1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 16:55:38 +02:00

added include/symbol/lib container to ui of container paths.

removed order/export block for now until we really need it will probably come back in some other form.
This commit is contained in:
David Inglis 2004-05-10 20:29:20 +00:00
parent 185c25cd0e
commit 5785b4bf37
7 changed files with 322 additions and 219 deletions

View file

@ -481,7 +481,7 @@ public class CPElement {
res = root.getFolder(path); res = root.getFolder(path);
} }
} }
if (res.getType() != IResource.PROJECT && project != null) { if (res.getType() != IResource.ROOT && project != null) {
isMissing = !project.isOnSourceRoot(res); isMissing = !project.isOnSourceRoot(res);
} }
exclusion = ((IIncludeEntry) curr).getExclusionPatterns(); exclusion = ((IIncludeEntry) curr).getExclusionPatterns();
@ -498,7 +498,7 @@ public class CPElement {
res = root.getFolder(path); res = root.getFolder(path);
} }
} }
if (res.getType() != IResource.PROJECT && project != null) { if (res.getType() != IResource.ROOT && project != null) {
isMissing = !project.isOnSourceRoot(res); isMissing = !project.isOnSourceRoot(res);
} }
exclusion = ((IMacroEntry) curr).getExclusionPatterns(); exclusion = ((IMacroEntry) curr).getExclusionPatterns();

View file

@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Common Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.util.ArrayList;
import java.util.List;
public class CPElementGroup {
CPElement element;
int kind;
public CPElementGroup(CPElement element, int kind) {
this.element = element;
this.kind = kind;
}
public CPElement getElement() {
return element;
}
public int getEntryType() {
return kind;
}
public Object[] getChildren() {
Object[] children = element.getChildren();
List rv = new ArrayList();
for (int i = 0; i < children.length; i++) {
if ((children[i] instanceof CPElement) && ((CPElement)children[i]).getEntryKind() == kind) {
rv.add(children[i]);
}
}
return rv.toArray();
}
}

View file

@ -34,8 +34,8 @@ class CPElementLabelProvider extends LabelProvider {
private ImageDescriptorRegistry fRegistry; private ImageDescriptorRegistry fRegistry;
public CPElementLabelProvider() { public CPElementLabelProvider() {
fNewLabel = CPathEntryMessages.getString("CPListLabelProvider.new"); //$NON-NLS-1$ fNewLabel = CPathEntryMessages.getString("CPElementLabelProvider.new"); //$NON-NLS-1$
fCreateLabel = CPathEntryMessages.getString("CPListLabelProvider.willbecreated"); //$NON-NLS-1$ fCreateLabel = CPathEntryMessages.getString("CPElementLabelProvider.willbecreated"); //$NON-NLS-1$
fRegistry = CUIPlugin.getImageDescriptorRegistry(); fRegistry = CUIPlugin.getImageDescriptorRegistry();
fLibIcon = CPluginImages.DESC_OBJS_ARCHIVE; fLibIcon = CPluginImages.DESC_OBJS_ARCHIVE;
@ -58,16 +58,30 @@ class CPElementLabelProvider extends LabelProvider {
return getCPElementAttributeText((CPElementAttribute)element); return getCPElementAttributeText((CPElementAttribute)element);
} else if (element instanceof IPathEntry) { } else if (element instanceof IPathEntry) {
return getCPElementText(CPElement.createFromExisting((IPathEntry)element, null)); return getCPElementText(CPElement.createFromExisting((IPathEntry)element, null));
} else if (element instanceof CPElementGroup) {
return (getCPContainerGroupText((CPElementGroup)element));
} }
return super.getText(element); return super.getText(element);
} }
private String getCPContainerGroupText(CPElementGroup group) {
switch (group.getEntryType()) {
case IPathEntry.CDT_INCLUDE :
return CPathEntryMessages.getString("CPElementLabelProvider.Includes"); //$NON-NLS-1$
case IPathEntry.CDT_MACRO :
return CPathEntryMessages.getString("CPElementLabelProvider.PreprocessorSymbols"); //$NON-NLS-1$
case IPathEntry.CDT_LIBRARY :
return CPathEntryMessages.getString("CPElementLabelProvider.Libraries"); //$NON-NLS-1$
}
return ""; //$NON-NLS-1$
}
public String getCPElementAttributeText(CPElementAttribute attrib) { public String getCPElementAttributeText(CPElementAttribute attrib) {
String notAvailable = CPathEntryMessages.getString("CPListLabelProvider.none"); //$NON-NLS-1$ String notAvailable = CPathEntryMessages.getString("CPElementLabelProvider.none"); //$NON-NLS-1$
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
String key = attrib.getKey(); String key = attrib.getKey();
if (key.equals(CPElement.SOURCEATTACHMENT)) { if (key.equals(CPElement.SOURCEATTACHMENT)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.source_attachment.label")); //$NON-NLS-1$ buf.append(CPathEntryMessages.getString("CPElementLabelProvider.source_attachment.label")); //$NON-NLS-1$
IPath path = (IPath)attrib.getValue(); IPath path = (IPath)attrib.getValue();
if (path != null && !path.isEmpty()) { if (path != null && !path.isEmpty()) {
buf.append(getPathString(path, path.getDevice() != null)); buf.append(getPathString(path, path.getDevice() != null));
@ -75,7 +89,7 @@ class CPElementLabelProvider extends LabelProvider {
buf.append(notAvailable); buf.append(notAvailable);
} }
} else if (key.equals(CPElement.SOURCEATTACHMENTROOT)) { } else if (key.equals(CPElement.SOURCEATTACHMENTROOT)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.source_attachment_root.label")); //$NON-NLS-1$ buf.append(CPathEntryMessages.getString("CPElementLabelProvider.source_attachment_root.label")); //$NON-NLS-1$
IPath path = (IPath)attrib.getValue(); IPath path = (IPath)attrib.getValue();
if (path != null && !path.isEmpty()) { if (path != null && !path.isEmpty()) {
buf.append(path.toString()); buf.append(path.toString());
@ -84,12 +98,12 @@ class CPElementLabelProvider extends LabelProvider {
} }
} }
if (key.equals(CPElement.EXCLUSION)) { if (key.equals(CPElement.EXCLUSION)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.exclusion_filter.label")); //$NON-NLS-1$ buf.append(CPathEntryMessages.getString("CPElementLabelProvider.exclusion_filter.label")); //$NON-NLS-1$
IPath[] patterns = (IPath[])attrib.getValue(); IPath[] patterns = (IPath[])attrib.getValue();
if (patterns != null && patterns.length > 0) { if (patterns != null && patterns.length > 0) {
for (int i = 0; i < patterns.length; i++) { for (int i = 0; i < patterns.length; i++) {
if (i > 0) { if (i > 0) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.exclusion_filter_separator")); //$NON-NLS-1$ buf.append(CPathEntryMessages.getString("CPElementLabelProvider.exclusion_filter_separator")); //$NON-NLS-1$
} }
buf.append(patterns[i].toString()); buf.append(patterns[i].toString());
} }
@ -103,45 +117,26 @@ class CPElementLabelProvider extends LabelProvider {
public String getCPElementText(CPElement cpentry) { public String getCPElementText(CPElement cpentry) {
IPath path = cpentry.getPath(); IPath path = cpentry.getPath();
switch (cpentry.getEntryKind()) { switch (cpentry.getEntryKind()) {
case IPathEntry.CDT_LIBRARY : { case IPathEntry.CDT_LIBRARY :
{
StringBuffer str = new StringBuffer( ((IPath)cpentry.getAttribute(CPElement.LIBRARY)).toOSString()); StringBuffer str = new StringBuffer( ((IPath)cpentry.getAttribute(CPElement.LIBRARY)).toOSString());
IPath base = (IPath)cpentry.getAttribute(CPElement.BASE_REF); addBaseString(cpentry, str);
if (!base.isEmpty()) {
str.append(" - ("); //$NON-NLS-1$
str.append(base);
str.append(')');
} else {
path = ((IPath)cpentry.getAttribute(CPElement.BASE)).addTrailingSeparator();
str.insert(0, path.toOSString());
}
return str.toString(); return str.toString();
} }
case IPathEntry.CDT_PROJECT : case IPathEntry.CDT_PROJECT :
return path.lastSegment(); return path.lastSegment();
case IPathEntry.CDT_INCLUDE : case IPathEntry.CDT_INCLUDE :
{ {
StringBuffer str = new StringBuffer( ((IPath)cpentry.getAttribute(CPElement.INCLUDE)).toOSString()); IPath incPath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE));
IPath base = (IPath)cpentry.getAttribute(CPElement.BASE_REF); StringBuffer str = new StringBuffer(incPath.toOSString());
if (!base.isEmpty()) { addBaseString(cpentry, str);
str.append(" - ("); //$NON-NLS-1$
str.append(base);
str.append(')');
} else {
path = ((IPath)cpentry.getAttribute(CPElement.BASE)).addTrailingSeparator();
str.insert(0, path.toOSString());
}
return str.toString(); return str.toString();
} }
case IPathEntry.CDT_MACRO : case IPathEntry.CDT_MACRO :
{ {
StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$ StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
+ (String)cpentry.getAttribute(CPElement.MACRO_VALUE)); + (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
IPath base = (IPath)cpentry.getAttribute(CPElement.BASE_REF); addBaseString(cpentry, str);
if (!base.isEmpty()) {
str.append('(');
str.append(base);
str.append(')');
}
return str.toString(); return str.toString();
} }
case IPathEntry.CDT_CONTAINER : case IPathEntry.CDT_CONTAINER :
@ -171,7 +166,38 @@ class CPElementLabelProvider extends LabelProvider {
default : default :
// pass // pass
} }
return CPathEntryMessages.getString("CPListLabelProvider.unknown_element.label"); //$NON-NLS-1$ return CPathEntryMessages.getString("CPElementLabelProvider.unknown_element.label"); //$NON-NLS-1$
}
private void addBaseString(CPElement cpentry, StringBuffer str) {
IPath baseRef = (IPath)cpentry.getAttribute(CPElement.BASE_REF);
if (!baseRef.isEmpty()) {
str.append(" - ("); //$NON-NLS-1$
if (baseRef.isAbsolute()) {
// str.append("From project ");
str.append(baseRef);
} else {
// str.append("From contribution ");
IPathEntryContainer container;
try {
container = CoreModel.getPathEntryContainer(baseRef, cpentry.getCProject());
if (container != null) {
str.append(container.getDescription());
}
} catch (CModelException e1) {
}
}
str.append(')');
} else {
IPath path = (IPath)cpentry.getAttribute(CPElement.BASE);
if (!path.isEmpty()) {
if (!path.hasTrailingSeparator()) {
path = path.addTrailingSeparator();
}
str.insert(0, path.toOSString());
}
}
} }
private String getPathString(IPath path, boolean isExternal) { private String getPathString(IPath path, boolean isExternal) {
@ -242,6 +268,15 @@ class CPElementLabelProvider extends LabelProvider {
} }
} else if (element instanceof IPathEntry) { } else if (element instanceof IPathEntry) {
return getImage(CPElement.createFromExisting((IPathEntry)element, null)); return getImage(CPElement.createFromExisting((IPathEntry)element, null));
} else if (element instanceof CPElementGroup) {
switch ( ((CPElementGroup)element).getEntryType()) {
case IPathEntry.CDT_INCLUDE :
return fRegistry.get(fIncludeIcon);
case IPathEntry.CDT_MACRO :
return fRegistry.get(fMacroIcon);
case IPathEntry.CDT_LIBRARY :
return fRegistry.get(fLibIcon);
}
} }
return null; return null;
} }

View file

@ -24,12 +24,13 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window; import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
public class CPathContainerEntryPage extends CPathBasePage { public class CPathContainerEntryPage extends CPathBasePage {
private ListDialogField fCPathList; private ListDialogField fCPathList;
@ -42,10 +43,9 @@ public class CPathContainerEntryPage extends CPathBasePage {
private final int IDX_EDIT = 2; private final int IDX_EDIT = 2;
private final int IDX_REMOVE = 3; private final int IDX_REMOVE = 3;
public CPathContainerEntryPage(ListDialogField cPathList) {
public CPathContainerEntryPage(ListDialogField classPathList) {
super(CPathEntryMessages.getString("ContainerEntryPage.title")); //$NON-NLS-1$ super(CPathEntryMessages.getString("ContainerEntryPage.title")); //$NON-NLS-1$
fCPathList= classPathList; fCPathList = cPathList;
String[] buttonLabels = new String[]{ String[] buttonLabels = new String[]{
/* IDX_ADD */CPathEntryMessages.getString("ContainerEntryPage.add.button"), //$NON-NLS-1$ /* IDX_ADD */CPathEntryMessages.getString("ContainerEntryPage.add.button"), //$NON-NLS-1$
@ -72,7 +72,6 @@ public class CPathContainerEntryPage extends CPathBasePage {
updateLibrariesList(); updateLibrariesList();
} }
private void updateLibrariesList() { private void updateLibrariesList() {
List cpelements = fCPathList.getElements(); List cpelements = fCPathList.getElements();
List libelements = new ArrayList(cpelements.size()); List libelements = new ArrayList(cpelements.size());
@ -100,7 +99,16 @@ public class CPathContainerEntryPage extends CPathBasePage {
int buttonBarWidth = converter.convertWidthInCharsToPixels(24); int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
fContainersList.setButtonsMinWidth(buttonBarWidth); fContainersList.setButtonsMinWidth(buttonBarWidth);
fContainersList.getTreeViewer().setSorter(new CPElementSorter()); fContainersList.getTreeViewer().addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if ( element instanceof CPElementGroup) {
return ((CPElementGroup)element).getChildren().length != 0;
}
return true;
}
});
setControl(composite); setControl(composite);
} }
@ -127,20 +135,30 @@ public class CPathContainerEntryPage extends CPathBasePage {
public Object[] getChildren(TreeListDialogField field, Object element) { public Object[] getChildren(TreeListDialogField field, Object element) {
if (element instanceof CPElement) { if (element instanceof CPElement) {
CPElement cpElem = (CPElement)element;
if (cpElem.getEntryKind() == IPathEntry.CDT_CONTAINER) {
return new Object[]{new CPElementGroup(cpElem, IPathEntry.CDT_MACRO),
new CPElementGroup(cpElem, IPathEntry.CDT_INCLUDE), new CPElementGroup(cpElem, IPathEntry.CDT_LIBRARY)};
} else {
return ((CPElement)element).getChildren(); return ((CPElement)element).getChildren();
} }
} else if (element instanceof CPElementGroup) {
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 CPElementAttribute) { if (element instanceof CPElementAttribute) {
return ((CPElementAttribute)element).getParent(); return ((CPElementAttribute)element).getParent();
} else if (element instanceof CPElementGroup) {
return ((CPElementGroup)element).getElement();
} }
return null; return null;
} }
public boolean hasChildren(TreeListDialogField field, Object element) { public boolean hasChildren(TreeListDialogField field, Object element) {
return (element instanceof CPElement); return (element instanceof CPElement || element instanceof CPElementGroup);
} }
// ---------- IDialogFieldListener -------- // ---------- IDialogFieldListener --------
@ -153,13 +171,16 @@ public class CPathContainerEntryPage extends CPathBasePage {
private void containerPageCustomButtonPressed(DialogField field, int index) { private void containerPageCustomButtonPressed(DialogField field, int index) {
CPElement[] containers = null; CPElement[] containers = null;
switch (index) { switch (index) {
case IDX_ADD: /* add container */ case IDX_ADD :
/* add container */
containers = openContainerSelectionDialog(null); containers = openContainerSelectionDialog(null);
break; break;
case IDX_EDIT: /* edit */ case IDX_EDIT :
/* edit */
editEntry(); editEntry();
return; return;
case IDX_REMOVE: /* remove */ case IDX_REMOVE :
/* remove */
removeEntry(); removeEntry();
return; return;
} }
@ -269,7 +290,8 @@ public class CPathContainerEntryPage extends CPathBasePage {
// containerPath= ((CPElement) parentContainer).getPath(); // containerPath= ((CPElement) parentContainer).getPath();
// applyChanges= true; // applyChanges= true;
// } // }
// SourceAttachmentDialog dialog= new SourceAttachmentDialog(getShell(), selElement.getPathEntry(), containerPath, fCurrJProject, applyChanges); // SourceAttachmentDialog dialog= new SourceAttachmentDialog(getShell(), selElement.getPathEntry(), containerPath,
// fCurrJProject, applyChanges);
// if (dialog.open() == Window.OK) { // if (dialog.open() == Window.OK) {
// selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath()); // selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath());
// fContainersList.refresh(); // fContainersList.refresh();
@ -376,7 +398,9 @@ public class CPathContainerEntryPage extends CPathBasePage {
return currEntries; return currEntries;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int) * @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
*/ */
public boolean isEntryKind(int kind) { public boolean isEntryKind(int kind) {

View file

@ -50,7 +50,6 @@ ProjectContainerPage.description=Select the C/C++ Project which contains path en
ProjectContainerPage.label=C/C++ Projects: ProjectContainerPage.label=C/C++ Projects:
# -------- ExtendingCPathBasePage --------- # -------- ExtendingCPathBasePage ---------
ExtendingCPathBasePage.editSourcePaths=Edit Source Paths...
ExtendingCPathBasePage.sourcePaths=Source Paths: ExtendingCPathBasePage.sourcePaths=Source Paths:
# -------- SymbolsEntryPage --------- # -------- SymbolsEntryPage ---------
@ -225,14 +224,17 @@ ExclusionPatternEntryDialog.ChooseExclusionPattern.title=Exclusion Pattern Selec
ExclusionPatternEntryDialog.ChooseExclusionPattern.description=&Choose a folder or file to exclude: ExclusionPatternEntryDialog.ChooseExclusionPattern.description=&Choose a folder or file to exclude:
# ------- CPListLabelProvider ------- # ------- CPListLabelProvider -------
CPListLabelProvider.new=(new) CPElementLabelProvider.new=(new)
CPListLabelProvider.willbecreated=(will be created) CPElementLabelProvider.willbecreated=(will be created)
CPListLabelProvider.none=(None) CPElementLabelProvider.none=(None)
CPListLabelProvider.source_attachment.label=Source attachment: CPElementLabelProvider.source_attachment.label=Source attachment:
CPListLabelProvider.source_attachment_root.label=Source attachment root: CPElementLabelProvider.source_attachment_root.label=Source attachment root:
CPListLabelProvider.exclusion_filter.label=Exclusion filter: CPElementLabelProvider.exclusion_filter.label=Exclusion filter:
CPListLabelProvider.exclusion_filter_separator=; CPElementLabelProvider.exclusion_filter_separator=;
CPListLabelProvider.unknown_element.label=unknown element CPElementLabelProvider.unknown_element.label=unknown element
CPElementLabelProvider.Includes=Includes
CPElementLabelProvider.PreprocessorSymbols=Preprocessor Symbols
CPElementLabelProvider.Libraries=Libraries
# ------- NewSourceFolderDialog------- # ------- NewSourceFolderDialog-------
NewSourceFolderDialog.useproject.button=&Project as source folder NewSourceFolderDialog.useproject.button=&Project as source folder

View file

@ -33,7 +33,7 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
private CPathContainerEntryPage fContainerPage; private CPathContainerEntryPage fContainerPage;
private CPathLibraryEntryPage fLibrariesPage; private CPathLibraryEntryPage fLibrariesPage;
private CPathOrderExportPage fOrderExportPage; // private CPathOrderExportPage fOrderExportPage;
private class BuildPathAdapter implements IDialogFieldListener { private class BuildPathAdapter implements IDialogFieldListener {
@ -86,8 +86,8 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
addPage(fLibrariesPage); addPage(fLibrariesPage);
fContainerPage = new CPathContainerEntryPage(fCPathList); fContainerPage = new CPathContainerEntryPage(fCPathList);
addPage(fContainerPage); addPage(fContainerPage);
fOrderExportPage = new CPathOrderExportPage(fCPathList); // fOrderExportPage = new CPathOrderExportPage(fCPathList);
addPage(fOrderExportPage); // addPage(fOrderExportPage);
} }
/* /*

View file

@ -53,7 +53,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
private ListDialogField fPathList; private ListDialogField fPathList;
private TreeListDialogField fSrcList; private TreeListDialogField fSrcList;
private class IncludeListAdapter implements IListAdapter, IDialogFieldListener { private class ListAdapter implements IListAdapter, IDialogFieldListener {
public void dialogFieldChanged(DialogField field) { public void dialogFieldChanged(DialogField field) {
} }
@ -166,7 +166,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
public ExtendedCPathBasePage(ITreeListAdapter adapter, String title, String pathTitle, String[] buttons) { public ExtendedCPathBasePage(ITreeListAdapter adapter, String title, String pathTitle, String[] buttons) {
super(title); super(title);
IncludeListAdapter includeListAdaper = new IncludeListAdapter(); ListAdapter includeListAdaper = new ListAdapter();
fPathList = new ListDialogField(includeListAdaper, buttons, new ModifiedCPListLabelProvider()) { fPathList = new ListDialogField(includeListAdaper, buttons, new ModifiedCPListLabelProvider()) {