diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
index 8402315291e..0720998e200 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
@@ -1,8 +1,8 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
+ * 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
@@ -12,6 +12,8 @@ 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.ICElement;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
@@ -22,17 +24,21 @@ import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
-
+import org.eclipse.core.runtime.SubProgressMonitor;
abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock implements ICOptionContainer {
+ private List fFilteredOut = new ArrayList();
private StatusInfo fCPathStatus;
private StatusInfo fBuildPathStatus;
@@ -48,10 +54,10 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
public AbstractPathOptionBlock(IStatusChangeListener context, int pageToShow) {
super(false);
-
+
fContext = context;
fPageIndex = pageToShow;
-
+
fCPathStatus = new StatusInfo();
fBuildPathStatus = new StatusInfo();
@@ -68,24 +74,81 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
public IPathEntry[] getRawCPath() {
List elements = getCPaths();
int nElements = elements.size();
- IPathEntry[] entries = new IPathEntry[elements.size()];
+ List entries = new ArrayList();
for (int i = 0; i < nElements; i++) {
CPListElement currElement = (CPListElement) elements.get(i);
- entries[i] = currElement.getPathEntry();
+ entries.add(currElement.getPathEntry());
}
- return entries;
+ entries.addAll(fFilteredOut);
+ return (IPathEntry[]) entries.toArray(new IPathEntry[entries.size()]);
}
- protected ArrayList getExistingEntries(IPathEntry[] cPathEntries) {
+ /**
+ * Initializes the paths for the given project. Multiple calls to init are
+ * allowed, but all existing settings will be cleared and replace by the
+ * given or default paths.
+ *
+ * @param cproject
+ * The C/C++ project to configure. Does not have to exist.
+ * @param outputLocation
+ * The output location to be set in the page. If null
+ * is passed, jdt default settings are used, or - if the project is
+ * an existing Java project- the output location of the existing
+ * project
+ * @param cpathEntries
+ * The path entries to be set in the page. If null
is
+ * passed, jdt default settings are used, or - if the project is an
+ * existing Java project - the path entries of the existing project
+ */
+ public void init(ICElement element, IPathEntry[] cpathEntries) {
+ setCProject(element.getCProject());
+ boolean projectExists = false;
+ List newCPath = null;
+
+ IProject project = getProject();
+ if (cpathEntries == null) {
+ try {
+ cpathEntries = getCProject().getRawPathEntries();
+ } catch (CModelException e) {
+ }
+ }
+ if (cpathEntries != null) {
+ newCPath = getFilteredEntries(cpathEntries, getFilteredTypes());
+ } else {
+ newCPath = new ArrayList();
+ }
+ initialize(element, newCPath);
+ }
+
+ abstract protected int[] getFilteredTypes();
+
+ abstract protected void initialize(ICElement element, List cPaths);
+
+ protected ArrayList getFilteredEntries(IPathEntry[] cPathEntries, int[] types) {
ArrayList newCPath = new ArrayList();
for (int i = 0; i < cPathEntries.length; i++) {
IPathEntry curr = cPathEntries[i];
- newCPath.add(CPListElement.createFromExisting(curr, fCurrCProject));
+ if (contains(types, curr.getEntryKind())) {
+ newCPath.add(CPListElement.createFromExisting(curr, fCurrCProject));
+ } else {
+ fFilteredOut.add(curr);
+ }
}
return newCPath;
}
-
+
+ // returns true if set contains elem
+ private boolean contains(int[] set, int elem) {
+ if (set == null)
+ return false;
+ for (int i = 0; i < set.length; ++i) {
+ if (set[i] == elem)
+ return true;
+ }
+ return false;
+ }
+
abstract protected List getCPaths();
private String getEncodedSettings() {
@@ -121,11 +184,11 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
protected void setCProject(ICProject project) {
fCurrCProject = project;
}
-
+
protected ICProject getCProject() {
return fCurrCProject;
}
-
+
public IProject getProject() {
return fCurrCProject.getProject();
}
@@ -142,7 +205,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
protected StatusInfo getPathStatus() {
return fCPathStatus;
}
-
+
// -------- tab switching ----------
public void setCurrentPage(ICOptionPage page) {
@@ -175,7 +238,8 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
entries[i] = currElement.getPathEntry();
}
- ICModelStatus status = CModelStatus.VERIFIED_OK; // CoreModelUtil.validateCPathEntries(fCurrCProject, entries);
+ ICModelStatus status = CModelStatus.VERIFIED_OK; // CoreModelUtil.validateCPathEntries(fCurrCProject,
+ // entries);
if (!status.isOK()) {
fBuildPathStatus.setError(status.getMessage());
return;
@@ -201,9 +265,31 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
}
return fCurrPage;
}
-
- abstract protected void internalConfigureCProject(List cPathEntries, IProgressMonitor monitor) throws CoreException, InterruptedException;
-
+
+ protected void internalConfigureCProject(List cPathEntries, IProgressMonitor monitor) throws CoreException,
+ InterruptedException {
+ // 10 monitor steps to go
+
+ monitor.worked(2);
+
+ List cpath = new ArrayList(cPathEntries.size() + fFilteredOut.size());
+
+ // create and set the paths
+ for (int i = 0; i < cPathEntries.size(); i++) {
+ CPListElement entry = ((CPListElement) cPathEntries.get(i));
+ IResource res = entry.getResource();
+ if ((res instanceof IFolder) && !res.exists()) {
+ createFolder((IFolder) res, true, true, null);
+ }
+ cpath.add(entry.getPathEntry());
+ }
+ cpath.addAll(fFilteredOut);
+
+ monitor.worked(1);
+
+ getCProject().setRawPathEntries((IPathEntry[]) cpath.toArray(new IPathEntry[cpath.size()]), new SubProgressMonitor(monitor, 7));
+ }
+
// -------- creation -------------------------------
public void configureCProject(IProgressMonitor monitor) throws CoreException, InterruptedException {
@@ -221,4 +307,18 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
}
}
-}
+ /**
+ * Creates a folder and all parent folders if not existing. Project must
+ * exist. org.eclipse.ui.dialogs.ContainerGenerator
is too
+ * heavy (creates a runnable)
+ */
+ private void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
+ if (!folder.exists()) {
+ IContainer parent = folder.getParent();
+ if (parent instanceof IFolder) {
+ createFolder((IFolder) parent, force, local, null);
+ }
+ folder.create(force, local, monitor);
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java
index 13218e6ca00..272949a8858 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java
@@ -31,7 +31,8 @@ public class CPListElement {
public static final String SOURCEATTACHMENTROOT = "rootpath"; //$NON-NLS-1$
public static final String EXCLUSION = "exclusion"; //$NON-NLS-1$
public static final String INCLUDE = "includepath"; //$NON-NLS-1$
- public static final String DEFINE = "define"; //$NON-NLS-1$
+ public static final String MACRO_NAME = "macroname"; //$NON-NLS-1$
+ public static final String MACRO_VALUE = "macrovalue"; //$NON-NLS-1$
private ICProject fProject;
@@ -69,12 +70,14 @@ public class CPListElement {
case IPathEntry.CDT_LIBRARY:
createAttributeElement(SOURCEATTACHMENT, null);
break;
- case IPathEntry.CDT_PROJECT:
case IPathEntry.CDT_INCLUDE:
- createAttributeElement(INCLUDE, null);
+ createAttributeElement(INCLUDE, new Path("")); //$NON-NLS-1$
+ createAttributeElement(EXCLUSION, new Path[0]);
break;
case IPathEntry.CDT_MACRO:
- createAttributeElement(DEFINE, null);
+ createAttributeElement(MACRO_NAME, ""); //$NON-NLS-1$
+ createAttributeElement(MACRO_VALUE, ""); //$NON-NLS-1$
+ createAttributeElement(EXCLUSION, new Path[0]);
break;
case IPathEntry.CDT_CONTAINER:
try {
@@ -122,22 +125,22 @@ public class CPListElement {
return CoreModel.newIncludeEntry(fPath, (IPath) getAttribute(INCLUDE));
case IPathEntry.CDT_MACRO:
exclusionPattern = (IPath[]) getAttribute(EXCLUSION);
- return CoreModel.newMacroEntry(fPath, (String) getAttribute(DEFINE), null);
+ return CoreModel.newMacroEntry(fPath, (String) getAttribute(MACRO_NAME), (String) getAttribute(MACRO_NAME));
default:
return null;
}
}
-
+
public static StringBuffer appendEncodePath(IPath path, StringBuffer buf) {
if (path != null) {
- String str= path.toString();
+ String str = path.toString();
buf.append('[').append(str.length()).append(']').append(str);
} else {
buf.append('[').append(']');
}
return buf;
}
-
+
/**
* @return
*/
@@ -150,18 +153,18 @@ public class CPListElement {
case IPathEntry.CDT_SOURCE:
case IPathEntry.CDT_INCLUDE:
case IPathEntry.CDT_MACRO:
- IPath[] exclusion= (IPath[]) getAttribute(EXCLUSION);
+ IPath[] exclusion = (IPath[]) getAttribute(EXCLUSION);
buf.append('[').append(exclusion.length).append(']');
- for (int i= 0; i < exclusion.length; i++) {
+ for (int i = 0; i < exclusion.length; i++) {
appendEncodePath(exclusion[i], buf).append(';');
}
break;
case IPathEntry.CDT_LIBRARY:
- IPath sourceAttach= (IPath) getAttribute(SOURCEATTACHMENT);
+ IPath sourceAttach = (IPath) getAttribute(SOURCEATTACHMENT);
appendEncodePath(sourceAttach, buf).append(';');
break;
default:
-
+
}
return buf;
}
@@ -228,7 +231,8 @@ public class CPListElement {
}
public Object[] getChildren() {
- if (fEntryKind == IPathEntry.CDT_OUTPUT || fEntryKind == IPathEntry.CDT_SOURCE || fEntryKind == IPathEntry.CDT_INCLUDE || fEntryKind == IPathEntry.CDT_MACRO) {
+ if (fEntryKind == IPathEntry.CDT_OUTPUT || fEntryKind == IPathEntry.CDT_SOURCE || fEntryKind == IPathEntry.CDT_INCLUDE
+ || fEntryKind == IPathEntry.CDT_MACRO) {
return new Object[] { findAttributeElement(EXCLUSION)};
@@ -325,6 +329,10 @@ public class CPListElement {
IWorkspaceRoot root = project.getProject().getWorkspace().getRoot();
IPath sourceAttachment = null;
IPath[] exclusion = null;
+ IPath include = null;
+ String macroName = null;
+ String macroValue = null;
+
// get the resource
IResource res = null;
boolean isMissing = false;
@@ -383,6 +391,7 @@ public class CPListElement {
isMissing = !path.toFile().isFile(); // look for external
}
exclusion = ((IIncludeEntry) curr).getExclusionPatterns();
+ include = ((IIncludeEntry) curr).getIncludePath();
break;
case IPathEntry.CDT_MACRO:
path = path.removeTrailingSeparator();
@@ -394,6 +403,8 @@ public class CPListElement {
isMissing = !path.toFile().isFile(); // look for external
}
exclusion = ((IMacroEntry) curr).getExclusionPatterns();
+ macroName = ((IMacroEntry) curr).getMacroName();
+ macroValue = ((IMacroEntry) curr).getMacroValue();
break;
case IPathEntry.CDT_PROJECT:
res = root.findMember(path);
@@ -403,6 +414,9 @@ public class CPListElement {
CPListElement elem = new CPListElement(project, curr.getEntryKind(), path, res);
elem.setAttribute(SOURCEATTACHMENT, sourceAttachment);
elem.setAttribute(EXCLUSION, exclusion);
+ elem.setAttribute(INCLUDE, include);
+ elem.setAttribute(MACRO_NAME, macroName);
+ elem.setAttribute(MACRO_VALUE, macroValue);
elem.setExported(curr.isExported());
if (project.exists()) {
@@ -410,4 +424,4 @@ public class CPListElement {
}
return elem;
}
-}
+}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListLabelProvider.java
index c188afa9fdd..a4b2c07b6d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListLabelProvider.java
@@ -83,7 +83,7 @@ class CPListLabelProvider extends LabelProvider {
} else {
buf.append(notAvailable);
}
- }
+ }
if (key.equals(CPListElement.EXCLUSION)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.exclusion_filter.label")); //$NON-NLS-1$
IPath[] patterns = (IPath[]) attrib.getValue();
@@ -128,6 +128,11 @@ class CPListLabelProvider extends LabelProvider {
}
case IPathEntry.CDT_PROJECT:
return path.lastSegment();
+ case IPathEntry.CDT_INCLUDE:
+ return ((IPath) cpentry.getAttribute(CPListElement.INCLUDE)).toString();
+ case IPathEntry.CDT_MACRO:
+ return (String) cpentry.getAttribute(CPListElement.MACRO_NAME) + "=" //$NON-NLS-1$
+ + (String) cpentry.getAttribute(CPListElement.MACRO_VALUE);
case IPathEntry.CDT_CONTAINER:
try {
IPathEntryContainer container = CoreModel.getDefault().getPathEntryContainer(cpentry.getPath(),
@@ -163,7 +168,8 @@ class CPListLabelProvider extends LabelProvider {
if (ArchiveFileFilter.isArchivePath(path)) {
IPath appendedPath = path.removeLastSegments(1);
String appended = isExternal ? appendedPath.toOSString() : appendedPath.makeRelative().toString();
- return CPathEntryMessages.getFormattedString("CPListLabelProvider.twopart", new String[] { path.lastSegment(), appended}); //$NON-NLS-1$
+ return CPathEntryMessages.getFormattedString("CPListLabelProvider.twopart", //$NON-NLS-1$
+ new String[] { path.lastSegment(), appended});
} else {
return isExternal ? path.toOSString() : path.makeRelative().toString();
}
@@ -229,16 +235,12 @@ class CPListLabelProvider extends LabelProvider {
} else if (element instanceof CPListElementAttribute) {
String key = ((CPListElementAttribute) element).getKey();
if (key.equals(CPListElement.SOURCEATTACHMENT)) {
-// return fRegistry.get(CPluginImages.DESC_OBJS_SOURCE_ATTACH_ATTRIB);
+ // return
+ // fRegistry.get(CPluginImages.DESC_OBJS_SOURCE_ATTACH_ATTRIB);
} else if (key.equals(CPListElement.EXCLUSION)) {
return CPluginImages.get(CPluginImages.IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
- } else if (key.equals(CPListElement.INCLUDE)) {
-// return fRegistry.get(CPluginImages.DESC_OBJS_INCLUDE_ATTRIB);
- } else if (key.equals(CPListElement.DEFINE)) {
-// return fRegistry.get(CPluginImages.DESC_OBJS_MACRO_ATTRIB);
}
}
return null;
}
-
-}
+}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
index cfa4f099539..f7291f0ef38 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
@@ -8,6 +8,7 @@
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -22,6 +23,7 @@ public abstract class CPathBasePage extends AbstractCOptionPage {
public CPathBasePage(String title) {
super(title);
}
+
public CPathBasePage(String title, ImageDescriptor image) {
super(title, image);
}
@@ -53,10 +55,24 @@ public abstract class CPathBasePage extends AbstractCOptionPage {
}
}
}
+
public abstract List getSelection();
public abstract void setSelection(List selection);
public abstract boolean isEntryKind(int kind);
-}
+ protected List filterList(List input) {
+ ArrayList filtered = new ArrayList();
+
+ List cpelements = input;
+ for (int i = 0; i < cpelements.size(); i++) {
+ CPListElement cpe = (CPListElement) cpelements.get(i);
+ if (isEntryKind(cpe.getEntryKind())) {
+ filtered.add(cpe);
+ }
+ }
+ return filtered;
+ }
+
+}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeEntryPage.java
index 8c68e86be80..1bee01fa9b3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeEntryPage.java
@@ -33,6 +33,7 @@ public class CPathIncludeEntryPage extends CPathBasePage {
private ListDialogField fIncludeList;
private TreeListDialogField fSrcList;
+ private List fCPathList;
private class IncludeListAdapter implements IListAdapter, IDialogFieldListener {
@@ -75,8 +76,9 @@ public class CPathIncludeEntryPage extends CPathBasePage {
fIncludeList.setButtonsMinWidth(buttonBarWidth);
}
- public void init(ICProject project) {
+ public void init(ICProject project, List cPaths) {
fSrcList.setElements(project.getChildrenOfType(ICElement.C_CCONTAINER));
+ fIncludeList.setElements(filterList(cPaths));
}
public List getSelection() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
index 8b398798067..bd882f2bf45 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
@@ -104,15 +104,8 @@ public class CPathOutputEntryPage extends CPathBasePage {
}
private void updateFoldersList() {
- ArrayList folders = new ArrayList();
-
- List cpelements = fCPathList.getElements();
- for (int i = 0; i < cpelements.size(); i++) {
- CPListElement cpe = (CPListElement) cpelements.get(i);
- if (cpe.getEntryKind() == IPathEntry.CDT_OUTPUT) {
- folders.add(cpe);
- }
- }
+
+ List folders = filterList(fCPathList.getElements());
fOutputList.setElements(folders);
for (int i = 0; i < folders.size(); i++) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
index f00576ab663..e40ea6eb947 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
@@ -104,15 +104,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
}
private void updateFoldersList() {
- ArrayList folders = new ArrayList();
-
- List cpelements = fCPathList.getElements();
- for (int i = 0; i < cpelements.size(); i++) {
- CPListElement cpe = (CPListElement) cpelements.get(i);
- if (cpe.getEntryKind() == IPathEntry.CDT_SOURCE) {
- folders.add(cpe);
- }
- }
+ List folders = filterList(fCPathList.getElements());
fFoldersList.setElements(folders);
for (int i = 0; i < folders.size(); i++) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSymbolEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSymbolEntryPage.java
index b5f375a9186..a62606bb242 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSymbolEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSymbolEntryPage.java
@@ -72,7 +72,6 @@ public class CPathSymbolEntryPage extends CPathBasePage {
int buttonBarWidth = converter.convertWidthInCharsToPixels(30);
fSymbolsList.setButtonsMinWidth(buttonBarWidth);
-
}
public List getSelection() {
@@ -93,7 +92,8 @@ public class CPathSymbolEntryPage extends CPathBasePage {
public void performDefaults() {
}
- public void init(ICProject project) {
+ public void init(ICProject project, List list) {
fSrcList.setElements(project.getChildrenOfType(ICElement.C_CCONTAINER));
+ fSymbolsList.setElements(filterList(list));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java
index baf66850105..4ea69577a14 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java
@@ -11,26 +11,20 @@ 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.ICProject;
+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.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
public class CPathTabBlock extends AbstractPathOptionBlock {
+ private int[] pathTypes = { IPathEntry.CDT_SOURCE, IPathEntry.CDT_PROJECT, IPathEntry.CDT_OUTPUT, IPathEntry.CDT_LIBRARY,
+ IPathEntry.CDT_CONTAINER};
private CheckedListDialogField fCPathList;
private CPathSourceEntryPage fSourcePage;
@@ -108,52 +102,18 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
return control;
}
- /**
- * Initializes the classpath for the given project. Multiple calls to init
- * are allowed, but all existing settings will be cleared and replace by the
- * given or default paths.
- *
- * @param jproject
- * The java project to configure. Does not have to exist.
- * @param outputLocation
- * The output location to be set in the page. If null
- * is passed, jdt default settings are used, or - if the project is
- * an existing Java project- the output location of the existing
- * project
- * @param classpathEntries
- * The classpath entries to be set in the page. If null
- * is passed, jdt default settings are used, or - if the project is
- * an existing Java project - the classpath entries of the existing
- * project
- */
- public void init(ICProject cproject, IPathEntry[] cpathEntries) {
- setCProject(cproject);
- boolean projectExists = false;
- List newClassPath = null;
- IProject project = getProject();
- if (cpathEntries == null) {
- try {
- cpathEntries = getCProject().getRawPathEntries();
- } catch (CModelException e) {
- }
- }
- if (cpathEntries != null) {
- newClassPath = getExistingEntries(cpathEntries);
- }
- if (newClassPath == null) {
- newClassPath = getDefaultCPath(cproject);
- }
+ protected void initialize(ICElement element, List cPaths) {
List exportedEntries = new ArrayList();
- for (int i = 0; i < newClassPath.size(); i++) {
- CPListElement curr = (CPListElement) newClassPath.get(i);
+ for (int i = 0; i < cPaths.size(); i++) {
+ CPListElement curr = (CPListElement) cPaths.get(i);
if (curr.isExported() && curr.getEntryKind() != IPathEntry.CDT_SOURCE) {
exportedEntries.add(curr);
}
}
- fCPathList.setElements(newClassPath);
+ fCPathList.setElements(cPaths);
fCPathList.setCheckedElements(exportedEntries);
if (fProjectsPage != null) {
@@ -167,52 +127,11 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
initializeTimeStamps();
}
- private List getDefaultCPath(ICProject cproj) {
- List list = new ArrayList();
- // IResource srcFolder;
- // IPreferenceStore store= PreferenceConstants.getPreferenceStore();
- // String sourceFolderName=
- // store.getString(PreferenceConstants.SRCBIN_SRCNAME);
- // if (store.getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ)
- // && sourceFolderName.length() > 0) {
- // srcFolder= jproj.getProject().getFolder(sourceFolderName);
- // } else {
- // srcFolder= jproj.getProject();
- // }
- //
- // list.add(new CPListElement(jproj, IClasspathEntry.CPE_SOURCE,
- // srcFolder.getFullPath(), srcFolder));
- //
- // IClasspathEntry[] jreEntries=
- // PreferenceConstants.getDefaultJRELibrary();
- // list.addAll(getExistingEntries(jreEntries));
- return list;
+
+ protected int[] getFilteredTypes() {
+ return pathTypes;
}
-
- // -------- evaluate default settings --------
-
- // private List getDefaultClassPath(IJavaProject jproj) {
- // List list= new ArrayList();
- // IResource srcFolder;
- // IPreferenceStore store= PreferenceConstants.getPreferenceStore();
- // String sourceFolderName=
- // store.getString(PreferenceConstants.SRCBIN_SRCNAME);
- // if (store.getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ) &&
- // sourceFolderName.length() > 0) {
- // srcFolder= jproj.getProject().getFolder(sourceFolderName);
- // } else {
- // srcFolder= jproj.getProject();
- // }
- //
- // list.add(new CPListElement(jproj, IClasspathEntry.CPE_SOURCE,
- // srcFolder.getFullPath(), srcFolder));
- //
- // IPathEntry[] jreEntries= PreferenceConstants.getDefaultJRELibrary();
- // list.addAll(getExistingEntries(jreEntries));
- // return list;
- // }
- //
-
+
/**
* Validates the build path.
*/
@@ -262,47 +181,4 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
*/
updateBuildPathStatus();
}
-
-
- /*
- * Creates the Java project and sets the configured build path and output
- * location. If the project already exists only build paths are updated.
- */
- protected void internalConfigureCProject(List cPathEntries, IProgressMonitor monitor) throws CoreException, InterruptedException {
- // 10 monitor steps to go
-
- monitor.worked(2);
-
- int nEntries = cPathEntries.size();
- IPathEntry[] classpath = new IPathEntry[nEntries];
-
- // create and set the class path
- for (int i = 0; i < nEntries; i++) {
- CPListElement entry = ((CPListElement) cPathEntries.get(i));
- IResource res = entry.getResource();
- if ((res instanceof IFolder) && !res.exists()) {
- createFolder((IFolder) res, true, true, null);
- }
- classpath[i] = entry.getPathEntry();
- }
-
- monitor.worked(1);
-
- getCProject().setRawPathEntries(classpath, new SubProgressMonitor(monitor, 7));
- }
-
- /**
- * Creates a folder and all parent folders if not existing. Project must
- * exist. org.eclipse.ui.dialogs.ContainerGenerator
is too
- * heavy (creates a runnable)
- */
- private void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
- if (!folder.exists()) {
- IContainer parent = folder.getParent();
- if (parent instanceof IFolder) {
- createFolder((IFolder) parent, force, local, null);
- }
- folder.create(force, local, monitor);
- }
- }
}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsTabBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsTabBlock.java
index dd2d65367ef..a8368832ba3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsTabBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsTabBlock.java
@@ -12,16 +12,12 @@ 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.ICContainer;
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.ITreeListAdapter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite;
@@ -29,10 +25,14 @@ import org.eclipse.swt.widgets.Control;
public class IncludesSymbolsTabBlock extends AbstractPathOptionBlock {
+ private int[] pathTypes = { IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO};
+
private CPathIncludeEntryPage fIncludePage;
private CPathSymbolEntryPage fSymbolsPage;
private SourceTreeAdapter fSourceTreeAdapter;
+ private List fCPaths;
+
private class SourceTreeAdapter implements ITreeListAdapter {
public void customButtonPressed(TreeListDialogField field, int index) {
@@ -79,46 +79,32 @@ public class IncludesSymbolsTabBlock extends AbstractPathOptionBlock {
fSymbolsPage = new CPathSymbolEntryPage(fSourceTreeAdapter);
addPage(fSymbolsPage);
}
-
+
public Control createContents(Composite parent) {
Control control = super.createContents(parent);
if (getCProject() != null) {
- fIncludePage.init(getCProject());
- fSymbolsPage.init(getCProject());
+ fIncludePage.init(getCProject(), getCPaths());
+ fSymbolsPage.init(getCProject(), getCPaths());
}
Dialog.applyDialogFont(control);
return control;
}
-
+
protected List getCPaths() {
- return new ArrayList();
+ return fCPaths;
}
- public void init(ICElement cElement, IPathEntry[] cpathEntries) {
- setCProject(cElement.getCProject());
- boolean projectExists = false;
- List newClassPath = null;
+ protected int[] getFilteredTypes() {
+ return pathTypes;
+ }
- IProject project = getProject();
- if (cpathEntries == null) {
- try {
- cpathEntries = getCProject().getRawPathEntries();
- } catch (CModelException e) {
- }
- }
- if (cpathEntries != null) {
- newClassPath = getExistingEntries(cpathEntries);
- }
+ protected void initialize(ICElement element, List cPaths) {
+ fCPaths = cPaths;
if (fIncludePage != null) {
- fIncludePage.init(getCProject());
- fSymbolsPage.init(getCProject());
+ fIncludePage.init(getCProject(), getCPaths());
+ fSymbolsPage.init(getCProject(), getCPaths());
}
doStatusLineUpdate();
initializeTimeStamps();
}
-
- protected void internalConfigureCProject(List cPathEntries, IProgressMonitor monitor) throws CoreException,
- InterruptedException {
-
- }
-}
+}
\ No newline at end of file