mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
new Include/symbol page
This commit is contained in:
parent
116d4e034b
commit
972ac277a0
24 changed files with 1778 additions and 558 deletions
|
@ -9,6 +9,7 @@
|
|||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
|
@ -38,30 +39,45 @@ public class CPElement {
|
|||
public static final String MACRO_VALUE = "macrovalue"; //$NON-NLS-1$
|
||||
public static final String BASE_REF = "base-ref"; //$NON-NLS-1$
|
||||
public static final String BASE = "base-path"; //$NON-NLS-1$
|
||||
public static final String PARENT = "parent"; //$NON-NLS-1$
|
||||
public static final String PARENT_CONTAINER = "parent-container"; //$NON-NLS-1$
|
||||
|
||||
private final int fEntryKind;
|
||||
private final IPath fPath;
|
||||
private final ICProject fCProject;
|
||||
private final IResource fResource;
|
||||
private final ArrayList fChildren;
|
||||
private final ArrayList fChildren = new ArrayList(1);
|
||||
|
||||
private boolean fIsExported;
|
||||
private boolean fIsMissing;
|
||||
|
||||
private CPElement fParentContainer;
|
||||
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
|
||||
|
||||
// create a inherited element and apply to path/resource
|
||||
public CPElement(CPElement element, IPath path, IResource res) {
|
||||
this(element.getCProject(), element.getEntryKind(), path, res);
|
||||
setExported(element.isExported());
|
||||
fChildren.clear();
|
||||
for(int i = 0; i < element.fChildren.size(); i++) {
|
||||
CPElementAttribute attrib = (CPElementAttribute)element.fChildren.get(i);
|
||||
fChildren.add(new CPElementAttribute(this, attrib.getKey(), attrib.getValue()));
|
||||
}
|
||||
Inherited = element;
|
||||
}
|
||||
|
||||
public CPElement(ICProject project, int entryKind, IPath path, IResource res) {
|
||||
fCProject = project;
|
||||
fEntryKind = entryKind;
|
||||
fPath = path;
|
||||
fChildren = new ArrayList();
|
||||
fResource = res;
|
||||
|
||||
fIsExported = false;
|
||||
fIsMissing = false;
|
||||
fCachedEntry = null;
|
||||
fParentContainer = null;
|
||||
|
||||
switch (entryKind) {
|
||||
case IPathEntry.CDT_OUTPUT :
|
||||
|
@ -97,8 +113,15 @@ public class CPElement {
|
|||
IPathEntry[] entries = container.getPathEntries();
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
CPElement curr = createFromExisting(entries[i], fCProject);
|
||||
curr.setParentContainer(this);
|
||||
fChildren.add(curr);
|
||||
curr.createAttributeElement(PARENT_CONTAINER, this);
|
||||
CPElementGroup group = new CPElementGroup(this, curr.getEntryKind());
|
||||
int indx = fChildren.indexOf(group);
|
||||
if (indx == -1) {
|
||||
fChildren.add(group);
|
||||
} else {
|
||||
group = (CPElementGroup)fChildren.get(indx);
|
||||
}
|
||||
group.addChild(curr);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
|
@ -109,6 +132,9 @@ public class CPElement {
|
|||
}
|
||||
|
||||
public IPathEntry getPathEntry() {
|
||||
if (Inherited != null) {
|
||||
return null;
|
||||
}
|
||||
if (fCachedEntry == null) {
|
||||
fCachedEntry = newPathEntry();
|
||||
}
|
||||
|
@ -129,9 +155,8 @@ public class CPElement {
|
|||
IPath attach = (IPath)getAttribute(SOURCEATTACHMENT);
|
||||
if (!baseRef.isEmpty()) {
|
||||
return CoreModel.newLibraryRefEntry(fPath, baseRef, libraryPath);
|
||||
} else {
|
||||
return CoreModel.newLibraryEntry(fPath, base, libraryPath, attach, null, null, isExported());
|
||||
}
|
||||
return CoreModel.newLibraryEntry(fPath, base, libraryPath, attach, null, null, isExported());
|
||||
case IPathEntry.CDT_PROJECT :
|
||||
return CoreModel.newProjectEntry(fPath, isExported());
|
||||
case IPathEntry.CDT_CONTAINER :
|
||||
|
@ -140,18 +165,16 @@ public class CPElement {
|
|||
IPath include = (IPath)getAttribute(INCLUDE);
|
||||
if (!baseRef.isEmpty()) {
|
||||
return CoreModel.newIncludeRefEntry(fPath, baseRef, include);
|
||||
} else {
|
||||
}
|
||||
return CoreModel.newIncludeEntry(fPath, base, include, ((Boolean)getAttribute(SYSTEM_INCLUDE)).booleanValue(),
|
||||
exclusionPattern);
|
||||
}
|
||||
case IPathEntry.CDT_MACRO :
|
||||
String macroName = (String)getAttribute(MACRO_NAME);
|
||||
String macroValue = (String)getAttribute(MACRO_VALUE);
|
||||
if (!baseRef.isEmpty()) {
|
||||
return CoreModel.newMacroRefEntry(fPath, baseRef, macroName);
|
||||
} else {
|
||||
return CoreModel.newMacroEntry(fPath, macroName, macroValue, exclusionPattern);
|
||||
}
|
||||
return CoreModel.newMacroEntry(fPath, macroName, macroValue, exclusionPattern);
|
||||
default :
|
||||
return null;
|
||||
}
|
||||
|
@ -245,6 +268,31 @@ public class CPElement {
|
|||
return fResource;
|
||||
}
|
||||
|
||||
public CPElement getParentContainer() {
|
||||
CPElementAttribute attribute = findAttributeElement(PARENT_CONTAINER);
|
||||
if (attribute != null) {
|
||||
return (CPElement)attribute.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setParent(CPElementGroup group) {
|
||||
CPElementAttribute attribute = findAttributeElement(PARENT);
|
||||
if (attribute == null && group != null) {
|
||||
createAttributeElement(PARENT, group);
|
||||
return;
|
||||
}
|
||||
attribute.setValue(group);
|
||||
}
|
||||
|
||||
public CPElementGroup getParent() {
|
||||
CPElementAttribute attribute = findAttributeElement(PARENT);
|
||||
if (attribute != null) {
|
||||
return (CPElementGroup)attribute.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CPElementAttribute setAttribute(String key, Object value) {
|
||||
CPElementAttribute attribute = findAttributeElement(key);
|
||||
if (attribute == null) {
|
||||
|
@ -284,23 +332,28 @@ public class CPElement {
|
|||
switch (fEntryKind) {
|
||||
case IPathEntry.CDT_OUTPUT :
|
||||
case IPathEntry.CDT_SOURCE :
|
||||
return new Object[] { findAttributeElement(EXCLUSION)};
|
||||
case IPathEntry.CDT_LIBRARY:
|
||||
// return new Object[] { findAttributeElement(SOURCEATTACHMENT) };
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
case IPathEntry.CDT_MACRO :
|
||||
if (getInherited() == null && getParentContainer() == null) {
|
||||
return new Object[]{findAttributeElement(EXCLUSION)};
|
||||
}
|
||||
break;
|
||||
// case IPathEntry.CDT_LIBRARY :
|
||||
// return new Object[] { findAttributeElement(SOURCEATTACHMENT) };
|
||||
|
||||
case IPathEntry.CDT_CONTAINER : {
|
||||
List list = new ArrayList();
|
||||
for (int i = 0; i < fChildren.size(); i++) {
|
||||
Object curr = fChildren.get(i);
|
||||
if (curr instanceof CPElementGroup) {
|
||||
list.add(curr);
|
||||
}
|
||||
}
|
||||
return list.toArray();
|
||||
}
|
||||
}
|
||||
return new Object[0];
|
||||
}
|
||||
return fChildren.toArray();
|
||||
}
|
||||
|
||||
private void setParentContainer(CPElement element) {
|
||||
fParentContainer = element;
|
||||
}
|
||||
|
||||
public CPElement getParentContainer() {
|
||||
return fParentContainer;
|
||||
}
|
||||
|
||||
private void attributeChanged(String key) {
|
||||
fCachedEntry = null;
|
||||
|
@ -318,8 +371,8 @@ public class CPElement {
|
|||
switch (fEntryKind) {
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
return (getAttribute(LIBRARY).equals(elem.getAttribute(LIBRARY))
|
||||
&& getAttribute(BASE).equals(elem.getAttribute(BASE))
|
||||
&& getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)));
|
||||
&& getAttribute(BASE).equals(elem.getAttribute(BASE)) && getAttribute(BASE_REF).equals(
|
||||
elem.getAttribute(BASE_REF)));
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
return (getAttribute(INCLUDE).equals(elem.getAttribute(INCLUDE))
|
||||
&& getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
|
||||
|
@ -405,6 +458,10 @@ public class CPElement {
|
|||
}
|
||||
}
|
||||
|
||||
public CPElement getInherited() {
|
||||
return Inherited;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the project.
|
||||
*
|
||||
|
|
|
@ -22,8 +22,9 @@ import org.eclipse.jface.viewers.ViewerFilter;
|
|||
public class CPElementFilter extends ViewerFilter {
|
||||
|
||||
protected List fExcludes;
|
||||
protected int fKind;
|
||||
protected int[] fKind;
|
||||
protected boolean fExportedOnly;
|
||||
protected boolean fShowInherited;
|
||||
|
||||
/**
|
||||
* @param excludedFiles
|
||||
|
@ -31,16 +32,17 @@ public class CPElementFilter extends ViewerFilter {
|
|||
* @param recusive
|
||||
* Folders are only shown if, searched recursivly, contain an archive
|
||||
*/
|
||||
public CPElementFilter(Object[] excludedElements, int kind, boolean exportedOnly) {
|
||||
public CPElementFilter(Object[] excludedElements, int[] kind, boolean exportedOnly, boolean showInherited) {
|
||||
if (excludedElements != null) {
|
||||
fExcludes = Arrays.asList(excludedElements);
|
||||
}
|
||||
fKind = kind;
|
||||
fExportedOnly = exportedOnly;
|
||||
fShowInherited = showInherited;
|
||||
}
|
||||
|
||||
public CPElementFilter(int kind, boolean exportedOnly) {
|
||||
this(null, kind, exportedOnly);
|
||||
public CPElementFilter(int[] kind, boolean exportedOnly, boolean showInherited) {
|
||||
this(null, kind, exportedOnly, showInherited);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -48,23 +50,42 @@ public class CPElementFilter extends ViewerFilter {
|
|||
*/
|
||||
public boolean select(Viewer viewer, Object parent, Object element) {
|
||||
if (element instanceof CPElement) {
|
||||
if ( ((CPElement)element).getEntryKind() == fKind) {
|
||||
for (int i = 0; i < fKind.length; i++) {
|
||||
if ( ((CPElement)element).getEntryKind() == fKind[i]) {
|
||||
if (fExcludes == null || !fExcludes.contains(element)) {
|
||||
if (fExportedOnly == true) {
|
||||
if ( !fShowInherited ) {
|
||||
return ((CPElement)element).getInherited() == null && ((CPElement)element).isExported();
|
||||
}
|
||||
return ((CPElement)element).isExported();
|
||||
}
|
||||
if ( !fShowInherited ) {
|
||||
return ((CPElement)element).getInherited() == null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (element instanceof IPathEntry) {
|
||||
if ( ((IPathEntry)element).getEntryKind() == fKind) {
|
||||
for (int i = 0; i < fKind.length; i++) {
|
||||
if ( ((IPathEntry)element).getEntryKind() == fKind[i]) {
|
||||
if (fExcludes == null || !fExcludes.contains(element)) {
|
||||
if (fExportedOnly == true) {
|
||||
return ((IPathEntry)element).isExported();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (element instanceof CPElementGroup) {
|
||||
for (int i = 0; i < fKind.length; i++) {
|
||||
if ( ((CPElementGroup)element).getEntryKind() == fKind[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -11,32 +11,96 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
public class CPElementGroup {
|
||||
|
||||
CPElement element;
|
||||
int kind;
|
||||
private CPElement parent;
|
||||
private final int kind;
|
||||
private IResource resource;
|
||||
private List children = new ArrayList(1);
|
||||
|
||||
public CPElementGroup(CPElement element, int kind) {
|
||||
this.element = element;
|
||||
public CPElementGroup(IResource resource) {
|
||||
this.kind = -1;
|
||||
this.resource = resource;
|
||||
this.children = new ArrayList();
|
||||
}
|
||||
|
||||
public CPElementGroup(CPElement parent, int kind) {
|
||||
this.parent = parent;
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
public CPElement getElement() {
|
||||
return element;
|
||||
public IResource getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public int getEntryType() {
|
||||
public IPath getPath() {
|
||||
return resource != null ? resource.getFullPath() : parent.getPath();
|
||||
}
|
||||
|
||||
public CPElement getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public int getEntryKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public Object[] getChildren() {
|
||||
Object[] children = element.getChildren();
|
||||
List rv = new ArrayList();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
if ((children[i] instanceof CPElement) && ((CPElement)children[i]).getEntryKind() == kind) {
|
||||
rv.add(children[i]);
|
||||
public boolean equals(Object arg0) {
|
||||
if (arg0 == this) {
|
||||
return true;
|
||||
}
|
||||
if (arg0 instanceof CPElementGroup) {
|
||||
CPElementGroup other = (CPElementGroup)arg0;
|
||||
return (kind == other.kind && ( (parent == null && other.parent == null) || parent.equals(other.parent)) && ( (resource == null && other.resource == null) || resource.equals(other.resource)));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int hashCode = parent != null ? parent.hashCode() : 0;
|
||||
hashCode += resource != null ? resource.hashCode() : 0;
|
||||
return hashCode + kind;
|
||||
}
|
||||
|
||||
public void addChild(CPElement element) {
|
||||
int indx = children.indexOf(element);
|
||||
if (indx == -1) {
|
||||
children.add(element);
|
||||
element.setParent(this);
|
||||
} else { // add element with closes matching resource path.
|
||||
CPElement other = (CPElement)children.get(indx);
|
||||
if ( other.getInherited() != null && element.getInherited() != null) {
|
||||
IPath otherPath = other.getInherited().getPath();
|
||||
IPath elemPath = element.getInherited().getPath();
|
||||
if (!otherPath.equals(elemPath) && otherPath.isPrefixOf(elemPath)) {
|
||||
children.remove(indx);
|
||||
other.setParent(null);
|
||||
children.add(element);
|
||||
element.setParent(this);
|
||||
}
|
||||
}
|
||||
return rv.toArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void addChildren(CPElement[] elements) {
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
addChild(elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeChild(CPElement element) {
|
||||
boolean removed = children.remove(element);
|
||||
if (removed) {
|
||||
element.setParent(null);
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
public CPElement[] getChildren() {
|
||||
return (CPElement[])children.toArray(new CPElement[children.size()]);
|
||||
}
|
||||
|
||||
}
|
|
@ -12,35 +12,44 @@ import org.eclipse.cdt.core.model.CModelException;
|
|||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||
import org.eclipse.cdt.internal.ui.CElementImageProvider;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
|
||||
import org.eclipse.cdt.ui.CElementImageDescriptor;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IColorProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
class CPElementLabelProvider extends LabelProvider {
|
||||
class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
||||
|
||||
private final Color inDirect = new Color(Display.getDefault(), new RGB(170, 170, 170));
|
||||
|
||||
private String fNewLabel, fCreateLabel;
|
||||
private ImageDescriptor fIncludeIcon, fMacroIcon, fLibWSrcIcon, fLibIcon;
|
||||
private ImageDescriptor fFolderImage, fOutputImage, fProjectImage, fContainerImage;
|
||||
private boolean bShowExported;
|
||||
private boolean bShowParentInfo;
|
||||
private ImageDescriptorRegistry fRegistry;
|
||||
private CElementImageProvider fCImages;
|
||||
|
||||
public CPElementLabelProvider() {
|
||||
this(true);
|
||||
this(true, false);
|
||||
}
|
||||
|
||||
public CPElementLabelProvider(boolean showExported) {
|
||||
public CPElementLabelProvider(boolean showExported, boolean showParentInfo) {
|
||||
fNewLabel = CPathEntryMessages.getString("CPElementLabelProvider.new"); //$NON-NLS-1$
|
||||
fCreateLabel = CPathEntryMessages.getString("CPElementLabelProvider.willbecreated"); //$NON-NLS-1$
|
||||
fRegistry = CUIPlugin.getImageDescriptorRegistry();
|
||||
fCImages = new CElementImageProvider();
|
||||
|
||||
fLibIcon = CPluginImages.DESC_OBJS_ARCHIVE;
|
||||
fLibWSrcIcon = CPluginImages.DESC_OBJS_ARCHIVE_WSRC;
|
||||
|
@ -54,6 +63,7 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
|
||||
fProjectImage = workbench.getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
|
||||
bShowExported = showExported;
|
||||
bShowParentInfo = showParentInfo;
|
||||
}
|
||||
|
||||
public String getText(Object element) {
|
||||
|
@ -70,13 +80,18 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
}
|
||||
|
||||
private String getCPContainerGroupText(CPElementGroup group) {
|
||||
switch (group.getEntryType()) {
|
||||
switch (group.getEntryKind()) {
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
return CPathEntryMessages.getString("CPElementLabelProvider.Includes"); //$NON-NLS-1$
|
||||
case IPathEntry.CDT_MACRO :
|
||||
return CPathEntryMessages.getString("CPElementLabelProvider.PreprocessorSymbols"); //$NON-NLS-1$
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
return CPathEntryMessages.getString("CPElementLabelProvider.Libraries"); //$NON-NLS-1$
|
||||
case -1:
|
||||
if (group.getResource().getType() == IResource.PROJECT) {
|
||||
return group.getResource().getName();
|
||||
}
|
||||
return group.getResource().getProjectRelativePath().toString();
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
@ -128,6 +143,7 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
StringBuffer str = new StringBuffer();
|
||||
addBaseString(libPath, cpentry, str);
|
||||
addExport(cpentry, str);
|
||||
addParentInfo(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_PROJECT :
|
||||
|
@ -138,6 +154,7 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
StringBuffer str = new StringBuffer();
|
||||
addBaseString(incPath, cpentry, str);
|
||||
addExport(cpentry, str);
|
||||
addParentInfo(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_MACRO :
|
||||
|
@ -146,6 +163,7 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
+ (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
|
||||
addBaseString(null, cpentry, str);
|
||||
addExport(cpentry, str);
|
||||
addParentInfo(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_CONTAINER :
|
||||
|
@ -182,6 +200,28 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
}
|
||||
return CPathEntryMessages.getString("CPElementLabelProvider.unknown_element.label"); //$NON-NLS-1$
|
||||
}
|
||||
/**
|
||||
* @param cpentry
|
||||
* @param str
|
||||
*/
|
||||
private void addParentInfo(CPElement cpentry, StringBuffer str) {
|
||||
if (bShowParentInfo) {
|
||||
CPElement parent = cpentry.getParentContainer();
|
||||
if (parent != null) {
|
||||
str.append(" ["); //$NON-NLS-1$
|
||||
try {
|
||||
IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
|
||||
if (container != null) {
|
||||
str.append(container.getDescription());
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
str.append(parent.getPath());
|
||||
}
|
||||
str.append(']');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addExport(CPElement cpentry, StringBuffer str) {
|
||||
if (bShowExported && cpentry.isExported()) {
|
||||
str.append(' ');
|
||||
|
@ -244,15 +284,13 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
case IPathEntry.CDT_OUTPUT :
|
||||
if (cpentry.getPath().segmentCount() == 1) {
|
||||
return fProjectImage;
|
||||
} else {
|
||||
return fOutputImage;
|
||||
}
|
||||
return fOutputImage;
|
||||
case IPathEntry.CDT_SOURCE :
|
||||
if (cpentry.getPath().segmentCount() == 1) {
|
||||
return fProjectImage;
|
||||
} else {
|
||||
return fFolderImage;
|
||||
}
|
||||
return fFolderImage;
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
IPath path = (IPath)cpentry.getAttribute(CPElement.SOURCEATTACHMENT);
|
||||
if (path == null || path.isEmpty()) {
|
||||
|
@ -280,7 +318,10 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
ImageDescriptor imageDescriptor = getCPElementBaseImage(cpentry);
|
||||
if (imageDescriptor != null) {
|
||||
if (cpentry.isMissing()) {
|
||||
imageDescriptor = new CElementImageDescriptor(imageDescriptor, CElementImageDescriptor.WARNING, SMALL_SIZE);
|
||||
imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
|
||||
}
|
||||
if (cpentry.getInherited() != null) {
|
||||
imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.PATH_INHERIT, SMALL_SIZE);
|
||||
}
|
||||
return fRegistry.get(imageDescriptor);
|
||||
}
|
||||
|
@ -294,15 +335,37 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
} else if (element instanceof IPathEntry) {
|
||||
return getImage(CPElement.createFromExisting((IPathEntry)element, null));
|
||||
} else if (element instanceof CPElementGroup) {
|
||||
switch ( ((CPElementGroup)element).getEntryType()) {
|
||||
switch ( ((CPElementGroup)element).getEntryKind()) {
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
return CPluginImages.get(CPluginImages.IMG_OBJS_INCLUDES_CONTAINER);
|
||||
case IPathEntry.CDT_MACRO :
|
||||
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);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (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) {
|
||||
return inDirect;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
|
||||
*/
|
||||
public Color getBackground(Object element) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@
|
|||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerSorter;
|
||||
|
||||
public class CPElementSorter extends ViewerSorter {
|
||||
|
@ -34,8 +36,36 @@ public class CPElementSorter extends ViewerSorter {
|
|||
case IPathEntry.CDT_CONTAINER :
|
||||
return CONTAINER;
|
||||
}
|
||||
} else if (obj instanceof CPElementGroup) {
|
||||
switch ( ((CPElementGroup)obj).getEntryKind()) {
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
return LIBRARY;
|
||||
case IPathEntry.CDT_PROJECT :
|
||||
return PROJECT;
|
||||
case IPathEntry.CDT_SOURCE :
|
||||
return SOURCE;
|
||||
case IPathEntry.CDT_CONTAINER :
|
||||
return CONTAINER;
|
||||
case -1 :
|
||||
if ( ((CPElementGroup)obj).getResource() instanceof IProject) {
|
||||
return PROJECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
public void sort(Viewer viewer, Object[] elements) {
|
||||
// include paths and symbol definitions must not be sorted
|
||||
if (elements.length > 0 && elements[0] instanceof CPElement) {
|
||||
CPElement firstElement = (CPElement)elements[0];
|
||||
switch (firstElement.getEntryKind()) {
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
case IPathEntry.CDT_MACRO :
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.sort(viewer, elements);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.jface.resource.CompositeImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.graphics.ImageData;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
|
||||
public class CPListImageDescriptor extends CompositeImageDescriptor {
|
||||
|
||||
/** Flag to render the waring adornment */
|
||||
public final static int WARNING= 0x1;
|
||||
|
||||
/** Flag to render the inherited adornment */
|
||||
public final static int ERROR= 0x2;
|
||||
|
||||
/** Flag to render the inherited adornment */
|
||||
public final static int PATH_INHERIT= 0x4;
|
||||
|
||||
private ImageDescriptor fBaseImage;
|
||||
private int flags;
|
||||
private Point fSize;
|
||||
|
||||
public CPListImageDescriptor(ImageDescriptor baseImage, int flags, Point size) {
|
||||
fBaseImage = baseImage;
|
||||
this.flags = flags;
|
||||
fSize = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CompositeImageDescriptor#getSize()
|
||||
*/
|
||||
protected Point getSize() {
|
||||
if (fSize == null) {
|
||||
ImageData data = fBaseImage.getImageData();
|
||||
setSize(new Point(data.width, data.height));
|
||||
}
|
||||
return fSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof CPListImageDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CPListImageDescriptor other = (CPListImageDescriptor) object;
|
||||
return fBaseImage.equals(other.fBaseImage) && flags == other.flags && fSize.equals(other.fSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return fBaseImage.hashCode() & flags | fSize.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CompositeImageDescriptor#drawCompositeImage(int, int)
|
||||
*/
|
||||
protected void drawCompositeImage(int width, int height) {
|
||||
ImageData bg = fBaseImage.getImageData();
|
||||
if (bg == null) {
|
||||
bg = DEFAULT_IMAGE_DATA;
|
||||
}
|
||||
drawImage(bg, 0, 0);
|
||||
drawOverlays();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add any overlays to the image as specified in the flags.
|
||||
*/
|
||||
protected void drawOverlays() {
|
||||
Point size= getSize();
|
||||
ImageData data = null;
|
||||
int x= getSize().x;
|
||||
if ((flags & PATH_INHERIT) == PATH_INHERIT) {
|
||||
data = CPluginImages.DESC_OVR_PATH_INHERIT.getImageData();
|
||||
drawImage(data, x, 0);
|
||||
}
|
||||
x= 0;
|
||||
if ((flags & ERROR) != 0) {
|
||||
data= CPluginImages.DESC_OVR_ERROR.getImageData();
|
||||
drawImage(data, x, size.y - data.height);
|
||||
x+= data.width;
|
||||
}
|
||||
if ((flags & WARNING) != 0) {
|
||||
data= CPluginImages.DESC_OVR_WARNING.getImageData();
|
||||
drawImage(data, x, size.y - data.height);
|
||||
x+= data.width;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setSize(Point size) {
|
||||
fSize = size;
|
||||
}
|
||||
|
||||
}
|
|
@ -20,13 +20,13 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.SWTException;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
public class CPathContainerDescriptor implements IContainerDescriptor {
|
||||
|
||||
|
@ -63,12 +63,11 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
|
|||
Object elem = CoreUtility.createExtension(fConfigElement, ATT_PAGE_CLASS);
|
||||
if (elem instanceof ICPathContainerPage) {
|
||||
return (ICPathContainerPage) elem;
|
||||
} else {
|
||||
}
|
||||
String id = fConfigElement.getAttribute(ATT_ID);
|
||||
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
|
||||
"Invalid extension (page not of type IClasspathContainerPage): " + id, null)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return fConfigElement.getAttribute(ATT_NAME);
|
||||
|
@ -79,17 +78,18 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
|
|||
String imageName = fConfigElement.getAttribute(ATT_ICON);
|
||||
if (imageName != null) {
|
||||
IExtension extension = fConfigElement.getDeclaringExtension();
|
||||
IPluginDescriptor pd = extension.getDeclaringPluginDescriptor();
|
||||
Image image = getImageFromPlugin(pd, imageName);
|
||||
String plugin = extension.getNamespace();
|
||||
Image image = getImageFromPlugin(plugin, imageName);
|
||||
pageImage = image;
|
||||
}
|
||||
}
|
||||
return pageImage;
|
||||
}
|
||||
|
||||
public Image getImageFromPlugin(IPluginDescriptor pluginDescriptor, String subdirectoryAndFilename) {
|
||||
URL installURL = pluginDescriptor.getInstallURL();
|
||||
return getImageFromURL(installURL, subdirectoryAndFilename);
|
||||
public Image getImageFromPlugin(String plugin, String subdirectoryAndFilename) {
|
||||
Bundle bundle = Platform.getBundle(plugin);
|
||||
URL iconURL = bundle.getEntry("/"); //$NON-NLS-1$
|
||||
return getImageFromURL(iconURL, subdirectoryAndFilename);
|
||||
}
|
||||
|
||||
public Image getImageFromURL(URL installURL, String subdirectoryAndFilename) {
|
||||
|
@ -120,7 +120,7 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
|
|||
public static IContainerDescriptor[] getDescriptors() {
|
||||
ArrayList containers = new ArrayList();
|
||||
|
||||
IExtensionPoint extensionPoint = Platform.getPluginRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, ATT_EXTENSION);
|
||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, ATT_EXTENSION);
|
||||
if (extensionPoint != null) {
|
||||
IContainerDescriptor defaultPage = null;
|
||||
String defaultPageName = CPathContainerDefaultPage.class.getName();
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
|||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
@ -140,13 +139,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
|
|||
|
||||
public Object[] getChildren(TreeListDialogField field, Object element) {
|
||||
if (element instanceof CPElement) {
|
||||
CPElement cpElem = (CPElement)element;
|
||||
if (cpElem.getEntryKind() == IPathEntry.CDT_CONTAINER) {
|
||||
return new Object[]{new CPElementGroup(cpElem, IPathEntry.CDT_MACRO),
|
||||
new CPElementGroup(cpElem, IPathEntry.CDT_INCLUDE), new CPElementGroup(cpElem, IPathEntry.CDT_LIBRARY)};
|
||||
} else {
|
||||
return ((CPElement)element).getChildren();
|
||||
}
|
||||
} else if (element instanceof CPElementGroup) {
|
||||
return ((CPElementGroup)element).getChildren();
|
||||
}
|
||||
|
@ -157,7 +150,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
|
|||
if (element instanceof CPElementAttribute) {
|
||||
return ((CPElementAttribute)element).getParent();
|
||||
} else if (element instanceof CPElementGroup) {
|
||||
return ((CPElementGroup)element).getElement();
|
||||
return ((CPElementGroup)element).getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -322,17 +315,17 @@ public class CPathContainerEntryPage extends CPathBasePage {
|
|||
}
|
||||
|
||||
private void editAttributeEntry(CPElementAttribute elem) {
|
||||
String key = elem.getKey();
|
||||
if (key.equals(CPElement.SOURCEATTACHMENT)) {
|
||||
CPElement selElement = elem.getParent();
|
||||
|
||||
IPath containerPath = null;
|
||||
boolean applyChanges = false;
|
||||
Object parentContainer = selElement.getParentContainer();
|
||||
if (parentContainer instanceof CPElement) {
|
||||
containerPath = ((CPElement)parentContainer).getPath();
|
||||
applyChanges = true;
|
||||
}
|
||||
// String key = elem.getKey();
|
||||
// if (key.equals(CPElement.SOURCEATTACHMENT)) {
|
||||
// CPElement selElement = elem.getParent();
|
||||
//
|
||||
// IPath containerPath = null;
|
||||
// boolean applyChanges = false;
|
||||
// Object parentContainer = selElement.getParentContainer();
|
||||
// if (parentContainer instanceof CPElement) {
|
||||
// containerPath = ((CPElement)parentContainer).getPath();
|
||||
// applyChanges = true;
|
||||
// }
|
||||
// SourceAttachmentDialog dialog = new SourceAttachmentDialog(getShell(), (ILibraryEntry)selElement.getPathEntry(), containerPath,
|
||||
// fCurrCProject, applyChanges);
|
||||
// if (dialog.open() == Window.OK) {
|
||||
|
@ -340,7 +333,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
|
|||
// fContainersList.refresh();
|
||||
// fCPathList.refresh(); // images
|
||||
// }
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
private void editElementEntry(CPElement elem) {
|
||||
|
|
|
@ -38,24 +38,24 @@ public class CPathContainerWizard extends Wizard {
|
|||
private CPathFilterPage fFilterPage;
|
||||
|
||||
private CPathContainerSelectionPage fSelectionWizardPage;
|
||||
private int fFilterType;
|
||||
private int[] fFilterType;
|
||||
|
||||
/**
|
||||
* Constructor for ClasspathContainerWizard.
|
||||
*/
|
||||
public CPathContainerWizard(IPathEntry entryToEdit, ICElement currElement, IPathEntry[] currEntries) {
|
||||
this(entryToEdit, null, currElement, currEntries, -1);
|
||||
this(entryToEdit, null, currElement, currEntries, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for ClasspathContainerWizard.
|
||||
*/
|
||||
public CPathContainerWizard(IContainerDescriptor pageDesc, ICElement currElement, IPathEntry[] currEntries) {
|
||||
this(null, pageDesc, currElement, currEntries, -1);
|
||||
this(null, pageDesc, currElement, currEntries, null);
|
||||
}
|
||||
|
||||
public CPathContainerWizard(IPathEntry entryToEdit, IContainerDescriptor pageDesc, ICElement currElement,
|
||||
IPathEntry[] currEntries, int filterType) {
|
||||
IPathEntry[] currEntries, int[] filterType) {
|
||||
fEntryToEdit = entryToEdit;
|
||||
fPageDesc = pageDesc;
|
||||
fNewEntries = null;
|
||||
|
@ -108,7 +108,7 @@ public class CPathContainerWizard extends Wizard {
|
|||
// first page
|
||||
IContainerDescriptor[] containers = CPathContainerDescriptor.getDescriptors();
|
||||
List allContainers = new ArrayList(Arrays.asList(containers));
|
||||
if (fFilterType != -1) {
|
||||
if (fFilterType != null) {
|
||||
allContainers.add(0, new ProjectContainerDescriptor(fFilterType));
|
||||
}
|
||||
fSelectionWizardPage = new CPathContainerSelectionPage(
|
||||
|
@ -124,7 +124,7 @@ public class CPathContainerWizard extends Wizard {
|
|||
fContainerPage = getContainerPage(descriptor);
|
||||
addPage(fContainerPage);
|
||||
}
|
||||
if (fFilterType != -1) {
|
||||
if (fFilterType != null) {
|
||||
fFilterPage = new CPathFilterPage(fCurrElement, fFilterType);
|
||||
addPage(fFilterPage);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,32 @@ ProjectContainerPage.label=C/C++ Projects:
|
|||
# -------- ExtendingCPathBasePage ---------
|
||||
ExtendingCPathBasePage.sourcePaths=Source Paths:
|
||||
|
||||
# -------- CPathIncludeSymbolEntryPage --------
|
||||
IncludeSymbolEntryPage.title=Include/Symbols
|
||||
IncludeSymbolEntryPage.label=Include Paths and Preprocessor Symbols:
|
||||
IncludeSymbolEntryPage.addFolderFile=Add Folder/File...
|
||||
IncludeSymbolEntryPage.addUserSymbol=Add Preprocessor Symbol...
|
||||
IncludeSymbolEntryPage.addExternalInclude=Add External Include Path...
|
||||
IncludeSymbolEntryPage.addFromWorkspace=Add Include Path from Workspace...
|
||||
IncludeSymbolEntryPage.addContributed=Add Contributed...
|
||||
IncludeSymbolEntryPage.edit=Edit...
|
||||
IncludeSymbolEntryPage.remove=Remove
|
||||
IncludeSymbolEntryPage.export=Export
|
||||
IncludeSymbolEntryPage.up=Up
|
||||
IncludeSymbolEntryPage.down=Down
|
||||
IncludeSymbolsEntryPage.show_inherited.check=Show Inherited Paths
|
||||
IncludeSymbolEntryPage.addSymbol.title=Add Preprocessor Symbol
|
||||
IncludeSymbolEntryPage.addSymbol.message=Symbol definition:
|
||||
IncludeSymbolEntryPage.addExternal.button.browse=Browse...
|
||||
IncludeSymbolEntryPage.addExternal.title=Add External Include Path
|
||||
IncludeSymbolEntryPage.addExternal.message=Include path:
|
||||
IncludeSymbolEntryPage.ContainerDialog.new.title=Contributed Include Path Selection
|
||||
IncludeSymbolEntryPage.ContainerDialog.edit.title=Contributed Include Path Selection
|
||||
IncludeSymbolEntryPage.fromWorkspaceDialog.new.title=New Include Path from Workspace
|
||||
IncludeSymbolEntryPage.fromWorkspaceDialog.new.description=Select a folder as a include path from the workspace.
|
||||
IncludeSymbolEntryPage.fromWorkspaceDialog.edit.title=Edit Include Path from Workspace
|
||||
IncludeSymbolEntryPage.fromWorkspaceDialog.edit.description=Select a folder as a include path from the workspace.
|
||||
|
||||
# -------- SymbolsEntryPage ---------
|
||||
SymbolEntryPage.title=Symbols
|
||||
SymbolEntryPage.addUser=Add User Defined...
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.eclipse.swt.widgets.Label;
|
|||
|
||||
public class CPathFilterPage extends WizardPage {
|
||||
|
||||
private final int fFilterType;
|
||||
private final int[] fFilterType;
|
||||
|
||||
private CheckboxTableViewer viewer;
|
||||
private IPathEntry fParentEntry;
|
||||
|
@ -46,7 +46,7 @@ public class CPathFilterPage extends WizardPage {
|
|||
|
||||
protected ICElement fCElement;
|
||||
|
||||
protected CPathFilterPage(ICElement cElement, int filterType) {
|
||||
protected CPathFilterPage(ICElement cElement, int[] filterType) {
|
||||
super("CPathFilterPage"); //$NON-NLS-1$
|
||||
setTitle(CPathEntryMessages.getString("CPathFilterPage.title")); //$NON-NLS-1$
|
||||
setDescription(CPathEntryMessages.getString("CPathFilterPage.description")); //$NON-NLS-1$
|
||||
|
@ -68,7 +68,7 @@ public class CPathFilterPage extends WizardPage {
|
|||
label.setLayoutData(gd);
|
||||
viewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
viewer.setContentProvider(new ListContentProvider());
|
||||
viewer.setLabelProvider(new CPElementLabelProvider(false));
|
||||
viewer.setLabelProvider(new CPElementLabelProvider(false, false));
|
||||
viewer.addCheckStateListener(new ICheckStateListener() {
|
||||
|
||||
public void checkStateChanged(CheckStateChangedEvent event) {
|
||||
|
@ -110,16 +110,16 @@ public class CPathFilterPage extends WizardPage {
|
|||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
createExlusions();
|
||||
createExlusions(fParentEntry.getEntryKind() == IPathEntry.CDT_PROJECT);
|
||||
}
|
||||
|
||||
|
||||
private void createExlusions() {
|
||||
private void createExlusions(boolean showExported) {
|
||||
fExclusions = new ArrayList();
|
||||
if (filter != null) {
|
||||
viewer.removeFilter(filter);
|
||||
}
|
||||
filter = new CPElementFilter(fExclusions.toArray(), fFilterType, true);
|
||||
filter = new CPElementFilter(fExclusions.toArray(), fFilterType, showExported, false);
|
||||
viewer.addFilter(filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.internal.ui.wizards.NewWizardMessages;
|
||||
import org.eclipse.cdt.internal.ui.wizards.TypedElementSelectionValidator;
|
||||
import org.eclipse.cdt.internal.ui.wizards.TypedViewerFilter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
||||
|
@ -172,7 +171,7 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
|
|||
String title = (existing == null) ? CPathEntryMessages.getString("IncludeEntryPage.fromWorkspaceDialog.new.title") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("IncludeEntryPage.fromWorkspaceDialog.edit.title"); //$NON-NLS-1$
|
||||
String message = (existing == null) ? CPathEntryMessages.getString("IncludeEntryPage.fromWorkspaceDialog.new.description") //$NON-NLS-1$
|
||||
: NewWizardMessages.getString("IncludeEntryPage.fromWorkspaceDialog.edit.description"); //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("IncludeEntryPage.fromWorkspaceDialog.edit.description"); //$NON-NLS-1$
|
||||
|
||||
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
|
||||
new CElementContentProvider());
|
||||
|
@ -220,7 +219,7 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
|
|||
elem = existing.getPathEntry();
|
||||
}
|
||||
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, (ICElement)getSelection().get(0), getRawPathEntries(),
|
||||
IPathEntry.CDT_INCLUDE);
|
||||
new int[] {IPathEntry.CDT_INCLUDE});
|
||||
wizard.setWindowTitle(title);
|
||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||
IPathEntry parent = wizard.getEntriesParent();
|
||||
|
|
|
@ -0,0 +1,787 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||
import org.eclipse.cdt.core.model.IMacroEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.TypedElementSelectionValidator;
|
||||
import org.eclipse.cdt.internal.ui.wizards.TypedViewerFilter;
|
||||
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.ITreeListAdapter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
|
||||
import org.eclipse.cdt.ui.CElementContentProvider;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.dialogs.IInputValidator;
|
||||
import org.eclipse.jface.dialogs.InputDialog;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.SWT;
|
||||
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.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
|
||||
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
||||
|
||||
public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||
|
||||
private TreeListDialogField fIncludeSymPathsList;
|
||||
private SelectionButtonDialogField fShowInheritedPaths;
|
||||
private ICProject fCurrCProject;
|
||||
private ListDialogField fCPathList;
|
||||
private CPElementFilter fFilter;
|
||||
|
||||
private final int IDX_ADD_FOLDER_FILE = 0;
|
||||
private final int IDX_ADD_SYMBOL = 2;
|
||||
private final int IDX_ADD_EXT_INCLUDE = 4;
|
||||
private final int IDX_ADD_WS_INCLUDE = 5;
|
||||
private final int IDX_ADD_CONTRIBUTED = 7;
|
||||
private final int IDX_EDIT = 9;
|
||||
private final int IDX_REMOVE = 10;
|
||||
private final int IDX_EXPORT = 12;
|
||||
private final int IDX_UP = 14;
|
||||
private final int IDX_DOWN = 15;
|
||||
|
||||
private static final String[] buttonLabel = new String[]{
|
||||
|
||||
/* 0 */CPathEntryMessages.getString("IncludeSymbolEntryPage.addFolderFile"), //$NON-NLS-1$
|
||||
null,
|
||||
/* 2 */CPathEntryMessages.getString("IncludeSymbolEntryPage.addUserSymbol"), //$NON-NLS-1$
|
||||
null,
|
||||
/* 4 */CPathEntryMessages.getString("IncludeSymbolEntryPage.addExternalInclude"), //$NON-NLS-1$
|
||||
/* 5 */CPathEntryMessages.getString("IncludeSymbolEntryPage.addFromWorkspace"), //$NON-NLS-1$
|
||||
null,
|
||||
/* 7 */CPathEntryMessages.getString("IncludeSymbolEntryPage.addContributed"), //$NON-NLS-1$
|
||||
null,
|
||||
/* 9 */CPathEntryMessages.getString("IncludeSymbolEntryPage.edit"), //$NON-NLS-1$
|
||||
/* 10 */CPathEntryMessages.getString("IncludeSymbolEntryPage.remove"), //$NON-NLS-1$
|
||||
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$
|
||||
|
||||
private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter {
|
||||
|
||||
private final Object[] EMPTY_ARR = new Object[0];
|
||||
|
||||
// -------- IListAdapter --------
|
||||
public void customButtonPressed(TreeListDialogField field, int index) {
|
||||
ListCustomButtonPressed(field, index);
|
||||
}
|
||||
|
||||
public void selectionChanged(TreeListDialogField field) {
|
||||
ListPageSelectionChanged(field);
|
||||
}
|
||||
|
||||
public void doubleClicked(TreeListDialogField field) {
|
||||
ListPageDoubleClicked(field);
|
||||
}
|
||||
|
||||
public void keyPressed(TreeListDialogField field, KeyEvent event) {
|
||||
ListPageKeyPressed(field, event);
|
||||
}
|
||||
|
||||
public Object[] getChildren(TreeListDialogField field, Object element) {
|
||||
if (element instanceof CPElement) {
|
||||
return ((CPElement)element).getChildren();
|
||||
} else if (element instanceof CPElementGroup) {
|
||||
return ((CPElementGroup)element).getChildren();
|
||||
}
|
||||
return EMPTY_ARR;
|
||||
}
|
||||
|
||||
public Object getParent(TreeListDialogField field, Object element) {
|
||||
if (element instanceof CPElementGroup) {
|
||||
return ((CPElementGroup)element).getParent();
|
||||
} else if (element instanceof CPElement) {
|
||||
return ((CPElement)element).getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasChildren(TreeListDialogField field, Object element) {
|
||||
if (element instanceof CPElementGroup) {
|
||||
return true;
|
||||
}
|
||||
if (element instanceof CPElement) {
|
||||
return ((CPElement)element).getChildren().length > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------- IDialogFieldListener --------
|
||||
|
||||
public void dialogFieldChanged(DialogField field) {
|
||||
ListPageDialogFieldChanged(field);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CPathIncludeSymbolEntryPage(ListDialogField cPathList) {
|
||||
super(CPathEntryMessages.getString("IncludeSymbolEntryPage.title")); //$NON-NLS-1$
|
||||
fCPathList = cPathList;
|
||||
IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
|
||||
fIncludeSymPathsList = new TreeListDialogField(adapter, buttonLabel, new CPElementLabelProvider(true,
|
||||
true)) {
|
||||
|
||||
protected int getTreeStyle() {
|
||||
return super.getTreeStyle() & ~SWT.MULTI;
|
||||
}
|
||||
};
|
||||
fIncludeSymPathsList.setLabelText(CPathEntryMessages.getString("IncludeSymbolEntryPage.label")); //$NON-NLS-1$
|
||||
fIncludeSymPathsList.enableButton(IDX_REMOVE, false);
|
||||
fIncludeSymPathsList.enableButton(IDX_EDIT, false);
|
||||
fIncludeSymPathsList.enableButton(IDX_ADD_CONTRIBUTED, false);
|
||||
fIncludeSymPathsList.enableButton(IDX_ADD_EXT_INCLUDE, false);
|
||||
fIncludeSymPathsList.enableButton(IDX_ADD_WS_INCLUDE, false);
|
||||
fIncludeSymPathsList.enableButton(IDX_ADD_SYMBOL, false);
|
||||
fIncludeSymPathsList.enableButton(IDX_EXPORT, false);
|
||||
fIncludeSymPathsList.enableButton(IDX_UP, false);
|
||||
fIncludeSymPathsList.enableButton(IDX_DOWN, false);
|
||||
|
||||
fShowInheritedPaths= new SelectionButtonDialogField(SWT.CHECK);
|
||||
fShowInheritedPaths.setSelection(true);
|
||||
fShowInheritedPaths.setLabelText(CPathEntryMessages.getString("IncludeSymbolsEntryPage.show_inherited.check")); //$NON-NLS-1$
|
||||
fShowInheritedPaths.setDialogFieldListener(adapter);
|
||||
|
||||
fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER}, false, true);
|
||||
}
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
PixelConverter converter = new PixelConverter(parent);
|
||||
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
|
||||
LayoutUtil.doDefaultLayout(composite, new DialogField[]{fIncludeSymPathsList, fShowInheritedPaths}, true);
|
||||
LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null));
|
||||
|
||||
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
|
||||
fIncludeSymPathsList.setButtonsMinWidth(buttonBarWidth);
|
||||
setControl(composite);
|
||||
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
|
||||
fIncludeSymPathsList.getTreeViewer().setSorter(new CPElementSorter());
|
||||
}
|
||||
|
||||
public Image getImage() {
|
||||
return CPluginImages.get(CPluginImages.IMG_OBJS_INCLUDES_CONTAINER);
|
||||
}
|
||||
|
||||
public void init(ICProject cproject) {
|
||||
fCurrCProject = cproject;
|
||||
List elements = createGroups();
|
||||
fIncludeSymPathsList.setElements(elements);
|
||||
}
|
||||
|
||||
private List createGroups() {
|
||||
List cpelements = fCPathList.getElements();
|
||||
|
||||
// create resource groups
|
||||
List resourceGroups = new ArrayList(5);
|
||||
CPElementGroup projectGroup = new CPElementGroup(fCurrCProject.getResource());
|
||||
resourceGroups.add(projectGroup);
|
||||
for (int i = 0; i < cpelements.size(); i++) {
|
||||
CPElement element = (CPElement)cpelements.get(i);
|
||||
switch (element.getEntryKind()) {
|
||||
case IPathEntry.CDT_CONTAINER :
|
||||
projectGroup.addChild(element);
|
||||
break;
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
case IPathEntry.CDT_MACRO :
|
||||
CPElementGroup resGroup = new CPElementGroup(element.getResource());
|
||||
int ndx = resourceGroups.indexOf(resGroup);
|
||||
if (ndx == -1) {
|
||||
resourceGroups.add(resGroup);
|
||||
} else {
|
||||
resGroup = (CPElementGroup)resourceGroups.get(ndx);
|
||||
}
|
||||
resGroup.addChild(element);
|
||||
}
|
||||
}
|
||||
|
||||
// place each path in its appropriate inherited group (or not if
|
||||
// excluded)
|
||||
for (int i = 0; i < cpelements.size(); i++) {
|
||||
CPElement element = (CPElement)cpelements.get(i);
|
||||
switch (element.getEntryKind()) {
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
case IPathEntry.CDT_MACRO :
|
||||
addPathToResourceGroups(element, null, resourceGroups);
|
||||
}
|
||||
}
|
||||
return resourceGroups;
|
||||
}
|
||||
|
||||
private void addPathToResourceGroup(CPElement element, CPElementGroup parent, CPElementGroup group) {
|
||||
IPath resPath = element.getPath();
|
||||
IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
|
||||
if ( (group != parent || !group.getResource().equals(element.getResource()))
|
||||
&& 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()));
|
||||
}
|
||||
}
|
||||
|
||||
private void addPathToResourceGroups(CPElement element, CPElementGroup parent, List groups) {
|
||||
if (parent != null) {
|
||||
parent.addChild(element);
|
||||
}
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||
addPathToResourceGroup(element, parent, group);
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePathOnResourceGroups(CPElement element, List groups) {
|
||||
CPElementGroup parent = element.getParent();
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||
if (group != parent) {
|
||||
CPElement[] elements = group.getChildren();
|
||||
for (int j = 0; j < elements.length; j++) {
|
||||
if (elements[j].getInherited() == element) {
|
||||
group.removeChild(elements[j]);
|
||||
}
|
||||
}
|
||||
addPathToResourceGroup(element, parent, group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CPElement removePathFromResourceGroups(CPElement element, List groups) {
|
||||
CPElement Inherited = element.getInherited();
|
||||
CPElementGroup resGroup = element.getParent();
|
||||
resGroup.removeChild(element);
|
||||
if (Inherited != null) { // applied exclusion to orig.
|
||||
IPath exclude = element.getPath().removeFirstSegments(Inherited.getPath().segmentCount());
|
||||
IPath[] exclusions = (IPath[])Inherited.getAttribute(CPElement.EXCLUSION);
|
||||
IPath[] newExlusions = new IPath[exclusions.length + 1];
|
||||
System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
|
||||
newExlusions[exclusions.length] = exclude;
|
||||
Inherited.setAttribute(CPElement.EXCLUSION, newExlusions);
|
||||
} else { // remove all inherited
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||
CPElement elements[] = group.getChildren();
|
||||
for (int j = 0; j < elements.length; j++) {
|
||||
if (elements[j].getInherited() == element) {
|
||||
group.removeChild(elements[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return element;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean canRemove(List selected) {
|
||||
if (selected.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
Object elem = selected.get(0);
|
||||
if (elem instanceof CPElement) {
|
||||
CPElement element = (CPElement)elem;
|
||||
if (element.getParentContainer() == null) {
|
||||
return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
|
||||
}
|
||||
} else if (elem instanceof CPElementAttribute) {
|
||||
CPElementAttribute attrib = (CPElementAttribute)elem;
|
||||
if (attrib.getKey().equals(CPElement.EXCLUSION)) {
|
||||
if ( ((IPath[])attrib.getValue()).length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean canEdit(List selected) {
|
||||
if (selected.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
Object elem = selected.get(0);
|
||||
if (elem instanceof CPElement) {
|
||||
CPElement element = (CPElement)selected.get(0);
|
||||
if (element.getParentContainer() == null && element.getInherited() == null) {
|
||||
return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
|
||||
}
|
||||
}
|
||||
if (elem instanceof CPElementAttribute) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param selected
|
||||
* @return
|
||||
*/
|
||||
private boolean canAddPath(List selected) {
|
||||
CPElementGroup group = getSelectedGroup();
|
||||
if (group != null) {
|
||||
return group.getEntryKind() == -1; // resource group
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private CPElementGroup getSelectedGroup() {
|
||||
List selected = fIncludeSymPathsList.getSelectedElements();
|
||||
if (!selected.isEmpty()) {
|
||||
Object item = selected.get(0);
|
||||
if (item instanceof CPElement) {
|
||||
item = ((CPElement)item).getParent();
|
||||
}
|
||||
if (item instanceof CPElementGroup) {
|
||||
return (CPElementGroup)item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void ListCustomButtonPressed(TreeListDialogField field, int index) {
|
||||
switch (index) {
|
||||
case IDX_ADD_FOLDER_FILE :
|
||||
addNewPathResource();
|
||||
break;
|
||||
case IDX_ADD_SYMBOL :
|
||||
addSymbol();
|
||||
break;
|
||||
case IDX_ADD_EXT_INCLUDE :
|
||||
addInclude();
|
||||
break;
|
||||
case IDX_ADD_WS_INCLUDE :
|
||||
addFromWorkspace();
|
||||
break;
|
||||
case IDX_ADD_CONTRIBUTED :
|
||||
addContributed();
|
||||
break;
|
||||
case IDX_EDIT :
|
||||
if (canEdit(field.getSelectedElements())) {
|
||||
editEntry();
|
||||
}
|
||||
break;
|
||||
case IDX_REMOVE :
|
||||
if (canRemove(field.getSelectedElements())) {
|
||||
removeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addNewPathResource() {
|
||||
Class[] acceptedClasses = new Class[]{ICProject.class, ICContainer.class, ITranslationUnit.class};
|
||||
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
|
||||
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
|
||||
|
||||
String title = CPathEntryMessages.getString("IncludeSymbolEntryPage.newResource.title"); //$NON-NLS-1$
|
||||
String message = CPathEntryMessages.getString("IncludeSymbolEntryPage.newResource.description"); //$NON-NLS-1$
|
||||
|
||||
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
|
||||
new CElementContentProvider());
|
||||
dialog.setValidator(validator);
|
||||
dialog.setTitle(title);
|
||||
dialog.setMessage(message);
|
||||
dialog.addFilter(filter);
|
||||
dialog.setInput(fCurrCProject);
|
||||
dialog.setInitialSelection(fCurrCProject);
|
||||
|
||||
if (dialog.open() == Window.OK) {
|
||||
Object[] elements = dialog.getResult();
|
||||
IResource resource;
|
||||
if (elements[0] instanceof IResource) {
|
||||
resource = (IResource)elements[0];
|
||||
} else {
|
||||
resource = ((ICElement)elements[0]).getResource();
|
||||
}
|
||||
CPElementGroup newGroup = new CPElementGroup(resource);
|
||||
if (!fIncludeSymPathsList.getElements().contains(newGroup)) {
|
||||
List cpelements = fCPathList.getElements();
|
||||
for (int i = 0; i < cpelements.size(); i++) {
|
||||
CPElement element = (CPElement)cpelements.get(i);
|
||||
if (element.getPath().isPrefixOf(newGroup.getPath())) {
|
||||
switch (element.getEntryKind()) {
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
case IPathEntry.CDT_MACRO :
|
||||
addPathToResourceGroup(element, null, newGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
fIncludeSymPathsList.addElement(newGroup);
|
||||
}
|
||||
fIncludeSymPathsList.selectElements(new StructuredSelection(newGroup));
|
||||
fIncludeSymPathsList.expandElement(newGroup, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void editEntry() {
|
||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
||||
if (selElements.size() != 1) {
|
||||
return;
|
||||
}
|
||||
Object element = selElements.get(0);
|
||||
|
||||
if (element instanceof CPElement) {
|
||||
} else if (element instanceof CPElementAttribute) {
|
||||
editAttributeEntry((CPElementAttribute)element);
|
||||
}
|
||||
}
|
||||
|
||||
private void editAttributeEntry(CPElementAttribute elem) {
|
||||
String key = elem.getKey();
|
||||
if (key.equals(CPElement.EXCLUSION)) {
|
||||
CPElement selElement = elem.getParent();
|
||||
ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
|
||||
if (dialog.open() == Window.OK) {
|
||||
selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
|
||||
fCPathList.dialogFieldChanged(); // validate
|
||||
updatePathOnResourceGroups(selElement, fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeEntry() {
|
||||
List selected = getSelection();
|
||||
Object elem = selected.get(0);
|
||||
if (elem instanceof CPElement) {
|
||||
CPElement removed = removePathFromResourceGroups((CPElement)elem, fIncludeSymPathsList.getElements());
|
||||
if (removed != null) {
|
||||
fCPathList.removeElement(removed);
|
||||
}
|
||||
fCPathList.dialogFieldChanged(); // validate
|
||||
fIncludeSymPathsList.refresh();
|
||||
} else if (elem instanceof CPElementAttribute) {
|
||||
CPElementAttribute attrib = (CPElementAttribute)elem;
|
||||
String key = attrib.getKey();
|
||||
Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
|
||||
attrib.getParent().setAttribute(key, value);
|
||||
updatePathOnResourceGroups(attrib.getParent(), fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void ListPageDoubleClicked(TreeListDialogField field) {
|
||||
if (canEdit(fIncludeSymPathsList.getSelectedElements())) {
|
||||
editEntry();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ListPageKeyPressed(TreeListDialogField field, KeyEvent event) {
|
||||
if (field == fIncludeSymPathsList) {
|
||||
if (event.character == SWT.DEL && event.stateMask == 0) {
|
||||
List selection = field.getSelectedElements();
|
||||
if (canEdit(selection)) {
|
||||
removeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IPathEntry[] getRawPathEntries() {
|
||||
IPathEntry[] currEntries = new IPathEntry[fCPathList.getElements().size()];
|
||||
for (int i = 0; i < currEntries.length; i++) {
|
||||
CPElement curr = (CPElement)fCPathList.getElement(i);
|
||||
currEntries[i] = curr.getPathEntry();
|
||||
}
|
||||
return currEntries;
|
||||
}
|
||||
|
||||
protected void addSymbol() {
|
||||
// Popup an entry dialog
|
||||
InputDialog dialog = new InputDialog(getShell(), CPathEntryMessages.getString("IncludeSymbolEntryPage.addSymbol.title"), //$NON-NLS-1$
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addSymbol.message"), "", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
null);
|
||||
String symbol = null;
|
||||
if (dialog.open() == Window.OK) {
|
||||
symbol = dialog.getValue();
|
||||
if (symbol != null && symbol.length() > 0) {
|
||||
List cplist = fCPathList.getElements();
|
||||
CPElementGroup group = getSelectedGroup();
|
||||
CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
|
||||
group.getResource());
|
||||
String name, value = ""; //$NON-NLS-1$
|
||||
int index = symbol.indexOf("="); //$NON-NLS-1$
|
||||
if (index != -1) {
|
||||
name = symbol.substring(0, index).trim();
|
||||
value = symbol.substring(index + 1).trim();
|
||||
} else {
|
||||
name = symbol.trim();
|
||||
}
|
||||
newPath.setAttribute(CPElement.MACRO_NAME, name);
|
||||
newPath.setAttribute(CPElement.MACRO_VALUE, value);
|
||||
|
||||
if (!cplist.contains(newPath)) {
|
||||
fCPathList.addElement(newPath);
|
||||
addPathToResourceGroups(newPath, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addInclude() {
|
||||
InputDialog dialog = new SelectPathInputDialog(getShell(),
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addExternal.title"), //$NON-NLS-1$
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addExternal.message"), null, null); //$NON-NLS-1$
|
||||
String newItem = null;
|
||||
if (dialog.open() == Window.OK) {
|
||||
newItem = dialog.getValue();
|
||||
if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$
|
||||
List cplist = fCPathList.getElements();
|
||||
CPElementGroup group = getSelectedGroup();
|
||||
CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
||||
group.getResource());
|
||||
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
||||
if (!cplist.contains(newPath)) {
|
||||
fCPathList.addElement(newPath);
|
||||
addPathToResourceGroups(newPath, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addFromWorkspace() {
|
||||
CPElement[] includes = openWorkspacePathEntryDialog(null);
|
||||
if (includes != null) {
|
||||
int nElementsChosen = includes.length;
|
||||
// remove duplicates
|
||||
List cplist = fCPathList.getElements();
|
||||
for (int i = 0; i < nElementsChosen; i++) {
|
||||
CPElement curr = includes[i];
|
||||
if (!cplist.contains(curr)) {
|
||||
fCPathList.addElement(curr);
|
||||
addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
|
||||
Class[] acceptedClasses = new Class[]{ICProject.class, IProject.class, IContainer.class, ICContainer.class};
|
||||
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
|
||||
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
|
||||
|
||||
String title = (existing == null) ? CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.new.title") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.edit.title"); //$NON-NLS-1$
|
||||
String message = (existing == null)
|
||||
? CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.new.description") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.edit.description"); //$NON-NLS-1$
|
||||
|
||||
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
|
||||
new CElementContentProvider());
|
||||
dialog.setValidator(validator);
|
||||
dialog.setTitle(title);
|
||||
dialog.setMessage(message);
|
||||
dialog.addFilter(filter);
|
||||
dialog.setInput(CoreModel.getDefault().getCModel());
|
||||
if (existing == null) {
|
||||
dialog.setInitialSelection(fCurrCProject);
|
||||
} else {
|
||||
dialog.setInitialSelection(existing.getCProject());
|
||||
}
|
||||
|
||||
if (dialog.open() == Window.OK) {
|
||||
Object[] elements = dialog.getResult();
|
||||
CPElement[] res = new CPElement[elements.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
IProject project;
|
||||
IPath includePath;
|
||||
if (elements[i] instanceof IResource) {
|
||||
project = ((IResource)elements[i]).getProject();
|
||||
includePath = ((IResource)elements[i]).getProjectRelativePath();
|
||||
} else {
|
||||
project = ((ICElement)elements[i]).getCProject().getProject();
|
||||
includePath = ((ICElement)elements[i]).getResource().getProjectRelativePath();
|
||||
}
|
||||
CPElementGroup group = getSelectedGroup();
|
||||
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
||||
group.getResource());
|
||||
res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative());
|
||||
res[i].setAttribute(CPElement.INCLUDE, includePath);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected CPElement[] openContainerSelectionDialog(CPElement existing) {
|
||||
IPathEntry elem = null;
|
||||
String title;
|
||||
if (existing == null) {
|
||||
title = CPathEntryMessages.getString("IncludeSymbolEntryPage.ContainerDialog.new.title"); //$NON-NLS-1$
|
||||
} else {
|
||||
title = CPathEntryMessages.getString("IncludeSymbolEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
|
||||
elem = existing.getPathEntry();
|
||||
}
|
||||
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(), new int[]{
|
||||
IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO});
|
||||
wizard.setWindowTitle(title);
|
||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||
IPathEntry parent = wizard.getEntriesParent();
|
||||
IPathEntry[] elements = wizard.getEntries();
|
||||
|
||||
if (elements != null) {
|
||||
CPElement[] res = new CPElement[elements.length];
|
||||
CPElementGroup group = getSelectedGroup();
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
if (elements[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
||||
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
||||
group.getResource());
|
||||
res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry)elements[i]).getIncludePath());
|
||||
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
|
||||
} else if (elements[i].getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
|
||||
group.getResource());
|
||||
res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry)elements[i]).getMacroName());
|
||||
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void addContributed() {
|
||||
CPElement[] includes = openContainerSelectionDialog(null);
|
||||
if (includes != null) {
|
||||
int nElementsChosen = includes.length;
|
||||
// remove duplicates
|
||||
List cplist = fCPathList.getElements();
|
||||
|
||||
for (int i = 0; i < nElementsChosen; i++) {
|
||||
CPElement curr = includes[i];
|
||||
if (!cplist.contains(curr)) {
|
||||
fCPathList.addElement(curr);
|
||||
addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SelectPathInputDialog extends InputDialog {
|
||||
|
||||
public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
|
||||
IInputValidator validator) {
|
||||
super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
|
||||
}
|
||||
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
super.createButtonsForButtonBar(parent);
|
||||
Button browse = createButton(parent, 3,
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addExternal.button.browse"), //$NON-NLS-1$
|
||||
true); //$NON-NLS-1$
|
||||
browse.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
public void widgetSelected(SelectionEvent ev) {
|
||||
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
|
||||
String currentName = getText().getText();
|
||||
if (currentName != null && currentName.trim().length() != 0) {
|
||||
dialog.setFilterPath(currentName);
|
||||
}
|
||||
String dirname = dialog.open();
|
||||
if (dirname != null) {
|
||||
getText().setText(dirname);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#getSelection()
|
||||
*/
|
||||
public List getSelection() {
|
||||
return fIncludeSymPathsList.getSelectedElements();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#setSelection(java.util.List)
|
||||
*/
|
||||
public void setSelection(List selElements) {
|
||||
fIncludeSymPathsList.selectElements(new StructuredSelection(selElements));
|
||||
}
|
||||
|
||||
public boolean isEntryKind(int kind) {
|
||||
return kind == IPathEntry.CDT_INCLUDE || kind == IPathEntry.CDT_MACRO;
|
||||
}
|
||||
|
||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||
}
|
||||
|
||||
public void performDefaults() {
|
||||
}
|
||||
}
|
|
@ -506,7 +506,7 @@ public class CPathLibraryEntryPage extends CPathBasePage {
|
|||
elem = existing.getPathEntry();
|
||||
}
|
||||
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(),
|
||||
IPathEntry.CDT_LIBRARY);
|
||||
new int[] {IPathEntry.CDT_LIBRARY});
|
||||
wizard.setWindowTitle(title);
|
||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||
IPathEntry parent = wizard.getEntriesParent();
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
/***********************************************************************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This program and the accompanying materials are made
|
||||
* available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
**********************************************************************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -93,7 +92,6 @@ public class CPathOutputEntryPage extends CPathBasePage {
|
|||
fOutputList.enableButton(IDX_REMOVE, false);
|
||||
}
|
||||
|
||||
|
||||
public Image getImage() {
|
||||
return CPluginImages.get(CPluginImages.IMG_OBJS_CONTAINER);
|
||||
}
|
||||
|
@ -420,13 +418,11 @@ public class CPathOutputEntryPage extends CPathBasePage {
|
|||
return newCPOutputElement(createdFolder);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
String title = (existing == null) ? CPathEntryMessages.getString("SourcePathEntryPage.NewSourceFolderDialog.new.title") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("SourcePathEntryPage.NewSourceFolderDialog.edit.title"); //$NON-NLS-1$
|
||||
|
||||
IProject proj = fCurrCProject.getProject();
|
||||
NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj, getExistingContainers(existing),
|
||||
existing);
|
||||
NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj, getExistingContainers(existing), existing);
|
||||
dialog.setMessage(CPathEntryMessages.getFormattedString("SourcePathEntryPage.NewSourceFolderDialog.description", //$NON-NLS-1$
|
||||
fProjPath.toString()));
|
||||
if (dialog.open() == Window.OK) {
|
||||
|
@ -435,7 +431,6 @@ public class CPathOutputEntryPage extends CPathBasePage {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void askForAddingExclusionPatternsDialog(List newEntries, Set modifiedEntries) {
|
||||
fixNestingConflicts(newEntries, fOutputList.getElements(), modifiedEntries);
|
||||
|
@ -465,9 +460,11 @@ public class CPathOutputEntryPage extends CPathBasePage {
|
|||
ILabelProvider lp = new WorkbenchLabelProvider();
|
||||
ITreeContentProvider cp = new BaseWorkbenchContentProvider();
|
||||
|
||||
String title = (existing == null) ? CPathEntryMessages.getString("OutputPathEntryPage.ExistingOutputFolderDialog.new.title") //$NON-NLS-1$
|
||||
String title = (existing == null)
|
||||
? CPathEntryMessages.getString("OutputPathEntryPage.ExistingOutputFolderDialog.new.title") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("OutputPathEntryPage.ExistingOutputFolderDialog.edit.title"); //$NON-NLS-1$
|
||||
String message = (existing == null) ? CPathEntryMessages.getString("OutputPathEntryPage.ExistingOutputFolderDialog.new.description") //$NON-NLS-1$
|
||||
String message = (existing == null)
|
||||
? CPathEntryMessages.getString("OutputPathEntryPage.ExistingOutputFolderDialog.new.description") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("OutputPathEntryPage.ExistingOutputFolderDialog.edit.description"); //$NON-NLS-1$
|
||||
|
||||
MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(getShell(), lp, cp);
|
||||
|
|
|
@ -93,7 +93,6 @@ public class CPathSourceEntryPage extends CPathBasePage {
|
|||
fFoldersList.enableButton(IDX_REMOVE, false);
|
||||
}
|
||||
|
||||
|
||||
public Image getImage() {
|
||||
return CPluginImages.get(CPluginImages.IMG_OBJS_SOURCE_ROOT);
|
||||
}
|
||||
|
@ -419,13 +418,12 @@ public class CPathSourceEntryPage extends CPathBasePage {
|
|||
return newCPSourceElement(createdFolder);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
String title = (existing == null) ? CPathEntryMessages.getString("SourcePathEntryPage.NewSourceFolderDialog.new.title") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("SourcePathEntryPage.NewSourceFolderDialog.edit.title"); //$NON-NLS-1$
|
||||
|
||||
IProject proj = fCurrCProject.getProject();
|
||||
NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj, getExistingContainers(existing),
|
||||
existing);
|
||||
NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj, getExistingContainers(existing), existing);
|
||||
dialog.setMessage(CPathEntryMessages.getFormattedString("SourcePathEntryPage.NewSourceFolderDialog.description", //$NON-NLS-1$
|
||||
fProjPath.toString()));
|
||||
if (dialog.open() == Window.OK) {
|
||||
|
@ -434,7 +432,6 @@ public class CPathSourceEntryPage extends CPathBasePage {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void askForAddingExclusionPatternsDialog(List newEntries, Set modifiedEntries) {
|
||||
fixNestingConflicts(newEntries, fFoldersList.getElements(), modifiedEntries);
|
||||
|
@ -464,9 +461,11 @@ public class CPathSourceEntryPage extends CPathBasePage {
|
|||
ILabelProvider lp = new WorkbenchLabelProvider();
|
||||
ITreeContentProvider cp = new BaseWorkbenchContentProvider();
|
||||
|
||||
String title = (existing == null) ? CPathEntryMessages.getString("SourcePathEntryPage.ExistingSourceFolderDialog.new.title") //$NON-NLS-1$
|
||||
String title = (existing == null)
|
||||
? CPathEntryMessages.getString("SourcePathEntryPage.ExistingSourceFolderDialog.new.title") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("SourcePathEntryPage.ExistingSourceFolderDialog.edit.title"); //$NON-NLS-1$
|
||||
String message = (existing == null) ? CPathEntryMessages.getString("SourcePathEntryPage.ExistingSourceFolderDialog.new.description") //$NON-NLS-1$
|
||||
String message = (existing == null)
|
||||
? CPathEntryMessages.getString("SourcePathEntryPage.ExistingSourceFolderDialog.new.description") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("SourcePathEntryPage.ExistingSourceFolderDialog.edit.description"); //$NON-NLS-1$
|
||||
|
||||
MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(getShell(), lp, cp);
|
||||
|
|
|
@ -157,7 +157,7 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
|
|||
elem = existing.getPathEntry();
|
||||
}
|
||||
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, (ICElement)getSelection().get(0), getRawPathEntries(),
|
||||
IPathEntry.CDT_MACRO);
|
||||
new int[] {IPathEntry.CDT_MACRO});
|
||||
wizard.setWindowTitle(title);
|
||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||
IPathEntry parent = wizard.getEntriesParent();
|
||||
|
|
|
@ -219,9 +219,8 @@ public class ExclusionPatternEntryDialog extends StatusDialog {
|
|||
IPath path = res.getFullPath().removeFirstSegments(fCurrSourceFolder.getFullPath().segmentCount()).makeRelative();
|
||||
if (res instanceof IContainer) {
|
||||
return path.addTrailingSeparator();
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
|
@ -32,15 +31,11 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.resource.CompositeImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IColorProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.ImageData;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
@ -74,84 +69,6 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
|||
|
||||
private final Color inDirect = new Color(Display.getDefault(), new RGB(170, 170, 170));
|
||||
|
||||
private class CPListImageDescriptor extends CompositeImageDescriptor {
|
||||
|
||||
private Image fBaseImage;
|
||||
private boolean showInherited;
|
||||
private Point fSize;
|
||||
|
||||
public CPListImageDescriptor(Image baseImage, boolean inherited) {
|
||||
fBaseImage = baseImage;
|
||||
showInherited = inherited;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CompositeImageDescriptor#getSize()
|
||||
*/
|
||||
protected Point getSize() {
|
||||
if (fSize == null) {
|
||||
ImageData data = fBaseImage.getImageData();
|
||||
setSize(new Point(data.width, data.height));
|
||||
}
|
||||
return fSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof CPListImageDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CPListImageDescriptor other = (CPListImageDescriptor) object;
|
||||
return (fBaseImage.equals(other.fBaseImage) && showInherited == other.showInherited);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return fBaseImage.hashCode() & (showInherited ? ~0x1 : ~0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CompositeImageDescriptor#drawCompositeImage(int, int)
|
||||
*/
|
||||
protected void drawCompositeImage(int width, int height) {
|
||||
ImageData bg = fBaseImage.getImageData();
|
||||
if (bg == null) {
|
||||
bg = DEFAULT_IMAGE_DATA;
|
||||
}
|
||||
drawImage(bg, 0, 0);
|
||||
drawOverlays();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add any overlays to the image as specified in the flags.
|
||||
*/
|
||||
protected void drawOverlays() {
|
||||
ImageData data = null;
|
||||
if (showInherited) {
|
||||
data = CPluginImages.DESC_OVR_PATH_INHERIT.getImageData();
|
||||
drawImage(data, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setSize(Point size) {
|
||||
fSize = size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Image getImage(Object element) {
|
||||
Image image = super.getImage(element);
|
||||
if (isPathInheritedFromSelected((CPElement) element)) {
|
||||
image = new CPListImageDescriptor(image, true).createImage();
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
public Color getBackground(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
|||
private static final String PAGE_SETTINGS = "IncludeSysmbolsPropertyPage"; //$NON-NLS-1$
|
||||
private static final String INDEX = "pageIndex"; //$NON-NLS-1$
|
||||
|
||||
IncludesSymbolsTabBlock fIncludesSymbolsBlock;
|
||||
NewIncludesSymbolsTabBlock fIncludesSymbolsBlock;
|
||||
|
||||
/**
|
||||
* @see PropertyPage#createContents
|
||||
|
@ -56,6 +56,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
|||
result = createWithCProject(parent, project);
|
||||
}
|
||||
Dialog.applyDialogFont(result);
|
||||
noDefaultAndApplyButton();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
|||
* Content for valid projects.
|
||||
*/
|
||||
private Control createWithCProject(Composite parent, IProject project) {
|
||||
fIncludesSymbolsBlock = new IncludesSymbolsTabBlock(this, getSettings().getInt(INDEX));
|
||||
fIncludesSymbolsBlock = new NewIncludesSymbolsTabBlock(this, getSettings().getInt(INDEX));
|
||||
fIncludesSymbolsBlock.init(getCElement(), null);
|
||||
return fIncludesSymbolsBlock.createContents(parent);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
|
||||
public class NewIncludesSymbolsTabBlock extends AbstractPathOptionBlock {
|
||||
|
||||
private int[] pathTypes = { IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER};
|
||||
|
||||
private CPathIncludeSymbolEntryPage fIncludeSymbols;
|
||||
|
||||
private CheckedListDialogField fCPathList;
|
||||
|
||||
private List fCPaths;
|
||||
|
||||
private class BuildPathAdapter implements IDialogFieldListener {
|
||||
|
||||
// ---------- IDialogFieldListener --------
|
||||
public void dialogFieldChanged(DialogField field) {
|
||||
buildPathDialogFieldChanged(field);
|
||||
}
|
||||
}
|
||||
|
||||
void buildPathDialogFieldChanged(DialogField field) {
|
||||
if (field == fCPathList) {
|
||||
updateCPathStatus();
|
||||
}
|
||||
doStatusLineUpdate();
|
||||
}
|
||||
|
||||
public NewIncludesSymbolsTabBlock(IStatusChangeListener context, int pageToShow) {
|
||||
super(context, pageToShow);
|
||||
|
||||
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$
|
||||
|
||||
};
|
||||
BuildPathAdapter adapter = new BuildPathAdapter();
|
||||
|
||||
fCPathList = new CheckedListDialogField(null, buttonLabels, new CPElementLabelProvider());
|
||||
fCPathList.setDialogFieldListener(adapter);
|
||||
fCPathList.setLabelText(CPathEntryMessages.getString("CPathsBlock.path.label")); //$NON-NLS-1$
|
||||
fCPathList.setUpButtonIndex(0);
|
||||
fCPathList.setDownButtonIndex(1);
|
||||
fCPathList.setCheckAllButtonIndex(3);
|
||||
fCPathList.setUncheckAllButtonIndex(4);
|
||||
}
|
||||
|
||||
protected void addTabs() {
|
||||
fIncludeSymbols = new CPathIncludeSymbolEntryPage(fCPathList);
|
||||
addPage(fIncludeSymbols);
|
||||
}
|
||||
|
||||
public Control createContents(Composite parent) {
|
||||
Control control = super.createContents(parent);
|
||||
if (getCProject() != null) {
|
||||
fIncludeSymbols.init(getCProject());
|
||||
}
|
||||
Dialog.applyDialogFont(control);
|
||||
return control;
|
||||
}
|
||||
|
||||
protected List getCPaths() {
|
||||
return fCPathList.getElements();
|
||||
}
|
||||
|
||||
protected int[] getFilteredTypes() {
|
||||
return pathTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the build path.
|
||||
*/
|
||||
public void updateCPathStatus() {
|
||||
getPathStatus().setOK();
|
||||
|
||||
List elements = fCPathList.getElements();
|
||||
|
||||
CPElement entryMissing = null;
|
||||
int nEntriesMissing = 0;
|
||||
IPathEntry[] entries = new IPathEntry[elements.size()];
|
||||
|
||||
for (int i = elements.size() - 1; i >= 0; i--) {
|
||||
CPElement currElement = (CPElement) elements.get(i);
|
||||
boolean isChecked = fCPathList.isChecked(currElement);
|
||||
if (currElement.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
||||
if (isChecked) {
|
||||
fCPathList.setCheckedWithoutUpdate(currElement, false);
|
||||
}
|
||||
} else {
|
||||
currElement.setExported(isChecked);
|
||||
}
|
||||
|
||||
entries[i] = currElement.getPathEntry();
|
||||
if (currElement.isMissing()) {
|
||||
nEntriesMissing++;
|
||||
if (entryMissing == null) {
|
||||
entryMissing = currElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nEntriesMissing > 0) {
|
||||
if (nEntriesMissing == 1) {
|
||||
getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPathsBlock.warning.EntryMissing", //$NON-NLS-1$
|
||||
entryMissing.getPath().toString()));
|
||||
} else {
|
||||
getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPathsBlock.warning.EntriesMissing", //$NON-NLS-1$
|
||||
String.valueOf(nEntriesMissing)));
|
||||
}
|
||||
}
|
||||
|
||||
updateBuildPathStatus();
|
||||
}
|
||||
|
||||
protected void initialize(ICElement element, List cPaths) {
|
||||
fCPaths = cPaths;
|
||||
|
||||
List exportedEntries = new ArrayList();
|
||||
for (int i = 0; i < fCPaths.size(); i++) {
|
||||
CPElement curr = (CPElement) fCPaths.get(i);
|
||||
if (curr.isExported()) {
|
||||
exportedEntries.add(curr);
|
||||
}
|
||||
}
|
||||
|
||||
fCPathList.setElements(cPaths);
|
||||
fCPathList.setCheckedElements(exportedEntries);
|
||||
|
||||
if (fIncludeSymbols != null) {
|
||||
fIncludeSymbols.init(getCProject());
|
||||
}
|
||||
doStatusLineUpdate();
|
||||
initializeTimeStamps();
|
||||
}
|
||||
}
|
|
@ -16,9 +16,9 @@ import org.eclipse.swt.graphics.Image;
|
|||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
public class ProjectContainerDescriptor implements IContainerDescriptor {
|
||||
private int fFilterType;
|
||||
private int[] fFilterType;
|
||||
|
||||
public ProjectContainerDescriptor(int filterType) {
|
||||
public ProjectContainerDescriptor(int[] filterType) {
|
||||
fFilterType = filterType;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
/***********************************************************************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This program and the accompanying materials are made
|
||||
* available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
**********************************************************************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -37,11 +36,11 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
|
|||
|
||||
public class ProjectContainerPage extends WizardPage implements ICPathContainerPage {
|
||||
|
||||
private int fFilterType;
|
||||
private int[] fFilterType;
|
||||
private TableViewer viewer;
|
||||
private ICProject fCProject;
|
||||
|
||||
protected ProjectContainerPage(int filterType) {
|
||||
protected ProjectContainerPage(int[] filterType) {
|
||||
super("projectContainerPage"); //$NON-NLS-1$
|
||||
setTitle(CPathEntryMessages.getString("ProjectContainerPage.title")); //$NON-NLS-1$
|
||||
setDescription(CPathEntryMessages.getString("ProjectContainerPage.description")); //$NON-NLS-1$
|
||||
|
@ -121,13 +120,15 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
|
|||
if (!cProjects[i].equals(fCProject) && !current.contains(CoreModel.newProjectEntry(cProjects[i].getPath()))) {
|
||||
IPathEntry[] projEntries = cProjects[i].getRawPathEntries();
|
||||
for (int j = 0; j < projEntries.length; j++) {
|
||||
if (projEntries[j].getEntryKind() == fFilterType && projEntries[j].isExported()) {
|
||||
for (int k = 0; k < fFilterType.length; k++) {
|
||||
if (projEntries[j].getEntryKind() == fFilterType[k] && projEntries[j].isExported()) {
|
||||
list.add(cProjects[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
viewer.setInput(list);
|
||||
|
|
|
@ -64,9 +64,8 @@ import org.eclipse.ui.model.WorkbenchContentProvider;
|
|||
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
||||
|
||||
/**
|
||||
* UI to set the source attachment archive and root.
|
||||
* Same implementation for both setting attachments for libraries from
|
||||
* variable entries and for normal (internal or external) jar.
|
||||
* UI to set the source attachment archive and root. Same implementation for both setting attachments for libraries from variable
|
||||
* entries and for normal (internal or external) jar.
|
||||
*
|
||||
* SourceAttachmentBlock
|
||||
*/
|
||||
|
@ -96,13 +95,16 @@ public class SourceAttachmentBlock {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param context listeners for status updates
|
||||
* @param entry The entry to edit
|
||||
* @param containerPath Path of the container that contains the given entry or
|
||||
* <code>null</code> if the entry does not belong to a container.
|
||||
* @param project Project to which the entry belongs. Can be
|
||||
* <code>null</code> if <code>getRunnable</code> is not run and the entry
|
||||
* does not belong to a container.
|
||||
* @param context
|
||||
* listeners for status updates
|
||||
* @param entry
|
||||
* The entry to edit
|
||||
* @param containerPath
|
||||
* Path of the container that contains the given entry or <code>null</code> if the entry does not belong to a
|
||||
* container.
|
||||
* @param project
|
||||
* Project to which the entry belongs. Can be <code>null</code> if <code>getRunnable</code> is not run and the
|
||||
* entry does not belong to a container.
|
||||
*
|
||||
*/
|
||||
public SourceAttachmentBlock(IStatusChangeListener context, ILibraryEntry entry, ICProject project) {
|
||||
|
@ -154,8 +156,7 @@ public class SourceAttachmentBlock {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the source attachment root chosen by the user
|
||||
* Returns null to let JCore automatically detect the root.
|
||||
* Gets the source attachment root chosen by the user Returns null to let JCore automatically detect the root.
|
||||
*/
|
||||
public IPath getSourceAttachmentRootPath() {
|
||||
return null;
|
||||
|
@ -163,6 +164,7 @@ public class SourceAttachmentBlock {
|
|||
|
||||
/**
|
||||
* Null for now
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IPath getSourceAttachmentPrefixMapping() {
|
||||
|
@ -192,7 +194,8 @@ public class SourceAttachmentBlock {
|
|||
|
||||
Label message = new Label(composite, SWT.LEFT);
|
||||
message.setLayoutData(gd);
|
||||
message.setText(CPathEntryMessages.getFormattedString("SourceAttachmentBlock.message", fEntry.getLibraryPath().lastSegment())); //$NON-NLS-1$
|
||||
message.setText(CPathEntryMessages.getFormattedString(
|
||||
"SourceAttachmentBlock.message", fEntry.getLibraryPath().lastSegment())); //$NON-NLS-1$
|
||||
|
||||
fWorkspaceButton.doFillIntoGrid(composite, 1);
|
||||
|
||||
|
@ -214,7 +217,6 @@ public class SourceAttachmentBlock {
|
|||
return composite;
|
||||
}
|
||||
|
||||
|
||||
private class SourceAttachmentAdapter implements IStringButtonAdapter, IDialogFieldListener {
|
||||
|
||||
// -------- IStringButtonAdapter --------
|
||||
|
@ -279,9 +281,8 @@ public class SourceAttachmentBlock {
|
|||
if (resolvedPath != null) {
|
||||
if (osPath) {
|
||||
return resolvedPath.toOSString();
|
||||
} else {
|
||||
return resolvedPath.toString();
|
||||
}
|
||||
return resolvedPath.toString();
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
@ -300,7 +301,7 @@ public class SourceAttachmentBlock {
|
|||
if (fileName.length() == 0) {
|
||||
// no source attachment
|
||||
return status;
|
||||
} else {
|
||||
}
|
||||
if (!Path.EMPTY.isValidPath(fileName)) {
|
||||
status.setError(CPathEntryMessages.getString("SourceAttachmentBlock.filename.error.notvalid")); //$NON-NLS-1$
|
||||
return status;
|
||||
|
@ -312,11 +313,11 @@ public class SourceAttachmentBlock {
|
|||
file = res.getLocation().toFile();
|
||||
}
|
||||
if (!file.exists()) {
|
||||
String message= CPathEntryMessages.getFormattedString("SourceAttachmentBlock.filename.error.filenotexists", filePath.toString()); //$NON-NLS-1$
|
||||
String message = CPathEntryMessages.getFormattedString(
|
||||
"SourceAttachmentBlock.filename.error.filenotexists", filePath.toString()); //$NON-NLS-1$
|
||||
status.setError(message);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -363,7 +364,6 @@ public class SourceAttachmentBlock {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Opens a dialog to choose an internal jar.
|
||||
*/
|
||||
|
@ -417,11 +417,11 @@ public class SourceAttachmentBlock {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a runnable that sets the source attachment by modifying the
|
||||
* project's classpath or updating a container.
|
||||
* Creates a runnable that sets the source attachment by modifying the project's classpath or updating a container.
|
||||
*/
|
||||
public IRunnableWithProgress getRunnable(final Shell shell) {
|
||||
return new IRunnableWithProgress() {
|
||||
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException {
|
||||
try {
|
||||
attachSource(shell, monitor);
|
||||
|
@ -440,7 +440,8 @@ public class SourceAttachmentBlock {
|
|||
updateProjectPathEntry(shell, fProject, newEntry, monitor);
|
||||
}
|
||||
|
||||
private void updateProjectPathEntry(Shell shell, ICProject cproject, ILibraryEntry newEntry, IProgressMonitor monitor) throws CModelException {
|
||||
private void updateProjectPathEntry(Shell shell, ICProject cproject, ILibraryEntry newEntry, IProgressMonitor monitor)
|
||||
throws CModelException {
|
||||
IPathEntry[] oldClasspath = cproject.getRawPathEntries();
|
||||
int nEntries = oldClasspath.length;
|
||||
ArrayList newEntries = new ArrayList(nEntries + 1);
|
||||
|
@ -471,6 +472,7 @@ public class SourceAttachmentBlock {
|
|||
private boolean putJarOnClasspathDialog(Shell shell) {
|
||||
final boolean[] result = new boolean[1];
|
||||
shell.getDisplay().syncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
String title = CPathEntryMessages.getString("SourceAttachmentBlock.putoncpdialog.title"); //$NON-NLS-1$
|
||||
String message = CPathEntryMessages.getString("SourceAttachmentBlock.putoncpdialog.message"); //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue