1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-07 10:33:26 +02:00

fixed problem with applying path entry after switching between include & symbols and project path properies page.

needed to correctly merge and changes made by project path page with entries in include path page
This commit is contained in:
David Inglis 2004-09-08 14:58:12 +00:00
parent a617f1ba4d
commit 0ad9d83903
5 changed files with 78 additions and 71 deletions

View file

@ -37,7 +37,6 @@ 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;
@ -69,17 +68,40 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
* @return Returns the current class path (raw). Note that the entries
* returned must not be valid.
*/
public IPathEntry[] getRawCPath() {
public IPathEntry[] getRawCPath() throws CModelException{
List elements = getCPaths();
int nElements = elements.size();
List entries = new ArrayList();
for (int i = 0; i < nElements; i++) {
CPElement currElement = (CPElement) elements.get(i);
entries.add(currElement.getPathEntry());
IPathEntry[] entries = fCurrCProject.getRawPathEntries();
List cpath = new ArrayList(elements.size() + entries.length);
int[] applyTypes = getAppliedFilteredTypes();
// create and set the paths
for (int i = 0; i < elements.size(); i++) {
CPElement entry = ((CPElement) elements.get(i));
for(int j = 0; j < applyTypes.length; j++) {
if (entry.getEntryKind() == applyTypes[j]) {
cpath.add(entry.getPathEntry());
break;
}
}
}
entries.addAll(fFilteredOut);
return (IPathEntry[]) entries.toArray(new IPathEntry[entries.size()]);
// add entries which do not match type being applyed by the ui block
for(int i = 0; i < entries.length; i++) {
int pathType = entries[i].getEntryKind();
boolean found = false;
for(int j = 0; j < applyTypes.length; j++) {
if (pathType == applyTypes[j]) {
found = true;
break;
}
}
if (!found) {
cpath.add(entries[i]);
}
}
return (IPathEntry[]) cpath.toArray(new IPathEntry[cpath.size()]);
}
/**
@ -117,19 +139,17 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
initialize(element, newCPath);
}
abstract protected int[] getFilteredTypes();
abstract protected int[] getFilteredTypes(); // path type which block would like access to
abstract protected int[] getAppliedFilteredTypes(); // path type which block modifies
abstract protected void initialize(ICElement element, List cPaths);
protected ArrayList getFilteredElements(IPathEntry[] cPathEntries, int[] types) {
ArrayList newCPath = new ArrayList();
fFilteredOut.clear();
for (int i = 0; i < cPathEntries.length; i++) {
IPathEntry curr = cPathEntries[i];
if (contains(types, curr.getEntryKind())) {
newCPath.add(CPElement.createFromExisting(curr, fCurrCProject));
} else {
fFilteredOut.add(curr);
}
}
return newCPath;
@ -267,20 +287,41 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
// 10 monitor steps to go
monitor.worked(2);
IPathEntry[] entries = fCurrCProject.getRawPathEntries();
List cpath = new ArrayList(cPathEntries.size() + entries.length);
List cpath = new ArrayList(cPathEntries.size() + fFilteredOut.size());
int[] applyTypes = getAppliedFilteredTypes();
// create and set the paths
for (int i = 0; i < cPathEntries.size(); i++) {
CPElement entry = ((CPElement) cPathEntries.get(i));
IResource res = entry.getResource();
if ((res instanceof IFolder) && !res.exists()) {
CoreUtility.createFolder((IFolder) res, true, true, null);
for(int j = 0; j < applyTypes.length; j++) {
if (entry.getEntryKind() == applyTypes[j]) {
IResource res = entry.getResource();
if ((res instanceof IFolder) && !res.exists()) {
CoreUtility.createFolder((IFolder) res, true, true, null);
}
cpath.add(entry.getPathEntry());
break;
}
}
cpath.add(entry.getPathEntry());
}
cpath.addAll(fFilteredOut);
// add entries which do not match type being applyed by the ui block
for(int i = 0; i < entries.length; i++) {
int pathType = entries[i].getEntryKind();
boolean found = false;
for(int j = 0; j < applyTypes.length; j++) {
if (pathType == applyTypes[j]) {
found = true;
break;
}
}
if (!found) {
cpath.add(entries[i]);
}
}
monitor.worked(1);
getCProject().setRawPathEntries((IPathEntry[]) cpath.toArray(new IPathEntry[cpath.size()]),

View file

@ -15,8 +15,6 @@ import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.resources.IPathEntryStore;
import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
@ -42,7 +40,7 @@ import org.eclipse.ui.dialogs.PropertyPage;
/**
* @see PropertyPage
*/
public class CPathPropertyPage extends PropertyPage implements IStatusChangeListener, IPathEntryStoreListener {
public class CPathPropertyPage extends PropertyPage implements IStatusChangeListener{
private static final String PAGE_SETTINGS = "CPathsPropertyPage"; //$NON-NLS-1$
private static final String INDEX = "pageIndex"; //$NON-NLS-1$
@ -64,12 +62,6 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
} else if (!project.isOpen()) {
result = createForClosedProject(parent);
} else {
try {
fStore = CoreModel.getPathEntryStore(getProject());
fStore.addPathEntryStoreListener(this);
} catch (CoreException e) {
}
result = createWithCProject(parent, project);
}
Dialog.applyDialogFont(result);
@ -201,16 +193,6 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
return true;
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#dispose()
*/
public void dispose() {
if (fStore != null) {
fStore.removePathEntryStoreListener(this);
}
}
/*
* (non-Javadoc)
*
@ -230,32 +212,6 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
if (fCPathsBlock != null) {
getSettings().put(INDEX, fCPathsBlock.getPageIndex());
}
if (fStore != null) {
fStore.removePathEntryStoreListener(this);
}
return super.performCancel();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent)
*/
public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
if (event.hasContentChanged()) {
Control control = getControl();
if (control != null && !control.isDisposed()) {
control.getDisplay().asyncExec(new Runnable() {
public void run() {
Control control = getControl();
if (control != null && !control.isDisposed()) {
fCPathsBlock.init(CoreModel.getDefault().create(getProject()), null);
}
}
});
}
}
}
}

View file

@ -22,9 +22,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
public class CPathTabBlock extends AbstractPathOptionBlock {
private final int[] pathTypes = {IPathEntry.CDT_SOURCE, IPathEntry.CDT_PROJECT, IPathEntry.CDT_OUTPUT, IPathEntry.CDT_LIBRARY,IPathEntry.CDT_CONTAINER};
private int[] pathTypes = {IPathEntry.CDT_SOURCE, IPathEntry.CDT_PROJECT, IPathEntry.CDT_OUTPUT, IPathEntry.CDT_LIBRARY,
IPathEntry.CDT_CONTAINER};
private ListDialogField fCPathList;
private CPathSourceEntryPage fSourcePage;
@ -118,6 +118,9 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
return pathTypes;
}
protected int[] getAppliedFilteredTypes() {
return pathTypes;
}
/**
* Validates the build path.
*/

View file

@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.resources.IPathEntryStore;
@ -249,7 +250,11 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
public void run() {
Control control = getControl();
if (control != null && !control.isDisposed()) {
fIncludesSymbolsBlock.init(getCElement(), null);
try {
fIncludesSymbolsBlock.init(getCElement(), fIncludesSymbolsBlock.getRawCPath());
} catch (CModelException e) {
CUIPlugin.getDefault().log(e);
}
}
}
});

View file

@ -23,8 +23,6 @@ import org.eclipse.swt.widgets.Control;
public class NewIncludesSymbolsTabBlock extends AbstractPathOptionBlock implements IStatusChangeListener {
private int[] pathTypes = {IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER};
private CPathIncludeSymbolEntryPage fIncludeSymbols;
private List fCPaths;
@ -68,9 +66,13 @@ public class NewIncludesSymbolsTabBlock extends AbstractPathOptionBlock implemen
}
protected int[] getFilteredTypes() {
return pathTypes;
return new int[] {IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER};
}
protected int[] getAppliedFilteredTypes() {
return new int[] {IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO};
}
protected void initialize(ICElement element, List cPaths) {
fCPaths = cPaths;