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()); {
IPath base = (IPath)cpentry.getAttribute(CPElement.BASE_REF); StringBuffer str = new StringBuffer( ((IPath)cpentry.getAttribute(CPElement.LIBRARY)).toOSString());
if (!base.isEmpty()) { addBaseString(cpentry, str);
str.append(" - ("); //$NON-NLS-1$ return str.toString();
str.append(base);
str.append(')');
} else {
path = ((IPath)cpentry.getAttribute(CPElement.BASE)).addTrailingSeparator();
str.insert(0, path.toOSString());
} }
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,159 +24,180 @@ 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;
private ICProject fCurrJProject; private ICProject fCurrJProject;
private TreeListDialogField fContainersList; private TreeListDialogField fContainersList;
private final int IDX_ADD= 0; private final int IDX_ADD = 0;
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$
/* */ null, /* */null,
/* IDX_EDIT */ CPathEntryMessages.getString("ContainerEntryPage.edit.button"), //$NON-NLS-1$ /* IDX_EDIT */CPathEntryMessages.getString("ContainerEntryPage.edit.button"), //$NON-NLS-1$
/* IDX_REMOVE */ CPathEntryMessages.getString("ContainerEntryPage.remove.button") //$NON-NLS-1$ /* IDX_REMOVE */CPathEntryMessages.getString("ContainerEntryPage.remove.button") //$NON-NLS-1$
}; };
ContainersAdapter adapter= new ContainersAdapter(); ContainersAdapter adapter = new ContainersAdapter();
fContainersList= new TreeListDialogField(adapter, buttonLabels, new CPElementLabelProvider()); fContainersList = new TreeListDialogField(adapter, buttonLabels, new CPElementLabelProvider());
fContainersList.setDialogFieldListener(adapter); fContainersList.setDialogFieldListener(adapter);
fContainersList.setLabelText(CPathEntryMessages.getString("ContainerEntryPage.libraries.label")); //$NON-NLS-1$ fContainersList.setLabelText(CPathEntryMessages.getString("ContainerEntryPage.libraries.label")); //$NON-NLS-1$
fContainersList.enableButton(IDX_REMOVE, false); fContainersList.enableButton(IDX_REMOVE, false);
fContainersList.enableButton(IDX_EDIT, false); fContainersList.enableButton(IDX_EDIT, false);
fContainersList.setViewerSorter(new CPElementSorter()); fContainersList.setViewerSorter(new CPElementSorter());
} }
public void init(ICProject jproject) { public void init(ICProject jproject) {
fCurrJProject= jproject; fCurrJProject = jproject;
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());
int nElements= cpelements.size(); int nElements = cpelements.size();
for (int i= 0; i < nElements; i++) { for (int i = 0; i < nElements; i++) {
CPElement cpe= (CPElement)cpelements.get(i); CPElement cpe = (CPElement)cpelements.get(i);
if (isEntryKind(cpe.getEntryKind())) { if (isEntryKind(cpe.getEntryKind())) {
libelements.add(cpe); libelements.add(cpe);
} }
} }
fContainersList.setElements(libelements); fContainersList.setElements(libelements);
} }
// -------- ui creation // -------- ui creation
public void createControl(Composite parent) { public void createControl(Composite parent) {
PixelConverter converter= new PixelConverter(parent); PixelConverter converter = new PixelConverter(parent);
Composite composite= new Composite(parent, SWT.NONE); Composite composite = new Composite(parent, SWT.NONE);
LayoutUtil.doDefaultLayout(composite, new DialogField[] { fContainersList }, true); LayoutUtil.doDefaultLayout(composite, new DialogField[]{fContainersList}, true);
LayoutUtil.setHorizontalGrabbing(fContainersList.getTreeControl(null)); LayoutUtil.setHorizontalGrabbing(fContainersList.getTreeControl(null));
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);
} }
private class ContainersAdapter implements IDialogFieldListener, ITreeListAdapter { private class ContainersAdapter implements IDialogFieldListener, ITreeListAdapter {
private final Object[] EMPTY_ARR= new Object[0]; private final Object[] EMPTY_ARR = new Object[0];
// -------- IListAdapter -------- // -------- IListAdapter --------
public void customButtonPressed(TreeListDialogField field, int index) { public void customButtonPressed(TreeListDialogField field, int index) {
containerPageCustomButtonPressed(field, index); containerPageCustomButtonPressed(field, index);
} }
public void selectionChanged(TreeListDialogField field) { public void selectionChanged(TreeListDialogField field) {
containerPageSelectionChanged(field); containerPageSelectionChanged(field);
} }
public void doubleClicked(TreeListDialogField field) { public void doubleClicked(TreeListDialogField field) {
containerPageDoubleClicked(field); containerPageDoubleClicked(field);
} }
public void keyPressed(TreeListDialogField field, KeyEvent event) { public void keyPressed(TreeListDialogField field, KeyEvent event) {
containerPageKeyPressed(field, event); containerPageKeyPressed(field, event);
} }
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(); CPElement cpElem = (CPElement)element;
if (cpElem.getEntryKind() == IPathEntry.CDT_CONTAINER) {
return new Object[]{new CPElementGroup(cpElem, IPathEntry.CDT_MACRO),
new CPElementGroup(cpElem, IPathEntry.CDT_INCLUDE), new CPElementGroup(cpElem, IPathEntry.CDT_LIBRARY)};
} else {
return ((CPElement)element).getChildren();
}
} else if (element instanceof CPElementGroup) {
return ((CPElementGroup)element).getChildren();
} }
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 --------
public void dialogFieldChanged(DialogField field) { public void dialogFieldChanged(DialogField field) {
containerPageDialogFieldChanged(field); containerPageDialogFieldChanged(field);
} }
} }
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 :
containers= openContainerSelectionDialog(null); /* add container */
break; containers = openContainerSelectionDialog(null);
case IDX_EDIT: /* edit */ break;
editEntry(); case IDX_EDIT :
return; /* edit */
case IDX_REMOVE: /* remove */ editEntry();
removeEntry(); return;
return; case IDX_REMOVE :
/* remove */
removeEntry();
return;
} }
if (containers != null) { if (containers != null) {
int nElementsChosen= containers.length; int nElementsChosen = containers.length;
// remove duplicates // remove duplicates
List cplist= fContainersList.getElements(); List cplist = fContainersList.getElements();
List elementsToAdd= new ArrayList(nElementsChosen); List elementsToAdd = new ArrayList(nElementsChosen);
for (int i= 0; i < nElementsChosen; i++) { for (int i = 0; i < nElementsChosen; i++) {
CPElement curr= containers[i]; CPElement curr = containers[i];
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) { if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
elementsToAdd.add(curr); elementsToAdd.add(curr);
// curr.setAttribute(CPElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr)); // curr.setAttribute(CPElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
} }
} }
fContainersList.addElements(elementsToAdd); fContainersList.addElements(elementsToAdd);
if (index == IDX_ADD) { if (index == IDX_ADD) {
fContainersList.refresh(); fContainersList.refresh();
@ -184,9 +205,9 @@ public class CPathContainerEntryPage extends CPathBasePage {
fContainersList.postSetSelection(new StructuredSelection(containers)); fContainersList.postSetSelection(new StructuredSelection(containers));
} }
} }
protected void containerPageDoubleClicked(TreeListDialogField field) { protected void containerPageDoubleClicked(TreeListDialogField field) {
List selection= fContainersList.getSelectedElements(); List selection = fContainersList.getSelectedElements();
if (canEdit(selection)) { if (canEdit(selection)) {
editEntry(); editEntry();
} }
@ -195,22 +216,22 @@ public class CPathContainerEntryPage extends CPathBasePage {
protected void containerPageKeyPressed(TreeListDialogField field, KeyEvent event) { protected void containerPageKeyPressed(TreeListDialogField field, KeyEvent event) {
if (field == fContainersList) { if (field == fContainersList) {
if (event.character == SWT.DEL && event.stateMask == 0) { if (event.character == SWT.DEL && event.stateMask == 0) {
List selection= field.getSelectedElements(); List selection = field.getSelectedElements();
if (canRemove(selection)) { if (canRemove(selection)) {
removeEntry(); removeEntry();
} }
} }
} }
} }
private void removeEntry() { private void removeEntry() {
List selElements= fContainersList.getSelectedElements(); List selElements = fContainersList.getSelectedElements();
for (int i= selElements.size() - 1; i >= 0 ; i--) { for (int i = selElements.size() - 1; i >= 0; i--) {
Object elem= selElements.get(i); Object elem = selElements.get(i);
if (elem instanceof CPElementAttribute) { if (elem instanceof CPElementAttribute) {
CPElementAttribute attrib= (CPElementAttribute) elem; CPElementAttribute attrib = (CPElementAttribute)elem;
attrib.getParent().setAttribute(attrib.getKey(), null); attrib.getParent().setAttribute(attrib.getKey(), null);
selElements.remove(i); selElements.remove(i);
} }
} }
if (selElements.isEmpty()) { if (selElements.isEmpty()) {
@ -220,169 +241,172 @@ public class CPathContainerEntryPage extends CPathBasePage {
fContainersList.removeElements(selElements); fContainersList.removeElements(selElements);
} }
} }
private boolean canRemove(List selElements) { private boolean canRemove(List selElements) {
if (selElements.size() == 0) { if (selElements.size() == 0) {
return false; return false;
} }
for (int i= 0; i < selElements.size(); i++) { for (int i = 0; i < selElements.size(); i++) {
Object elem= selElements.get(i); Object elem = selElements.get(i);
if (elem instanceof CPElementAttribute) { if (elem instanceof CPElementAttribute) {
if (((CPElementAttribute)elem).getValue() == null) { if ( ((CPElementAttribute)elem).getValue() == null) {
return false; return false;
} }
} else if (elem instanceof CPElement) { } else if (elem instanceof CPElement) {
CPElement curr= (CPElement) elem; CPElement curr = (CPElement)elem;
if (curr.getParentContainer() != null) { if (curr.getParentContainer() != null) {
return false; return false;
} }
} }
} }
return true; return true;
} }
/** /**
* Method editEntry. * Method editEntry.
*/ */
private void editEntry() { private void editEntry() {
List selElements= fContainersList.getSelectedElements(); List selElements = fContainersList.getSelectedElements();
if (selElements.size() != 1) { if (selElements.size() != 1) {
return; return;
} }
Object elem= selElements.get(0); Object elem = selElements.get(0);
if (fContainersList.getIndexOfElement(elem) != -1) { if (fContainersList.getIndexOfElement(elem) != -1) {
editElementEntry((CPElement) elem); editElementEntry((CPElement)elem);
} else if (elem instanceof CPElementAttribute) { } else if (elem instanceof CPElementAttribute) {
// editAttributeEntry((CPElementAttribute) elem); // editAttributeEntry((CPElementAttribute) elem);
} }
} }
// private void editAttributeEntry(CPElementAttribute elem) { // private void editAttributeEntry(CPElementAttribute elem) {
// String key= elem.getKey(); // String key= elem.getKey();
// if (key.equals(CPElement.SOURCEATTACHMENT)) { // if (key.equals(CPElement.SOURCEATTACHMENT)) {
// CPElement selElement= elem.getParent(); // CPElement selElement= elem.getParent();
// //
// IPath containerPath= null; // IPath containerPath= null;
// boolean applyChanges= false; // boolean applyChanges= false;
// Object parentContainer= selElement.getParentContainer(); // Object parentContainer= selElement.getParentContainer();
// if (parentContainer instanceof CPElement) { // if (parentContainer instanceof CPElement) {
// 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,
// if (dialog.open() == Window.OK) { // fCurrJProject, applyChanges);
// selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath()); // if (dialog.open() == Window.OK) {
// fContainersList.refresh(); // selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath());
// fCPathList.refresh(); // images // fContainersList.refresh();
// } // fCPathList.refresh(); // images
// } // }
// } // }
// }
private void editElementEntry(CPElement elem) { private void editElementEntry(CPElement elem) {
CPElement[] res= null; CPElement[] res = null;
res= openContainerSelectionDialog(elem); res = openContainerSelectionDialog(elem);
if (res != null && res.length > 0) { if (res != null && res.length > 0) {
CPElement curr= res[0]; CPElement curr = res[0];
curr.setExported(elem.isExported()); curr.setExported(elem.isExported());
fContainersList.replaceElement(elem, curr); fContainersList.replaceElement(elem, curr);
} }
} }
private void containerPageSelectionChanged(DialogField field) { private void containerPageSelectionChanged(DialogField field) {
List selElements= fContainersList.getSelectedElements(); List selElements = fContainersList.getSelectedElements();
fContainersList.enableButton(IDX_EDIT, canEdit(selElements)); fContainersList.enableButton(IDX_EDIT, canEdit(selElements));
fContainersList.enableButton(IDX_REMOVE, canRemove(selElements)); fContainersList.enableButton(IDX_REMOVE, canRemove(selElements));
} }
private boolean canEdit(List selElements) { private boolean canEdit(List selElements) {
if (selElements.size() != 1) { if (selElements.size() != 1) {
return false; return false;
} }
Object elem= selElements.get(0); Object elem = selElements.get(0);
if (elem instanceof CPElement) { if (elem instanceof CPElement) {
CPElement curr= (CPElement) elem; CPElement curr = (CPElement)elem;
return !(curr.getResource() instanceof IFolder) && curr.getParentContainer() == null; return ! (curr.getResource() instanceof IFolder) && curr.getParentContainer() == null;
} }
if (elem instanceof CPElementAttribute) { if (elem instanceof CPElementAttribute) {
return true; return true;
} }
return false; return false;
} }
private void containerPageDialogFieldChanged(DialogField field) { private void containerPageDialogFieldChanged(DialogField field) {
if (fCurrJProject != null) { if (fCurrJProject != null) {
// already initialized // already initialized
updateCPathList(); updateCPathList();
} }
} }
private void updateCPathList() { private void updateCPathList() {
List projelements= fContainersList.getElements(); List projelements = fContainersList.getElements();
List cpelements= fCPathList.getElements(); List cpelements = fCPathList.getElements();
int nEntries= cpelements.size(); int nEntries = cpelements.size();
// backwards, as entries will be deleted // backwards, as entries will be deleted
int lastRemovePos= nEntries; int lastRemovePos = nEntries;
for (int i= nEntries - 1; i >= 0; i--) { for (int i = nEntries - 1; i >= 0; i--) {
CPElement cpe= (CPElement)cpelements.get(i); CPElement cpe = (CPElement)cpelements.get(i);
int kind= cpe.getEntryKind(); int kind = cpe.getEntryKind();
if (isEntryKind(kind)) { if (isEntryKind(kind)) {
if (!projelements.remove(cpe)) { if (!projelements.remove(cpe)) {
cpelements.remove(i); cpelements.remove(i);
lastRemovePos= i; lastRemovePos = i;
} }
} }
} }
cpelements.addAll(lastRemovePos, projelements); cpelements.addAll(lastRemovePos, projelements);
if (lastRemovePos != nEntries || !projelements.isEmpty()) { if (lastRemovePos != nEntries || !projelements.isEmpty()) {
fCPathList.setElements(cpelements); fCPathList.setElements(cpelements);
} }
} }
private CPElement[] openContainerSelectionDialog(CPElement existing) { private CPElement[] openContainerSelectionDialog(CPElement existing) {
IPathEntry elem= null; IPathEntry elem = null;
String title; String title;
if (existing == null) { if (existing == null) {
title= CPathEntryMessages.getString("ContainerEntryPage.ContainerDialog.new.title"); //$NON-NLS-1$ title = CPathEntryMessages.getString("ContainerEntryPage.ContainerDialog.new.title"); //$NON-NLS-1$
} else { } else {
title= CPathEntryMessages.getString("ContainerEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$ title = CPathEntryMessages.getString("ContainerEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
elem= existing.getPathEntry(); elem = existing.getPathEntry();
} }
CPathContainerWizard wizard= new CPathContainerWizard(elem, fCurrJProject, getRawClasspath()); CPathContainerWizard wizard = new CPathContainerWizard(elem, fCurrJProject, getRawClasspath());
wizard.setWindowTitle(title); wizard.setWindowTitle(title);
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) { if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
IPathEntry[] created= wizard.getContainers(); IPathEntry[] created = wizard.getContainers();
if (created != null) { if (created != null) {
CPElement[] res= new CPElement[created.length]; CPElement[] res = new CPElement[created.length];
for (int i= 0; i < res.length; i++) { for (int i = 0; i < res.length; i++) {
res[i]= new CPElement(fCurrJProject, IPathEntry.CDT_CONTAINER, created[i].getPath(), null); res[i] = new CPElement(fCurrJProject, IPathEntry.CDT_CONTAINER, created[i].getPath(), null);
} }
return res; return res;
} }
} }
return null; return null;
} }
private IPathEntry[] getRawClasspath() { private IPathEntry[] getRawClasspath() {
IPathEntry[] currEntries= new IPathEntry[fCPathList.getSize()]; IPathEntry[] currEntries = new IPathEntry[fCPathList.getSize()];
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)fCPathList.getElement(i);
currEntries[i]= curr.getPathEntry(); currEntries[i] = curr.getPathEntry();
} }
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) {
return kind == IPathEntry.CDT_CONTAINER; return kind == IPathEntry.CDT_CONTAINER;
} }
/* /*
* @see BuildPathBasePage#getSelection * @see BuildPathBasePage#getSelection
*/ */
@ -392,18 +416,18 @@ public class CPathContainerEntryPage extends CPathBasePage {
/* /*
* @see BuildPathBasePage#setSelection * @see BuildPathBasePage#setSelection
*/ */
public void setSelection(List selElements) { public void setSelection(List selElements) {
fContainersList.selectElements(new StructuredSelection(selElements)); fContainersList.selectElements(new StructuredSelection(selElements));
} }
public void performApply(IProgressMonitor monitor) throws CoreException { public void performApply(IProgressMonitor monitor) throws CoreException {
// dinglis-TODO Auto-generated method stub // dinglis-TODO Auto-generated method stub
} }
public void performDefaults() { public void performDefaults() {
// dinglis-TODO Auto-generated method stub // dinglis-TODO Auto-generated method stub
} }
} }

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()) {