mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-21 15:23:59 +02:00
update include/symbol path
- fix updating problems - support edit - removed single tab to use full page area
This commit is contained in:
parent
5a49f2aee5
commit
53738dc5bf
7 changed files with 478 additions and 318 deletions
|
@ -12,11 +12,11 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
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.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatus;
|
import org.eclipse.cdt.core.model.ICModelStatus;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.CModelStatus;
|
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
||||||
|
@ -123,6 +123,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
|
||||||
|
|
||||||
protected ArrayList getFilteredElements(IPathEntry[] cPathEntries, int[] types) {
|
protected ArrayList getFilteredElements(IPathEntry[] cPathEntries, int[] types) {
|
||||||
ArrayList newCPath = new ArrayList();
|
ArrayList newCPath = new ArrayList();
|
||||||
|
fFilteredOut.clear();
|
||||||
for (int i = 0; i < cPathEntries.length; i++) {
|
for (int i = 0; i < cPathEntries.length; i++) {
|
||||||
IPathEntry curr = cPathEntries[i];
|
IPathEntry curr = cPathEntries[i];
|
||||||
if (contains(types, curr.getEntryKind())) {
|
if (contains(types, curr.getEntryKind())) {
|
||||||
|
@ -234,8 +235,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
|
||||||
entries[i] = currElement.getPathEntry();
|
entries[i] = currElement.getPathEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
ICModelStatus status = CModelStatus.VERIFIED_OK; // CoreModelUtil.validateCPathEntries(fCurrCProject,
|
ICModelStatus status = CoreModel.validatePathEntries(fCurrCProject, entries);
|
||||||
// entries);
|
|
||||||
if (!status.isOK()) {
|
if (!status.isOK()) {
|
||||||
fBuildPathStatus.setError(status.getMessage());
|
fBuildPathStatus.setError(status.getMessage());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -108,4 +108,20 @@ public class CPElementGroup {
|
||||||
return (CPElement[])children.toArray(new CPElement[children.size()]);
|
return (CPElement[])children.toArray(new CPElement[children.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param newPath
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean contains(CPElement newPath) {
|
||||||
|
return children.contains(newPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void replaceChild(CPElement element, CPElement replaceWith) {
|
||||||
|
int idx = children.indexOf(element);
|
||||||
|
if (idx != -1) {
|
||||||
|
children.remove(idx);
|
||||||
|
children.add(idx, replaceWith);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -118,16 +118,16 @@ public class CPathContainerWizard extends Wizard {
|
||||||
// add as dummy, will not be shown
|
// add as dummy, will not be shown
|
||||||
fContainerPage = new CPathContainerDefaultPage();
|
fContainerPage = new CPathContainerDefaultPage();
|
||||||
addPage(fContainerPage);
|
addPage(fContainerPage);
|
||||||
|
if (fFilterType != null) {
|
||||||
|
fFilterPage = new CPathFilterPage(fCurrElement, fFilterType);
|
||||||
|
addPage(fFilterPage);
|
||||||
|
}
|
||||||
} else { // fPageDesc == null && fEntryToEdit != null
|
} else { // fPageDesc == null && fEntryToEdit != null
|
||||||
IContainerDescriptor[] containers = CPathContainerDescriptor.getDescriptors();
|
IContainerDescriptor[] containers = CPathContainerDescriptor.getDescriptors();
|
||||||
IContainerDescriptor descriptor = findDescriptorPage(containers, fEntryToEdit);
|
IContainerDescriptor descriptor = findDescriptorPage(containers, fEntryToEdit);
|
||||||
fContainerPage = getContainerPage(descriptor);
|
fContainerPage = getContainerPage(descriptor);
|
||||||
addPage(fContainerPage);
|
addPage(fContainerPage);
|
||||||
}
|
}
|
||||||
if (fFilterType != null) {
|
|
||||||
fFilterPage = new CPathFilterPage(fCurrElement, fFilterType);
|
|
||||||
addPage(fFilterPage);
|
|
||||||
}
|
|
||||||
super.addPages();
|
super.addPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.model.IMacroEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
||||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.TypedElementSelectionValidator;
|
import org.eclipse.cdt.internal.ui.wizards.TypedElementSelectionValidator;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.TypedViewerFilter;
|
import org.eclipse.cdt.internal.ui.wizards.TypedViewerFilter;
|
||||||
|
@ -30,17 +31,19 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
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.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.SelectionButtonDialogField;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
|
||||||
import org.eclipse.cdt.ui.CElementContentProvider;
|
import org.eclipse.cdt.ui.CElementContentProvider;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.jface.dialogs.IInputValidator;
|
import org.eclipse.jface.dialogs.IInputValidator;
|
||||||
import org.eclipse.jface.dialogs.InputDialog;
|
import org.eclipse.jface.dialogs.InputDialog;
|
||||||
import org.eclipse.jface.viewers.StructuredSelection;
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
@ -63,8 +66,8 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
private TreeListDialogField fIncludeSymPathsList;
|
private TreeListDialogField fIncludeSymPathsList;
|
||||||
private SelectionButtonDialogField fShowInheritedPaths;
|
private SelectionButtonDialogField fShowInheritedPaths;
|
||||||
private ICProject fCurrCProject;
|
private ICProject fCurrCProject;
|
||||||
private ListDialogField fCPathList;
|
|
||||||
private CPElementFilter fFilter;
|
private CPElementFilter fFilter;
|
||||||
|
private IStatusChangeListener fContext;
|
||||||
|
|
||||||
private final int IDX_ADD_FOLDER_FILE = 0;
|
private final int IDX_ADD_FOLDER_FILE = 0;
|
||||||
private final int IDX_ADD_SYMBOL = 2;
|
private final int IDX_ADD_SYMBOL = 2;
|
||||||
|
@ -77,7 +80,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
private final int IDX_UP = 14;
|
private final int IDX_UP = 14;
|
||||||
private final int IDX_DOWN = 15;
|
private final int IDX_DOWN = 15;
|
||||||
|
|
||||||
private static final String[] buttonLabel = new String[] {
|
private static final String[] buttonLabel = new String[]{
|
||||||
|
|
||||||
/* 0 */CPathEntryMessages.getString("IncludeSymbolEntryPage.addFolderFile"), //$NON-NLS-1$
|
/* 0 */CPathEntryMessages.getString("IncludeSymbolEntryPage.addFolderFile"), //$NON-NLS-1$
|
||||||
null,
|
null,
|
||||||
|
@ -95,6 +98,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
null,
|
null,
|
||||||
/* 14 */CPathEntryMessages.getString("IncludeSymbolEntryPage.down"), //$NON-NLS-1$
|
/* 14 */CPathEntryMessages.getString("IncludeSymbolEntryPage.down"), //$NON-NLS-1$
|
||||||
/* 15 */CPathEntryMessages.getString("IncludeSymbolEntryPage.up")}; //$NON-NLS-1$
|
/* 15 */CPathEntryMessages.getString("IncludeSymbolEntryPage.up")}; //$NON-NLS-1$
|
||||||
|
private CPElementGroup fProjectGroup;
|
||||||
|
|
||||||
private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter {
|
private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter {
|
||||||
|
|
||||||
|
@ -119,18 +123,18 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
|
|
||||||
public Object[] getChildren(TreeListDialogField field, Object element) {
|
public Object[] getChildren(TreeListDialogField field, Object element) {
|
||||||
if (element instanceof CPElement) {
|
if (element instanceof CPElement) {
|
||||||
return ((CPElement) element).getChildren();
|
return ((CPElement)element).getChildren();
|
||||||
} else if (element instanceof CPElementGroup) {
|
} else if (element instanceof CPElementGroup) {
|
||||||
return ((CPElementGroup) element).getChildren();
|
return ((CPElementGroup)element).getChildren();
|
||||||
}
|
}
|
||||||
return EMPTY_ARR;
|
return EMPTY_ARR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getParent(TreeListDialogField field, Object element) {
|
public Object getParent(TreeListDialogField field, Object element) {
|
||||||
if (element instanceof CPElementGroup) {
|
if (element instanceof CPElementGroup) {
|
||||||
return ((CPElementGroup) element).getParent();
|
return ((CPElementGroup)element).getParent();
|
||||||
} else if (element instanceof CPElement) {
|
} else if (element instanceof CPElement) {
|
||||||
return ((CPElement) element).getParent();
|
return ((CPElement)element).getParent();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +144,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (element instanceof CPElement) {
|
if (element instanceof CPElement) {
|
||||||
return ((CPElement) element).getChildren().length > 0;
|
return ((CPElement)element).getChildren().length > 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -154,9 +158,9 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPathIncludeSymbolEntryPage(ListDialogField cPathList) {
|
public CPathIncludeSymbolEntryPage(IStatusChangeListener context) {
|
||||||
super(CPathEntryMessages.getString("IncludeSymbolEntryPage.title")); //$NON-NLS-1$
|
super(CPathEntryMessages.getString("IncludeSymbolEntryPage.title")); //$NON-NLS-1$
|
||||||
fCPathList = cPathList;
|
fContext = context;
|
||||||
IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
|
IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
|
||||||
fIncludeSymPathsList = new TreeListDialogField(adapter, buttonLabel, new CPElementLabelProvider(true, false)) {
|
fIncludeSymPathsList = new TreeListDialogField(adapter, buttonLabel, new CPElementLabelProvider(true, false)) {
|
||||||
|
|
||||||
|
@ -180,8 +184,8 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
fShowInheritedPaths.setLabelText(CPathEntryMessages.getString("IncludeSymbolsEntryPage.show_inherited.check")); //$NON-NLS-1$
|
fShowInheritedPaths.setLabelText(CPathEntryMessages.getString("IncludeSymbolsEntryPage.show_inherited.check")); //$NON-NLS-1$
|
||||||
fShowInheritedPaths.setDialogFieldListener(adapter);
|
fShowInheritedPaths.setDialogFieldListener(adapter);
|
||||||
|
|
||||||
fFilter = new CPElementFilter(new int[] { -1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER},
|
fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER}, false,
|
||||||
false, true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
|
@ -189,7 +193,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
|
|
||||||
Composite composite = new Composite(parent, SWT.NONE);
|
Composite composite = new Composite(parent, SWT.NONE);
|
||||||
|
|
||||||
LayoutUtil.doDefaultLayout(composite, new DialogField[] { fIncludeSymPathsList, fShowInheritedPaths}, true);
|
LayoutUtil.doDefaultLayout(composite, new DialogField[]{fIncludeSymPathsList, fShowInheritedPaths}, true);
|
||||||
LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null));
|
LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null));
|
||||||
|
|
||||||
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
|
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
|
||||||
|
@ -203,33 +207,60 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
return CPluginImages.get(CPluginImages.IMG_OBJS_INCLUDES_CONTAINER);
|
return CPluginImages.get(CPluginImages.IMG_OBJS_INCLUDES_CONTAINER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(ICProject cproject) {
|
public void init(ICProject cproject, List cPaths) {
|
||||||
fCurrCProject = cproject;
|
fCurrCProject = cproject;
|
||||||
List elements = createGroups();
|
List elements = createGroups(cPaths);
|
||||||
fIncludeSymPathsList.setElements(elements);
|
fIncludeSymPathsList.setElements(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List createGroups() {
|
private void updateStatus() {
|
||||||
List cpelements = fCPathList.getElements();
|
CPElement entryMissing = null;
|
||||||
|
int nEntriesMissing = 0;
|
||||||
|
IStatus status = Status.OK_STATUS;
|
||||||
|
List elements = getCPaths();
|
||||||
|
for (int i = elements.size() - 1; i >= 0; i--) {
|
||||||
|
CPElement currElement = (CPElement)elements.get(i);
|
||||||
|
if (currElement.isMissing()) {
|
||||||
|
nEntriesMissing++;
|
||||||
|
if (entryMissing == null) {
|
||||||
|
entryMissing = currElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nEntriesMissing > 0) {
|
||||||
|
if (nEntriesMissing == 1) {
|
||||||
|
status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getFormattedString(
|
||||||
|
"CPathsBlock.warning.EntryMissing", //$NON-NLS-1$
|
||||||
|
entryMissing.getPath().toString()), null);
|
||||||
|
} else {
|
||||||
|
status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getFormattedString(
|
||||||
|
"CPathsBlock.warning.EntriesMissing", //$NON-NLS-1$
|
||||||
|
String.valueOf(nEntriesMissing)), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fContext.statusChanged(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List createGroups(List cPaths) {
|
||||||
// create resource groups
|
// create resource groups
|
||||||
List resourceGroups = new ArrayList(5);
|
List resourceGroups = new ArrayList(5);
|
||||||
CPElementGroup projectGroup = new CPElementGroup(fCurrCProject.getResource());
|
fProjectGroup = new CPElementGroup(fCurrCProject.getResource());
|
||||||
resourceGroups.add(projectGroup);
|
resourceGroups.add(fProjectGroup);
|
||||||
for (int i = 0; i < cpelements.size(); i++) {
|
for (int i = 0; i < cPaths.size(); i++) {
|
||||||
CPElement element = (CPElement) cpelements.get(i);
|
CPElement element = (CPElement)cPaths.get(i);
|
||||||
switch (element.getEntryKind()) {
|
switch (element.getEntryKind()) {
|
||||||
case IPathEntry.CDT_CONTAINER:
|
case IPathEntry.CDT_CONTAINER :
|
||||||
projectGroup.addChild(element);
|
fProjectGroup.addChild(element);
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_INCLUDE:
|
case IPathEntry.CDT_INCLUDE :
|
||||||
case IPathEntry.CDT_MACRO:
|
case IPathEntry.CDT_MACRO :
|
||||||
CPElementGroup resGroup = new CPElementGroup(element.getResource());
|
CPElementGroup resGroup = new CPElementGroup(element.getResource());
|
||||||
int ndx = resourceGroups.indexOf(resGroup);
|
int ndx = resourceGroups.indexOf(resGroup);
|
||||||
if (ndx == -1) {
|
if (ndx == -1) {
|
||||||
resourceGroups.add(resGroup);
|
resourceGroups.add(resGroup);
|
||||||
} else {
|
} else {
|
||||||
resGroup = (CPElementGroup) resourceGroups.get(ndx);
|
resGroup = (CPElementGroup)resourceGroups.get(ndx);
|
||||||
}
|
}
|
||||||
resGroup.addChild(element);
|
resGroup.addChild(element);
|
||||||
}
|
}
|
||||||
|
@ -237,11 +268,11 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
|
|
||||||
// place each path in its appropriate inherited group (or not if
|
// place each path in its appropriate inherited group (or not if
|
||||||
// excluded)
|
// excluded)
|
||||||
for (int i = 0; i < cpelements.size(); i++) {
|
for (int i = 0; i < cPaths.size(); i++) {
|
||||||
CPElement element = (CPElement) cpelements.get(i);
|
CPElement element = (CPElement)cPaths.get(i);
|
||||||
switch (element.getEntryKind()) {
|
switch (element.getEntryKind()) {
|
||||||
case IPathEntry.CDT_INCLUDE:
|
case IPathEntry.CDT_INCLUDE :
|
||||||
case IPathEntry.CDT_MACRO:
|
case IPathEntry.CDT_MACRO :
|
||||||
addPathToResourceGroups(element, null, resourceGroups);
|
addPathToResourceGroups(element, null, resourceGroups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,8 +281,8 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
|
|
||||||
private void addPathToResourceGroup(CPElement element, CPElementGroup parent, CPElementGroup group) {
|
private void addPathToResourceGroup(CPElement element, CPElementGroup parent, CPElementGroup group) {
|
||||||
IPath resPath = element.getPath();
|
IPath resPath = element.getPath();
|
||||||
IPath[] exclusions = (IPath[]) element.getAttribute(CPElement.EXCLUSION);
|
IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
|
||||||
if ((group != parent || !group.getResource().equals(element.getResource()))
|
if ( (group != parent || !group.getResource().equals(element.getResource()))
|
||||||
&& resPath.isPrefixOf(group.getPath())
|
&& resPath.isPrefixOf(group.getPath())
|
||||||
&& (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
|
&& (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
|
||||||
group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions))) {
|
group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions))) {
|
||||||
|
@ -264,26 +295,37 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
parent.addChild(element);
|
parent.addChild(element);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < groups.size(); i++) {
|
for (int i = 0; i < groups.size(); i++) {
|
||||||
CPElementGroup group = (CPElementGroup) groups.get(i);
|
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||||
addPathToResourceGroup(element, parent, group);
|
addPathToResourceGroup(element, parent, group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePathOnResourceGroups(CPElement element, List groups) {
|
private void updatePathOnResourceGroups(CPElement element, List groups) {
|
||||||
CPElementGroup parent = element.getParent();
|
CPElementGroup parent = element.getParent();
|
||||||
|
IPath resPath = element.getPath();
|
||||||
|
IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
|
||||||
for (int i = 0; i < groups.size(); i++) {
|
for (int i = 0; i < groups.size(); i++) {
|
||||||
CPElementGroup group = (CPElementGroup) groups.get(i);
|
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||||
if (group != parent) {
|
if (group != parent) {
|
||||||
|
boolean found = false;
|
||||||
CPElement[] elements = group.getChildren();
|
CPElement[] elements = group.getChildren();
|
||||||
for (int j = 0; j < elements.length; j++) {
|
for (int j = 0; j < elements.length; j++) {
|
||||||
if (elements[j].getInherited() == element) {
|
if (elements[j].getInherited() == element) {
|
||||||
|
found = true;
|
||||||
|
if (!CoreModelUtil.isExcludedPath(group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions)) {
|
||||||
|
group.replaceChild(elements[j], new CPElement(element, group.getPath(), group.getResource()));
|
||||||
|
} else {
|
||||||
group.removeChild(elements[j]);
|
group.removeChild(elements[j]);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
addPathToResourceGroup(element, parent, group);
|
addPathToResourceGroup(element, parent, group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private CPElement removePathFromResourceGroups(CPElement element, List groups) {
|
private CPElement removePathFromResourceGroups(CPElement element, List groups) {
|
||||||
CPElement Inherited = element.getInherited();
|
CPElement Inherited = element.getInherited();
|
||||||
|
@ -291,14 +333,16 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
resGroup.removeChild(element);
|
resGroup.removeChild(element);
|
||||||
if (Inherited != null) { // applied exclusion to orig.
|
if (Inherited != null) { // applied exclusion to orig.
|
||||||
IPath exclude = element.getPath().removeFirstSegments(Inherited.getPath().segmentCount());
|
IPath exclude = element.getPath().removeFirstSegments(Inherited.getPath().segmentCount());
|
||||||
IPath[] exclusions = (IPath[]) Inherited.getAttribute(CPElement.EXCLUSION);
|
IPath[] exclusions = (IPath[])Inherited.getAttribute(CPElement.EXCLUSION);
|
||||||
IPath[] newExlusions = new IPath[exclusions.length + 1];
|
IPath[] newExlusions = new IPath[exclusions.length + 1];
|
||||||
System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
|
System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
|
||||||
newExlusions[exclusions.length] = exclude;
|
newExlusions[exclusions.length] = exclude;
|
||||||
Inherited.setAttribute(CPElement.EXCLUSION, newExlusions);
|
Inherited.setAttribute(CPElement.EXCLUSION, newExlusions);
|
||||||
} else { // remove all inherited
|
return null;
|
||||||
|
}
|
||||||
|
// remove all inherited
|
||||||
for (int i = 0; i < groups.size(); i++) {
|
for (int i = 0; i < groups.size(); i++) {
|
||||||
CPElementGroup group = (CPElementGroup) groups.get(i);
|
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||||
CPElement elements[] = group.getChildren();
|
CPElement elements[] = group.getChildren();
|
||||||
for (int j = 0; j < elements.length; j++) {
|
for (int j = 0; j < elements.length; j++) {
|
||||||
if (elements[j].getInherited() == element) {
|
if (elements[j].getInherited() == element) {
|
||||||
|
@ -309,8 +353,6 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
}
|
}
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean canAddPath(List selected) {
|
private boolean canAddPath(List selected) {
|
||||||
CPElementGroup group = getSelectedGroup();
|
CPElementGroup group = getSelectedGroup();
|
||||||
|
@ -326,14 +368,14 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
}
|
}
|
||||||
Object elem = selected.get(0);
|
Object elem = selected.get(0);
|
||||||
if (elem instanceof CPElement) {
|
if (elem instanceof CPElement) {
|
||||||
CPElement element = (CPElement) elem;
|
CPElement element = (CPElement)elem;
|
||||||
if (element.getParentContainer() == null) {
|
if (element.getParentContainer() == null) {
|
||||||
return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
|
return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
|
||||||
}
|
}
|
||||||
} else if (elem instanceof CPElementAttribute) {
|
} else if (elem instanceof CPElementAttribute) {
|
||||||
CPElementAttribute attrib = (CPElementAttribute) elem;
|
CPElementAttribute attrib = (CPElementAttribute)elem;
|
||||||
if (attrib.getKey().equals(CPElement.EXCLUSION)) {
|
if (attrib.getKey().equals(CPElement.EXCLUSION)) {
|
||||||
if (((IPath[]) attrib.getValue()).length > 0) {
|
if ( ((IPath[])attrib.getValue()).length > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,21 +387,19 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
List selected = getSelection();
|
List selected = getSelection();
|
||||||
Object elem = selected.get(0);
|
Object elem = selected.get(0);
|
||||||
if (elem instanceof CPElement) {
|
if (elem instanceof CPElement) {
|
||||||
CPElement removed = removePathFromResourceGroups((CPElement) elem, fIncludeSymPathsList.getElements());
|
if (removePathFromResourceGroups((CPElement)elem, fIncludeSymPathsList.getElements()) == null) {
|
||||||
if (removed != null) {
|
updatePathOnResourceGroups(((CPElement)elem).getInherited(), fIncludeSymPathsList.getElements());
|
||||||
fCPathList.removeElement(removed);
|
|
||||||
}
|
}
|
||||||
fCPathList.dialogFieldChanged(); // validate
|
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
} else if (elem instanceof CPElementAttribute) {
|
} else if (elem instanceof CPElementAttribute) {
|
||||||
CPElementAttribute attrib = (CPElementAttribute) elem;
|
CPElementAttribute attrib = (CPElementAttribute)elem;
|
||||||
String key = attrib.getKey();
|
String key = attrib.getKey();
|
||||||
Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
|
Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
|
||||||
attrib.getParent().setAttribute(key, value);
|
attrib.getParent().setAttribute(key, value);
|
||||||
updatePathOnResourceGroups(attrib.getParent(), fIncludeSymPathsList.getElements());
|
updatePathOnResourceGroups(attrib.getParent(), fIncludeSymPathsList.getElements());
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
}
|
}
|
||||||
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canEdit(List selected) {
|
private boolean canEdit(List selected) {
|
||||||
|
@ -368,9 +408,14 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
}
|
}
|
||||||
Object elem = selected.get(0);
|
Object elem = selected.get(0);
|
||||||
if (elem instanceof CPElement) {
|
if (elem instanceof CPElement) {
|
||||||
CPElement element = (CPElement) selected.get(0);
|
CPElement element = (CPElement)selected.get(0);
|
||||||
if (element.getParentContainer() == null && element.getInherited() == null) {
|
if (element.getParentContainer() == null && element.getInherited() == null) {
|
||||||
return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
|
IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
|
||||||
|
if (path != null && !path.equals(Path.EMPTY)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO
|
||||||
|
|| element.getEntryKind() == IPathEntry.CDT_CONTAINER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (elem instanceof CPElementAttribute) {
|
if (elem instanceof CPElementAttribute) {
|
||||||
|
@ -387,9 +432,39 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
Object element = selElements.get(0);
|
Object element = selElements.get(0);
|
||||||
|
|
||||||
if (element instanceof CPElement) {
|
if (element instanceof CPElement) {
|
||||||
|
editElementEntry((CPElement)element);
|
||||||
} else if (element instanceof CPElementAttribute) {
|
} else if (element instanceof CPElementAttribute) {
|
||||||
editAttributeEntry((CPElementAttribute) element);
|
editAttributeEntry((CPElementAttribute)element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editElementEntry(CPElement element) {
|
||||||
|
IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
|
||||||
|
if (path != null && !path.equals(Path.EMPTY)) {
|
||||||
|
return;
|
||||||
|
} else if (element.getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||||
|
addSymbol(element);
|
||||||
|
} else if (element.getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
||||||
|
path = (IPath)element.getAttribute(CPElement.BASE);
|
||||||
|
if (path != null && !path.equals(Path.EMPTY)) {
|
||||||
|
CPElement[] includes = openWorkspacePathEntryDialog(null);
|
||||||
|
if (includes != null && includes.length > 0) {
|
||||||
|
includes[0].setExported(element.isExported());
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addInclude(element);
|
||||||
|
}
|
||||||
|
} else if (element.getEntryKind() == IPathEntry.CDT_CONTAINER) {
|
||||||
|
CPElement[] res = null;
|
||||||
|
|
||||||
|
res = openContainerSelectionDialog(element);
|
||||||
|
if (res != null && res.length > 0) {
|
||||||
|
CPElement curr = res[0];
|
||||||
|
curr.setExported(element.isExported());
|
||||||
|
fProjectGroup.replaceChild(element, curr);
|
||||||
|
fIncludeSymPathsList.refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,19 +475,30 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
|
ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
|
||||||
if (dialog.open() == Window.OK) {
|
if (dialog.open() == Window.OK) {
|
||||||
selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
|
selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
|
||||||
fCPathList.dialogFieldChanged(); // validate
|
|
||||||
updatePathOnResourceGroups(selElement, fIncludeSymPathsList.getElements());
|
updatePathOnResourceGroups(selElement, fIncludeSymPathsList.getElements());
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
|
updateStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportEntry() {
|
private void exportEntry() {
|
||||||
|
CPElement element = (CPElement)getSelection().get(0);
|
||||||
|
element.setExported(!element.isExported()); // toggle
|
||||||
|
fIncludeSymPathsList.refresh(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canExport(List selectedElements) {
|
private boolean canExport(List selected) {
|
||||||
// dinglis-TODO Auto-generated method stub
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +514,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
boolean rc = false;
|
boolean rc = false;
|
||||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
List selElements = fIncludeSymPathsList.getSelectedElements();
|
||||||
for (Iterator i = selElements.iterator(); i.hasNext();) {
|
for (Iterator i = selElements.iterator(); i.hasNext();) {
|
||||||
CPElement elem = (CPElement) i.next();
|
CPElement elem = (CPElement)i.next();
|
||||||
CPElementGroup parent = elem.getParent();
|
CPElementGroup parent = elem.getParent();
|
||||||
CPElement[] children = parent.getChildren();
|
CPElement[] children = parent.getChildren();
|
||||||
for (int j = 0; j < children.length; ++j) {
|
for (int j = 0; j < children.length; ++j) {
|
||||||
|
@ -461,7 +547,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
List revSelElements = new ArrayList(selElements);
|
List revSelElements = new ArrayList(selElements);
|
||||||
Collections.reverse(revSelElements);
|
Collections.reverse(revSelElements);
|
||||||
for (Iterator i = revSelElements.iterator(); i.hasNext();) {
|
for (Iterator i = revSelElements.iterator(); i.hasNext();) {
|
||||||
CPElement elem = (CPElement) i.next();
|
CPElement elem = (CPElement)i.next();
|
||||||
CPElementGroup parent = elem.getParent();
|
CPElementGroup parent = elem.getParent();
|
||||||
CPElement[] children = parent.getChildren();
|
CPElement[] children = parent.getChildren();
|
||||||
for (int j = children.length - 1; j >= 0; --j) {
|
for (int j = children.length - 1; j >= 0; --j) {
|
||||||
|
@ -491,7 +577,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
if (fFilter != null) {
|
if (fFilter != null) {
|
||||||
fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
|
fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
|
||||||
}
|
}
|
||||||
fFilter = new CPElementFilter(new int[] { -1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER},
|
fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER},
|
||||||
false, showInherited);
|
false, showInherited);
|
||||||
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
|
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
|
@ -506,18 +592,20 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
field.enableButton(IDX_ADD_EXT_INCLUDE, canAddPath(selected));
|
field.enableButton(IDX_ADD_EXT_INCLUDE, canAddPath(selected));
|
||||||
field.enableButton(IDX_ADD_WS_INCLUDE, canAddPath(selected));
|
field.enableButton(IDX_ADD_WS_INCLUDE, canAddPath(selected));
|
||||||
field.enableButton(IDX_ADD_SYMBOL, canAddPath(selected));
|
field.enableButton(IDX_ADD_SYMBOL, canAddPath(selected));
|
||||||
|
field.enableButton(IDX_EXPORT, canExport(selected));
|
||||||
|
field.enableButton(IDX_DOWN, canMoveDown(selected));
|
||||||
|
field.enableButton(IDX_UP, canMoveUp(selected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CPElementGroup getSelectedGroup() {
|
private CPElementGroup getSelectedGroup() {
|
||||||
List selected = fIncludeSymPathsList.getSelectedElements();
|
List selected = fIncludeSymPathsList.getSelectedElements();
|
||||||
if (!selected.isEmpty()) {
|
if (!selected.isEmpty()) {
|
||||||
Object item = selected.get(0);
|
Object item = selected.get(0);
|
||||||
if (item instanceof CPElement) {
|
if (item instanceof CPElement) {
|
||||||
item = ((CPElement) item).getParent();
|
item = ((CPElement)item).getParent();
|
||||||
}
|
}
|
||||||
if (item instanceof CPElementGroup) {
|
if (item instanceof CPElementGroup) {
|
||||||
return (CPElementGroup) item;
|
return (CPElementGroup)item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -525,42 +613,42 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
|
|
||||||
protected void ListCustomButtonPressed(TreeListDialogField field, int index) {
|
protected void ListCustomButtonPressed(TreeListDialogField field, int index) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case IDX_ADD_FOLDER_FILE:
|
case IDX_ADD_FOLDER_FILE :
|
||||||
addNewPathResource();
|
addNewPathResource();
|
||||||
break;
|
break;
|
||||||
case IDX_ADD_SYMBOL:
|
case IDX_ADD_SYMBOL :
|
||||||
addSymbol(null);
|
addSymbol(null);
|
||||||
break;
|
break;
|
||||||
case IDX_ADD_EXT_INCLUDE:
|
case IDX_ADD_EXT_INCLUDE :
|
||||||
addInclude(null);
|
addInclude(null);
|
||||||
break;
|
break;
|
||||||
case IDX_ADD_WS_INCLUDE:
|
case IDX_ADD_WS_INCLUDE :
|
||||||
addFromWorkspace();
|
addFromWorkspace();
|
||||||
break;
|
break;
|
||||||
case IDX_ADD_CONTRIBUTED:
|
case IDX_ADD_CONTRIBUTED :
|
||||||
addContributed();
|
addContributed();
|
||||||
break;
|
break;
|
||||||
case IDX_EDIT:
|
case IDX_EDIT :
|
||||||
if (canEdit(field.getSelectedElements())) {
|
if (canEdit(field.getSelectedElements())) {
|
||||||
editEntry();
|
editEntry();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDX_REMOVE:
|
case IDX_REMOVE :
|
||||||
if (canRemove(field.getSelectedElements())) {
|
if (canRemove(field.getSelectedElements())) {
|
||||||
removeEntry();
|
removeEntry();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDX_DOWN:
|
case IDX_DOWN :
|
||||||
if (canMoveDown(field.getSelectedElements())) {
|
if (canMoveDown(field.getSelectedElements())) {
|
||||||
moveDown();
|
moveDown();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDX_UP:
|
case IDX_UP :
|
||||||
if (canMoveUp(field.getSelectedElements())) {
|
if (canMoveUp(field.getSelectedElements())) {
|
||||||
moveUp();
|
moveUp();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDX_EXPORT:
|
case IDX_EXPORT :
|
||||||
if (canExport(field.getSelectedElements())) {
|
if (canExport(field.getSelectedElements())) {
|
||||||
exportEntry();
|
exportEntry();
|
||||||
}
|
}
|
||||||
|
@ -568,51 +656,6 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void ListPageDoubleClicked(TreeListDialogField field) {
|
protected void ListPageDoubleClicked(TreeListDialogField field) {
|
||||||
if (canEdit(fIncludeSymPathsList.getSelectedElements())) {
|
if (canEdit(fIncludeSymPathsList.getSelectedElements())) {
|
||||||
editEntry();
|
editEntry();
|
||||||
|
@ -631,24 +674,86 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IPathEntry[] getRawPathEntries() {
|
protected IPathEntry[] getRawPathEntries() {
|
||||||
IPathEntry[] currEntries = new IPathEntry[fCPathList.getElements().size()];
|
List paths = getCPaths();
|
||||||
|
IPathEntry[] currEntries = new IPathEntry[paths.size()];
|
||||||
for (int i = 0; i < currEntries.length; i++) {
|
for (int i = 0; i < currEntries.length; i++) {
|
||||||
CPElement curr = (CPElement) fCPathList.getElement(i);
|
CPElement curr = (CPElement)paths.get(i);
|
||||||
currEntries[i] = curr.getPathEntry();
|
currEntries[i] = curr.getPathEntry();
|
||||||
}
|
}
|
||||||
return currEntries;
|
return currEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 groups = fIncludeSymPathsList.getElements();
|
||||||
|
for (int i = 0; i < groups.size(); i++) {
|
||||||
|
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||||
|
if (group.getPath().isPrefixOf(newGroup.getPath())) {
|
||||||
|
CPElement[] cpelements = group.getChildren();
|
||||||
|
for (int j = 0; j < cpelements.length; j++) {
|
||||||
|
if (cpelements[j].getInherited() == null) {
|
||||||
|
switch (cpelements[j].getEntryKind()) {
|
||||||
|
case IPathEntry.CDT_INCLUDE :
|
||||||
|
case IPathEntry.CDT_MACRO :
|
||||||
|
addPathToResourceGroup(cpelements[j], null, newGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fIncludeSymPathsList.addElement(newGroup);
|
||||||
|
}
|
||||||
|
fIncludeSymPathsList.selectElements(new StructuredSelection(newGroup));
|
||||||
|
fIncludeSymPathsList.expandElement(newGroup, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void addSymbol(CPElement existing) {
|
protected void addSymbol(CPElement existing) {
|
||||||
// Popup an entry dialog
|
// Popup an entry dialog
|
||||||
InputDialog dialog = new InputDialog(getShell(), CPathEntryMessages.getString("IncludeSymbolEntryPage.addSymbol.title"), //$NON-NLS-1$
|
InputDialog dialog;
|
||||||
|
if (existing == null) {
|
||||||
|
dialog = new InputDialog(getShell(), CPathEntryMessages.getString("IncludeSymbolEntryPage.addSymbol.title"), //$NON-NLS-1$
|
||||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addSymbol.message"), "", //$NON-NLS-1$ //$NON-NLS-2$
|
CPathEntryMessages.getString("IncludeSymbolEntryPage.addSymbol.message"), "", //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
null);
|
null);
|
||||||
|
} else {
|
||||||
|
StringBuffer initialValue = new StringBuffer();
|
||||||
|
initialValue.append((String)existing.getAttribute(CPElement.MACRO_NAME));
|
||||||
|
initialValue.append('=');
|
||||||
|
initialValue.append((String)existing.getAttribute(CPElement.MACRO_VALUE));
|
||||||
|
dialog = new InputDialog(getShell(), CPathEntryMessages.getString("IncludeSymbolEntryPage.editSymbol.title"), //$NON-NLS-1$
|
||||||
|
CPathEntryMessages.getString("IncludeSymbolEntryPage.editSymbol.message"), initialValue.toString(), //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
String symbol = null;
|
String symbol = null;
|
||||||
if (dialog.open() == Window.OK) {
|
if (dialog.open() == Window.OK) {
|
||||||
symbol = dialog.getValue();
|
symbol = dialog.getValue();
|
||||||
if (symbol != null && symbol.length() > 0) {
|
if (symbol != null && symbol.length() > 0) {
|
||||||
List cplist = fCPathList.getElements();
|
|
||||||
CPElementGroup group = getSelectedGroup();
|
CPElementGroup group = getSelectedGroup();
|
||||||
CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
|
CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
|
||||||
group.getResource());
|
group.getResource());
|
||||||
|
@ -660,14 +765,20 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
} else {
|
} else {
|
||||||
name = symbol.trim();
|
name = symbol.trim();
|
||||||
}
|
}
|
||||||
|
if (existing != null) {
|
||||||
|
existing.setAttribute(CPElement.MACRO_NAME, name);
|
||||||
|
existing.setAttribute(CPElement.MACRO_VALUE, value);
|
||||||
|
updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
|
||||||
|
fIncludeSymPathsList.refresh();
|
||||||
|
} else {
|
||||||
newPath.setAttribute(CPElement.MACRO_NAME, name);
|
newPath.setAttribute(CPElement.MACRO_NAME, name);
|
||||||
newPath.setAttribute(CPElement.MACRO_VALUE, value);
|
newPath.setAttribute(CPElement.MACRO_VALUE, value);
|
||||||
|
|
||||||
if (!cplist.contains(newPath)) {
|
if (!group.contains(newPath)) {
|
||||||
fCPathList.addElement(newPath);
|
addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
|
||||||
addPathToResourceGroups(newPath, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
}
|
||||||
|
updateStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -683,59 +794,75 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
dialog = new SelectPathInputDialog(
|
dialog = new SelectPathInputDialog(
|
||||||
getShell(),
|
getShell(),
|
||||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.editExternal.title"), //$NON-NLS-1$
|
CPathEntryMessages.getString("IncludeSymbolEntryPage.editExternal.title"), //$NON-NLS-1$
|
||||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.editExternal.message"), ((IPath) existing.getAttribute(CPElement.INCLUDE)).toOSString(), null); //$NON-NLS-1$
|
CPathEntryMessages.getString("IncludeSymbolEntryPage.editExternal.message"), ((IPath)existing.getAttribute(CPElement.INCLUDE)).toOSString(), null); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
String newItem = null;
|
String newItem = null;
|
||||||
if (dialog.open() == Window.OK) {
|
if (dialog.open() == Window.OK) {
|
||||||
newItem = dialog.getValue();
|
newItem = dialog.getValue();
|
||||||
if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$
|
if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
List cplist = fCPathList.getElements();
|
|
||||||
CPElementGroup group = getSelectedGroup();
|
CPElementGroup group = getSelectedGroup();
|
||||||
CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
||||||
group.getResource());
|
group.getResource());
|
||||||
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
||||||
if (!cplist.contains(newPath)) {
|
if (!group.contains(newPath)) {
|
||||||
fCPathList.addElement(newPath);
|
addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
|
||||||
addPathToResourceGroups(newPath, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
|
||||||
fIncludeSymPathsList.refresh();
|
|
||||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
||||||
fIncludeSymPathsList.refresh();
|
updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
|
||||||
}
|
}
|
||||||
|
fIncludeSymPathsList.refresh();
|
||||||
|
updateStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addFromWorkspace() {
|
protected void addFromWorkspace() {
|
||||||
CPElement[] includes = openWorkspacePathEntryDialog(null);
|
CPElement[] includes = openWorkspacePathEntryDialog(null);
|
||||||
if (includes != null) {
|
if (includes != null && includes.length > 0) {
|
||||||
int nElementsChosen = includes.length;
|
int nElementsChosen = includes.length;
|
||||||
// remove duplicates
|
CPElementGroup group = getSelectedGroup();
|
||||||
List cplist = fCPathList.getElements();
|
|
||||||
for (int i = 0; i < nElementsChosen; i++) {
|
for (int i = 0; i < nElementsChosen; i++) {
|
||||||
CPElement curr = includes[i];
|
CPElement curr = includes[i];
|
||||||
if (!cplist.contains(curr)) {
|
if (!group.contains(curr)) {
|
||||||
fCPathList.addElement(curr);
|
addPathToResourceGroups(curr, group, fIncludeSymPathsList.getElements());
|
||||||
|
fIncludeSymPathsList.refresh();
|
||||||
|
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
||||||
|
updateStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addContributed() {
|
||||||
|
CPElement[] includes = openContainerSelectionDialog(null);
|
||||||
|
if (includes != null && includes.length > 0) {
|
||||||
|
int nElementsChosen = includes.length;
|
||||||
|
// remove duplicates
|
||||||
|
CPElementGroup group = getSelectedGroup();
|
||||||
|
for (int i = 0; i < nElementsChosen; i++) {
|
||||||
|
CPElement curr = includes[i];
|
||||||
|
if (!group.contains(curr)) {
|
||||||
addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
||||||
|
updateStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
|
protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
|
||||||
Class[] acceptedClasses = new Class[] { ICProject.class, IProject.class, IContainer.class, ICContainer.class};
|
Class[] acceptedClasses = new Class[]{ICProject.class, IProject.class, IContainer.class, ICContainer.class};
|
||||||
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
|
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
|
||||||
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
|
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
|
||||||
|
|
||||||
String title = (existing == null) ? CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.new.title") //$NON-NLS-1$
|
String title = (existing == null) ? CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.new.title") //$NON-NLS-1$
|
||||||
: CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.edit.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$
|
String message = (existing == null)
|
||||||
|
? CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.new.description") //$NON-NLS-1$
|
||||||
: CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.edit.description"); //$NON-NLS-1$
|
: CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.edit.description"); //$NON-NLS-1$
|
||||||
|
|
||||||
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
|
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
|
||||||
|
@ -758,11 +885,11 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
IProject project;
|
IProject project;
|
||||||
IPath includePath;
|
IPath includePath;
|
||||||
if (elements[i] instanceof IResource) {
|
if (elements[i] instanceof IResource) {
|
||||||
project = ((IResource) elements[i]).getProject();
|
project = ((IResource)elements[i]).getProject();
|
||||||
includePath = ((IResource) elements[i]).getProjectRelativePath();
|
includePath = ((IResource)elements[i]).getProjectRelativePath();
|
||||||
} else {
|
} else {
|
||||||
project = ((ICElement) elements[i]).getCProject().getProject();
|
project = ((ICElement)elements[i]).getCProject().getProject();
|
||||||
includePath = ((ICElement) elements[i]).getResource().getProjectRelativePath();
|
includePath = ((ICElement)elements[i]).getResource().getProjectRelativePath();
|
||||||
}
|
}
|
||||||
CPElementGroup group = getSelectedGroup();
|
CPElementGroup group = getSelectedGroup();
|
||||||
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
||||||
|
@ -784,7 +911,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
title = CPathEntryMessages.getString("IncludeSymbolEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
|
title = CPathEntryMessages.getString("IncludeSymbolEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
|
||||||
elem = existing.getPathEntry();
|
elem = existing.getPathEntry();
|
||||||
}
|
}
|
||||||
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(), new int[] {
|
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(), new int[]{
|
||||||
IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO});
|
IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO});
|
||||||
wizard.setWindowTitle(title);
|
wizard.setWindowTitle(title);
|
||||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||||
|
@ -798,42 +925,22 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
if (elements[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
if (elements[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
||||||
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
||||||
group.getResource());
|
group.getResource());
|
||||||
res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry) elements[i]).getIncludePath());
|
res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry)elements[i]).getIncludePath());
|
||||||
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
|
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
|
||||||
} else if (elements[i].getEntryKind() == IPathEntry.CDT_MACRO) {
|
} else if (elements[i].getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||||
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
|
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
|
||||||
group.getResource());
|
group.getResource());
|
||||||
res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry) elements[i]).getMacroName());
|
res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry)elements[i]).getMacroName());
|
||||||
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
|
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
return new CPElement[] {CPElement.createFromExisting(parent, fCurrCProject)};
|
||||||
}
|
}
|
||||||
return null;
|
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 {
|
private class SelectPathInputDialog extends InputDialog {
|
||||||
|
|
||||||
public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
|
public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
|
||||||
|
@ -891,4 +998,22 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
|
|
||||||
public void performDefaults() {
|
public void performDefaults() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List getCPaths() {
|
||||||
|
List cPaths = new ArrayList();
|
||||||
|
List groups = fIncludeSymPathsList.getElements();
|
||||||
|
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() == null) {
|
||||||
|
cPaths.add(elements[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cPaths;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -10,10 +10,14 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
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.IStatusChangeListener;
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
|
@ -39,12 +43,13 @@ import org.eclipse.ui.dialogs.PropertyPage;
|
||||||
/**
|
/**
|
||||||
* @see PropertyPage
|
* @see PropertyPage
|
||||||
*/
|
*/
|
||||||
public class CPathPropertyPage extends PropertyPage implements IStatusChangeListener {
|
public class CPathPropertyPage extends PropertyPage implements IStatusChangeListener, IPathEntryStoreListener {
|
||||||
|
|
||||||
private static final String PAGE_SETTINGS = "CPathsPropertyPage"; //$NON-NLS-1$
|
private static final String PAGE_SETTINGS = "CPathsPropertyPage"; //$NON-NLS-1$
|
||||||
private static final String INDEX = "pageIndex"; //$NON-NLS-1$
|
private static final String INDEX = "pageIndex"; //$NON-NLS-1$
|
||||||
|
|
||||||
CPathTabBlock fCPathsBlock;
|
CPathTabBlock fCPathsBlock;
|
||||||
|
IPathEntryStore fStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PropertyPage#createContents
|
* @see PropertyPage#createContents
|
||||||
|
@ -60,6 +65,12 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
|
||||||
} else if (!project.isOpen()) {
|
} else if (!project.isOpen()) {
|
||||||
result = createForClosedProject(parent);
|
result = createForClosedProject(parent);
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
|
fStore = CCorePlugin.getDefault().getPathEntryStore(getProject());
|
||||||
|
fStore.addPathEntryStoreListener(this);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
|
||||||
result = createWithCProject(parent, project);
|
result = createWithCProject(parent, project);
|
||||||
}
|
}
|
||||||
Dialog.applyDialogFont(result);
|
Dialog.applyDialogFont(result);
|
||||||
|
@ -113,21 +124,19 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
|
||||||
if (fCPathsBlock != null) {
|
if (fCPathsBlock != null) {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
if (fCPathsBlock.hasChangesInDialog()) {
|
if (fCPathsBlock.hasChangesInDialog()) {
|
||||||
String title= CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.title"); //$NON-NLS-1$
|
String title = CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.title"); //$NON-NLS-1$
|
||||||
String message= CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.message"); //$NON-NLS-1$
|
String message = CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.message"); //$NON-NLS-1$
|
||||||
String[] buttonLabels= new String[] {
|
String[] buttonLabels = new String[]{
|
||||||
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.save"), //$NON-NLS-1$
|
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.save"), //$NON-NLS-1$
|
||||||
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.discard"), //$NON-NLS-1$
|
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.discard"), //$NON-NLS-1$
|
||||||
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.ignore") //$NON-NLS-1$
|
|
||||||
};
|
};
|
||||||
MessageDialog dialog= new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0);
|
MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
|
||||||
int res= dialog.open();
|
buttonLabels, 0);
|
||||||
|
int res = dialog.open();
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
performOk();
|
performOk();
|
||||||
} else if (res == 1) {
|
} else if (res == 1) {
|
||||||
fCPathsBlock.init(CoreModel.getDefault().create(getProject()), null);
|
fCPathsBlock.init(CoreModel.getDefault().create(getProject()), null);
|
||||||
} else {
|
|
||||||
fCPathsBlock.initializeTimeStamps();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -142,9 +151,9 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
|
||||||
private IProject getProject() {
|
private IProject getProject() {
|
||||||
IAdaptable adaptable = getElement();
|
IAdaptable adaptable = getElement();
|
||||||
if (adaptable != null) {
|
if (adaptable != null) {
|
||||||
ICElement elem = (ICElement) adaptable.getAdapter(ICElement.class);
|
ICElement elem = (ICElement)adaptable.getAdapter(ICElement.class);
|
||||||
if (elem instanceof ICProject) {
|
if (elem instanceof ICProject) {
|
||||||
return ((ICProject) elem).getProject();
|
return ((ICProject)elem).getProject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -190,6 +199,9 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fStore != null) {
|
||||||
|
fStore.removePathEntryStoreListener(this);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +224,29 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
|
||||||
if (fCPathsBlock != null) {
|
if (fCPathsBlock != null) {
|
||||||
getSettings().put(INDEX, fCPathsBlock.getPageIndex());
|
getSettings().put(INDEX, fCPathsBlock.getPageIndex());
|
||||||
}
|
}
|
||||||
|
if (fStore != null) {
|
||||||
|
fStore.removePathEntryStoreListener(this);
|
||||||
|
}
|
||||||
return super.performCancel();
|
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() {
|
||||||
|
fCPathsBlock.init(CoreModel.getDefault().create(getProject()), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -10,13 +10,18 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
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.IStatusChangeListener;
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -34,13 +39,13 @@ import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
|
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
|
||||||
import org.eclipse.ui.dialogs.PropertyPage;
|
import org.eclipse.ui.dialogs.PropertyPage;
|
||||||
|
|
||||||
|
public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatusChangeListener, IPathEntryStoreListener {
|
||||||
public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatusChangeListener {
|
|
||||||
|
|
||||||
private static final String PAGE_SETTINGS = "IncludeSysmbolsPropertyPage"; //$NON-NLS-1$
|
private static final String PAGE_SETTINGS = "IncludeSysmbolsPropertyPage"; //$NON-NLS-1$
|
||||||
private static final String INDEX = "pageIndex"; //$NON-NLS-1$
|
private static final String INDEX = "pageIndex"; //$NON-NLS-1$
|
||||||
|
|
||||||
NewIncludesSymbolsTabBlock fIncludesSymbolsBlock;
|
NewIncludesSymbolsTabBlock fIncludesSymbolsBlock;
|
||||||
|
IPathEntryStore fStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PropertyPage#createContents
|
* @see PropertyPage#createContents
|
||||||
|
@ -53,6 +58,11 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
||||||
} else if (!project.isOpen()) {
|
} else if (!project.isOpen()) {
|
||||||
result = createForClosedProject(parent);
|
result = createForClosedProject(parent);
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
|
fStore = CCorePlugin.getDefault().getPathEntryStore(getProject());
|
||||||
|
fStore.addPathEntryStoreListener(this);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
result = createWithCProject(parent, project);
|
result = createWithCProject(parent, project);
|
||||||
}
|
}
|
||||||
Dialog.applyDialogFont(result);
|
Dialog.applyDialogFont(result);
|
||||||
|
@ -107,21 +117,19 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
||||||
if (fIncludesSymbolsBlock != null) {
|
if (fIncludesSymbolsBlock != null) {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
if (fIncludesSymbolsBlock.hasChangesInDialog()) {
|
if (fIncludesSymbolsBlock.hasChangesInDialog()) {
|
||||||
String title= CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.title"); //$NON-NLS-1$
|
String title = CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.title"); //$NON-NLS-1$
|
||||||
String message= CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.message"); //$NON-NLS-1$
|
String message = CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.message"); //$NON-NLS-1$
|
||||||
String[] buttonLabels= new String[] {
|
String[] buttonLabels = new String[]{
|
||||||
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.save"), //$NON-NLS-1$
|
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.save"), //$NON-NLS-1$
|
||||||
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.discard"), //$NON-NLS-1$
|
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.discard"), //$NON-NLS-1$
|
||||||
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.ignore") //$NON-NLS-1$
|
|
||||||
};
|
};
|
||||||
MessageDialog dialog= new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0);
|
MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
|
||||||
int res= dialog.open();
|
buttonLabels, 0);
|
||||||
|
int res = dialog.open();
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
performOk();
|
performOk();
|
||||||
} else if (res == 1) {
|
} else if (res == 1) {
|
||||||
fIncludesSymbolsBlock.init(getCElement(), null);
|
fIncludesSymbolsBlock.init(getCElement(), null);
|
||||||
} else {
|
|
||||||
fIncludesSymbolsBlock.initializeTimeStamps();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -136,8 +144,8 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
||||||
private IProject getProject() {
|
private IProject getProject() {
|
||||||
IAdaptable adaptable = getElement();
|
IAdaptable adaptable = getElement();
|
||||||
if (adaptable != null) {
|
if (adaptable != null) {
|
||||||
ICElement elem = (ICElement) adaptable.getAdapter(ICElement.class);
|
IResource resource = (IResource)adaptable.getAdapter(IResource.class);
|
||||||
return elem.getCProject().getProject();
|
return resource.getProject();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +153,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
||||||
private ICElement getCElement() {
|
private ICElement getCElement() {
|
||||||
IAdaptable adaptable = getElement();
|
IAdaptable adaptable = getElement();
|
||||||
if (adaptable != null) {
|
if (adaptable != null) {
|
||||||
ICElement elem = (ICElement) adaptable.getAdapter(ICElement.class);
|
ICElement elem = (ICElement)adaptable.getAdapter(ICElement.class);
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -191,6 +199,9 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fStore != null) {
|
||||||
|
fStore.removePathEntryStoreListener(this);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +224,31 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
||||||
if (fIncludesSymbolsBlock != null) {
|
if (fIncludesSymbolsBlock != null) {
|
||||||
getSettings().put(INDEX, fIncludesSymbolsBlock.getPageIndex());
|
getSettings().put(INDEX, fIncludesSymbolsBlock.getPageIndex());
|
||||||
}
|
}
|
||||||
|
if (fStore != null) {
|
||||||
|
fStore.removePathEntryStoreListener(this);
|
||||||
|
}
|
||||||
return super.performCancel();
|
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() {
|
||||||
|
fIncludesSymbolsBlock.init(getCElement(), null);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,149 +8,97 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
|
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
|
||||||
public class NewIncludesSymbolsTabBlock extends AbstractPathOptionBlock {
|
public class NewIncludesSymbolsTabBlock extends AbstractPathOptionBlock implements IStatusChangeListener {
|
||||||
|
|
||||||
private int[] pathTypes = { IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER};
|
private int[] pathTypes = {IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER};
|
||||||
|
|
||||||
private CPathIncludeSymbolEntryPage fIncludeSymbols;
|
private CPathIncludeSymbolEntryPage fIncludeSymbols;
|
||||||
|
|
||||||
private CheckedListDialogField fCPathList;
|
|
||||||
|
|
||||||
private List fCPaths;
|
private List fCPaths;
|
||||||
|
|
||||||
private class BuildPathAdapter implements IDialogFieldListener {
|
private Composite fComposite;
|
||||||
|
|
||||||
// ---------- IDialogFieldListener --------
|
|
||||||
public void dialogFieldChanged(DialogField field) {
|
|
||||||
buildPathDialogFieldChanged(field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildPathDialogFieldChanged(DialogField field) {
|
|
||||||
if (field == fCPathList) {
|
|
||||||
updateCPathStatus();
|
|
||||||
}
|
|
||||||
doStatusLineUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NewIncludesSymbolsTabBlock(IStatusChangeListener context, int pageToShow) {
|
public NewIncludesSymbolsTabBlock(IStatusChangeListener context, int pageToShow) {
|
||||||
super(context, pageToShow);
|
super(context, pageToShow);
|
||||||
|
}
|
||||||
|
|
||||||
String[] buttonLabels = new String[] { /* 0 */CPathEntryMessages.getString("CPathsBlock.path.up.button"), //$NON-NLS-1$
|
protected void addTab(ICOptionPage tab) {
|
||||||
/* 1 */CPathEntryMessages.getString("CPathsBlock.path.down.button"), //$NON-NLS-1$
|
tab.setContainer(this);
|
||||||
/* 2 */null, /* 3 */CPathEntryMessages.getString("CPathsBlock.path.checkall.button"), //$NON-NLS-1$
|
tab.createControl(fComposite);
|
||||||
/* 4 */CPathEntryMessages.getString("CPathsBlock.path.uncheckall.button") //$NON-NLS-1$
|
addOptionPage(tab);
|
||||||
|
|
||||||
};
|
|
||||||
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() {
|
protected void addTabs() {
|
||||||
fIncludeSymbols = new CPathIncludeSymbolEntryPage(fCPathList);
|
|
||||||
addPage(fIncludeSymbols);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Control createContents(Composite parent) {
|
public Control createContents(Composite parent) {
|
||||||
Control control = super.createContents(parent);
|
fComposite = new Composite(parent, SWT.NONE);
|
||||||
|
fComposite.setLayout(new GridLayout(1, false));
|
||||||
|
|
||||||
|
fIncludeSymbols = new CPathIncludeSymbolEntryPage(this);
|
||||||
|
addPage(fIncludeSymbols);
|
||||||
|
setCurrentPage(fIncludeSymbols);
|
||||||
|
initializingTabs = false;
|
||||||
|
|
||||||
if (getCProject() != null) {
|
if (getCProject() != null) {
|
||||||
fIncludeSymbols.init(getCProject());
|
fIncludeSymbols.init(getCProject(), fCPaths);
|
||||||
}
|
}
|
||||||
Dialog.applyDialogFont(control);
|
Dialog.applyDialogFont(fComposite);
|
||||||
return control;
|
return fComposite;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List getCPaths() {
|
protected List getCPaths() {
|
||||||
return fCPathList.getElements();
|
if (fIncludeSymbols != null) {
|
||||||
|
return fIncludeSymbols.getCPaths();
|
||||||
|
}
|
||||||
|
return fCPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int[] getFilteredTypes() {
|
protected int[] getFilteredTypes() {
|
||||||
return pathTypes;
|
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) {
|
protected void initialize(ICElement element, List cPaths) {
|
||||||
fCPaths = 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) {
|
if (fIncludeSymbols != null) {
|
||||||
fIncludeSymbols.init(getCProject());
|
fIncludeSymbols.init(getCProject(), cPaths);
|
||||||
}
|
}
|
||||||
doStatusLineUpdate();
|
doStatusLineUpdate();
|
||||||
initializeTimeStamps();
|
initializeTimeStamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
|
||||||
|
*/
|
||||||
|
public void statusChanged(IStatus status) {
|
||||||
|
switch (status.getSeverity()) {
|
||||||
|
case IStatus.ERROR :
|
||||||
|
getPathStatus().setError(status.getMessage());
|
||||||
|
break;
|
||||||
|
case IStatus.INFO :
|
||||||
|
getPathStatus().setInfo(status.getMessage());
|
||||||
|
break;
|
||||||
|
case IStatus.WARNING :
|
||||||
|
getPathStatus().setWarning(status.getMessage());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
updateBuildPathStatus();
|
||||||
|
doStatusLineUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue