mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 18:05:33 +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:
parent
185c25cd0e
commit
5785b4bf37
7 changed files with 322 additions and 219 deletions
|
@ -481,7 +481,7 @@ public class CPElement {
|
|||
res = root.getFolder(path);
|
||||
}
|
||||
}
|
||||
if (res.getType() != IResource.PROJECT && project != null) {
|
||||
if (res.getType() != IResource.ROOT && project != null) {
|
||||
isMissing = !project.isOnSourceRoot(res);
|
||||
}
|
||||
exclusion = ((IIncludeEntry) curr).getExclusionPatterns();
|
||||
|
@ -498,7 +498,7 @@ public class CPElement {
|
|||
res = root.getFolder(path);
|
||||
}
|
||||
}
|
||||
if (res.getType() != IResource.PROJECT && project != null) {
|
||||
if (res.getType() != IResource.ROOT && project != null) {
|
||||
isMissing = !project.isOnSourceRoot(res);
|
||||
}
|
||||
exclusion = ((IMacroEntry) curr).getExclusionPatterns();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -34,8 +34,8 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
private ImageDescriptorRegistry fRegistry;
|
||||
|
||||
public CPElementLabelProvider() {
|
||||
fNewLabel = CPathEntryMessages.getString("CPListLabelProvider.new"); //$NON-NLS-1$
|
||||
fCreateLabel = CPathEntryMessages.getString("CPListLabelProvider.willbecreated"); //$NON-NLS-1$
|
||||
fNewLabel = CPathEntryMessages.getString("CPElementLabelProvider.new"); //$NON-NLS-1$
|
||||
fCreateLabel = CPathEntryMessages.getString("CPElementLabelProvider.willbecreated"); //$NON-NLS-1$
|
||||
fRegistry = CUIPlugin.getImageDescriptorRegistry();
|
||||
|
||||
fLibIcon = CPluginImages.DESC_OBJS_ARCHIVE;
|
||||
|
@ -58,16 +58,30 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
return getCPElementAttributeText((CPElementAttribute)element);
|
||||
} else if (element instanceof IPathEntry) {
|
||||
return getCPElementText(CPElement.createFromExisting((IPathEntry)element, null));
|
||||
} else if (element instanceof CPElementGroup) {
|
||||
return (getCPContainerGroupText((CPElementGroup)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) {
|
||||
String notAvailable = CPathEntryMessages.getString("CPListLabelProvider.none"); //$NON-NLS-1$
|
||||
String notAvailable = CPathEntryMessages.getString("CPElementLabelProvider.none"); //$NON-NLS-1$
|
||||
StringBuffer buf = new StringBuffer();
|
||||
String key = attrib.getKey();
|
||||
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();
|
||||
if (path != null && !path.isEmpty()) {
|
||||
buf.append(getPathString(path, path.getDevice() != null));
|
||||
|
@ -75,7 +89,7 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
buf.append(notAvailable);
|
||||
}
|
||||
} 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();
|
||||
if (path != null && !path.isEmpty()) {
|
||||
buf.append(path.toString());
|
||||
|
@ -84,12 +98,12 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
}
|
||||
}
|
||||
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();
|
||||
if (patterns != null && patterns.length > 0) {
|
||||
for (int i = 0; i < patterns.length; i++) {
|
||||
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());
|
||||
}
|
||||
|
@ -103,45 +117,26 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
public String getCPElementText(CPElement cpentry) {
|
||||
IPath path = cpentry.getPath();
|
||||
switch (cpentry.getEntryKind()) {
|
||||
case IPathEntry.CDT_LIBRARY : {
|
||||
StringBuffer str = new StringBuffer( ((IPath)cpentry.getAttribute(CPElement.LIBRARY)).toOSString());
|
||||
IPath base = (IPath)cpentry.getAttribute(CPElement.BASE_REF);
|
||||
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());
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
{
|
||||
StringBuffer str = new StringBuffer( ((IPath)cpentry.getAttribute(CPElement.LIBRARY)).toOSString());
|
||||
addBaseString(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_PROJECT :
|
||||
return path.lastSegment();
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
{
|
||||
StringBuffer str = new StringBuffer( ((IPath)cpentry.getAttribute(CPElement.INCLUDE)).toOSString());
|
||||
IPath base = (IPath)cpentry.getAttribute(CPElement.BASE_REF);
|
||||
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());
|
||||
}
|
||||
IPath incPath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE));
|
||||
StringBuffer str = new StringBuffer(incPath.toOSString());
|
||||
addBaseString(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_MACRO :
|
||||
{
|
||||
StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
|
||||
+ (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
|
||||
IPath base = (IPath)cpentry.getAttribute(CPElement.BASE_REF);
|
||||
if (!base.isEmpty()) {
|
||||
str.append('(');
|
||||
str.append(base);
|
||||
str.append(')');
|
||||
}
|
||||
addBaseString(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_CONTAINER :
|
||||
|
@ -171,7 +166,38 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
default :
|
||||
// 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) {
|
||||
|
@ -242,6 +268,15 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
}
|
||||
} else if (element instanceof IPathEntry) {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -24,159 +24,180 @@ import org.eclipse.core.resources.IFolder;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
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.swt.SWT;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
|
||||
public class CPathContainerEntryPage extends CPathBasePage {
|
||||
|
||||
private ListDialogField fCPathList;
|
||||
private ICProject fCurrJProject;
|
||||
|
||||
|
||||
private TreeListDialogField fContainersList;
|
||||
|
||||
private final int IDX_ADD= 0;
|
||||
|
||||
private final int IDX_EDIT= 2;
|
||||
private final int IDX_REMOVE= 3;
|
||||
|
||||
|
||||
public CPathContainerEntryPage(ListDialogField classPathList) {
|
||||
|
||||
private final int IDX_ADD = 0;
|
||||
|
||||
private final int IDX_EDIT = 2;
|
||||
private final int IDX_REMOVE = 3;
|
||||
|
||||
public CPathContainerEntryPage(ListDialogField cPathList) {
|
||||
super(CPathEntryMessages.getString("ContainerEntryPage.title")); //$NON-NLS-1$
|
||||
fCPathList= classPathList;
|
||||
|
||||
String[] buttonLabels= new String[] {
|
||||
/* IDX_ADD*/ CPathEntryMessages.getString("ContainerEntryPage.add.button"), //$NON-NLS-1$
|
||||
/* */ null,
|
||||
/* IDX_EDIT */ CPathEntryMessages.getString("ContainerEntryPage.edit.button"), //$NON-NLS-1$
|
||||
/* IDX_REMOVE */ CPathEntryMessages.getString("ContainerEntryPage.remove.button") //$NON-NLS-1$
|
||||
};
|
||||
|
||||
ContainersAdapter adapter= new ContainersAdapter();
|
||||
|
||||
fContainersList= new TreeListDialogField(adapter, buttonLabels, new CPElementLabelProvider());
|
||||
fCPathList = cPathList;
|
||||
|
||||
String[] buttonLabels = new String[]{
|
||||
/* IDX_ADD */CPathEntryMessages.getString("ContainerEntryPage.add.button"), //$NON-NLS-1$
|
||||
/* */null,
|
||||
/* IDX_EDIT */CPathEntryMessages.getString("ContainerEntryPage.edit.button"), //$NON-NLS-1$
|
||||
/* IDX_REMOVE */CPathEntryMessages.getString("ContainerEntryPage.remove.button") //$NON-NLS-1$
|
||||
};
|
||||
|
||||
ContainersAdapter adapter = new ContainersAdapter();
|
||||
|
||||
fContainersList = new TreeListDialogField(adapter, buttonLabels, new CPElementLabelProvider());
|
||||
fContainersList.setDialogFieldListener(adapter);
|
||||
fContainersList.setLabelText(CPathEntryMessages.getString("ContainerEntryPage.libraries.label")); //$NON-NLS-1$
|
||||
|
||||
fContainersList.enableButton(IDX_REMOVE, false);
|
||||
fContainersList.enableButton(IDX_EDIT, false);
|
||||
|
||||
|
||||
fContainersList.setViewerSorter(new CPElementSorter());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void init(ICProject jproject) {
|
||||
fCurrJProject= jproject;
|
||||
fCurrJProject = jproject;
|
||||
updateLibrariesList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateLibrariesList() {
|
||||
List cpelements= fCPathList.getElements();
|
||||
List libelements= new ArrayList(cpelements.size());
|
||||
|
||||
int nElements= cpelements.size();
|
||||
for (int i= 0; i < nElements; i++) {
|
||||
CPElement cpe= (CPElement)cpelements.get(i);
|
||||
List cpelements = fCPathList.getElements();
|
||||
List libelements = new ArrayList(cpelements.size());
|
||||
|
||||
int nElements = cpelements.size();
|
||||
for (int i = 0; i < nElements; i++) {
|
||||
CPElement cpe = (CPElement)cpelements.get(i);
|
||||
if (isEntryKind(cpe.getEntryKind())) {
|
||||
libelements.add(cpe);
|
||||
}
|
||||
}
|
||||
fContainersList.setElements(libelements);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -------- ui creation
|
||||
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
PixelConverter converter= new PixelConverter(parent);
|
||||
|
||||
Composite composite= new Composite(parent, SWT.NONE);
|
||||
|
||||
LayoutUtil.doDefaultLayout(composite, new DialogField[] { fContainersList }, true);
|
||||
PixelConverter converter = new PixelConverter(parent);
|
||||
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
|
||||
LayoutUtil.doDefaultLayout(composite, new DialogField[]{fContainersList}, true);
|
||||
LayoutUtil.setHorizontalGrabbing(fContainersList.getTreeControl(null));
|
||||
|
||||
int buttonBarWidth= converter.convertWidthInCharsToPixels(24);
|
||||
|
||||
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
private class ContainersAdapter implements IDialogFieldListener, ITreeListAdapter {
|
||||
|
||||
private final Object[] EMPTY_ARR= new Object[0];
|
||||
|
||||
|
||||
private final Object[] EMPTY_ARR = new Object[0];
|
||||
|
||||
// -------- IListAdapter --------
|
||||
public void customButtonPressed(TreeListDialogField field, int index) {
|
||||
containerPageCustomButtonPressed(field, index);
|
||||
}
|
||||
|
||||
|
||||
public void selectionChanged(TreeListDialogField field) {
|
||||
containerPageSelectionChanged(field);
|
||||
}
|
||||
|
||||
|
||||
public void doubleClicked(TreeListDialogField field) {
|
||||
containerPageDoubleClicked(field);
|
||||
}
|
||||
|
||||
|
||||
public void keyPressed(TreeListDialogField field, KeyEvent event) {
|
||||
containerPageKeyPressed(field, event);
|
||||
}
|
||||
|
||||
public Object[] getChildren(TreeListDialogField field, Object element) {
|
||||
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;
|
||||
}
|
||||
|
||||
public Object getParent(TreeListDialogField field, Object element) {
|
||||
if (element instanceof CPElementAttribute) {
|
||||
return ((CPElementAttribute) element).getParent();
|
||||
return ((CPElementAttribute)element).getParent();
|
||||
} else if (element instanceof CPElementGroup) {
|
||||
return ((CPElementGroup)element).getElement();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasChildren(TreeListDialogField field, Object element) {
|
||||
return (element instanceof CPElement);
|
||||
}
|
||||
|
||||
return (element instanceof CPElement || element instanceof CPElementGroup);
|
||||
}
|
||||
|
||||
// ---------- IDialogFieldListener --------
|
||||
|
||||
|
||||
public void dialogFieldChanged(DialogField field) {
|
||||
containerPageDialogFieldChanged(field);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void containerPageCustomButtonPressed(DialogField field, int index) {
|
||||
CPElement[] containers= null;
|
||||
CPElement[] containers = null;
|
||||
switch (index) {
|
||||
case IDX_ADD: /* add container */
|
||||
containers= openContainerSelectionDialog(null);
|
||||
break;
|
||||
case IDX_EDIT: /* edit */
|
||||
editEntry();
|
||||
return;
|
||||
case IDX_REMOVE: /* remove */
|
||||
removeEntry();
|
||||
return;
|
||||
case IDX_ADD :
|
||||
/* add container */
|
||||
containers = openContainerSelectionDialog(null);
|
||||
break;
|
||||
case IDX_EDIT :
|
||||
/* edit */
|
||||
editEntry();
|
||||
return;
|
||||
case IDX_REMOVE :
|
||||
/* remove */
|
||||
removeEntry();
|
||||
return;
|
||||
}
|
||||
if (containers != null) {
|
||||
int nElementsChosen= containers.length;
|
||||
int nElementsChosen = containers.length;
|
||||
// remove duplicates
|
||||
List cplist= fContainersList.getElements();
|
||||
List elementsToAdd= new ArrayList(nElementsChosen);
|
||||
|
||||
for (int i= 0; i < nElementsChosen; i++) {
|
||||
CPElement curr= containers[i];
|
||||
List cplist = fContainersList.getElements();
|
||||
List elementsToAdd = new ArrayList(nElementsChosen);
|
||||
|
||||
for (int i = 0; i < nElementsChosen; i++) {
|
||||
CPElement curr = containers[i];
|
||||
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
||||
elementsToAdd.add(curr);
|
||||
// curr.setAttribute(CPElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
|
||||
// curr.setAttribute(CPElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fContainersList.addElements(elementsToAdd);
|
||||
if (index == IDX_ADD) {
|
||||
fContainersList.refresh();
|
||||
|
@ -184,9 +205,9 @@ public class CPathContainerEntryPage extends CPathBasePage {
|
|||
fContainersList.postSetSelection(new StructuredSelection(containers));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void containerPageDoubleClicked(TreeListDialogField field) {
|
||||
List selection= fContainersList.getSelectedElements();
|
||||
List selection = fContainersList.getSelectedElements();
|
||||
if (canEdit(selection)) {
|
||||
editEntry();
|
||||
}
|
||||
|
@ -195,22 +216,22 @@ public class CPathContainerEntryPage extends CPathBasePage {
|
|||
protected void containerPageKeyPressed(TreeListDialogField field, KeyEvent event) {
|
||||
if (field == fContainersList) {
|
||||
if (event.character == SWT.DEL && event.stateMask == 0) {
|
||||
List selection= field.getSelectedElements();
|
||||
List selection = field.getSelectedElements();
|
||||
if (canRemove(selection)) {
|
||||
removeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeEntry() {
|
||||
List selElements= fContainersList.getSelectedElements();
|
||||
for (int i= selElements.size() - 1; i >= 0 ; i--) {
|
||||
Object elem= selElements.get(i);
|
||||
List selElements = fContainersList.getSelectedElements();
|
||||
for (int i = selElements.size() - 1; i >= 0; i--) {
|
||||
Object elem = selElements.get(i);
|
||||
if (elem instanceof CPElementAttribute) {
|
||||
CPElementAttribute attrib= (CPElementAttribute) elem;
|
||||
CPElementAttribute attrib = (CPElementAttribute)elem;
|
||||
attrib.getParent().setAttribute(attrib.getKey(), null);
|
||||
selElements.remove(i);
|
||||
selElements.remove(i);
|
||||
}
|
||||
}
|
||||
if (selElements.isEmpty()) {
|
||||
|
@ -220,169 +241,172 @@ public class CPathContainerEntryPage extends CPathBasePage {
|
|||
fContainersList.removeElements(selElements);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean canRemove(List selElements) {
|
||||
if (selElements.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i= 0; i < selElements.size(); i++) {
|
||||
Object elem= selElements.get(i);
|
||||
for (int i = 0; i < selElements.size(); i++) {
|
||||
Object elem = selElements.get(i);
|
||||
if (elem instanceof CPElementAttribute) {
|
||||
if (((CPElementAttribute)elem).getValue() == null) {
|
||||
if ( ((CPElementAttribute)elem).getValue() == null) {
|
||||
return false;
|
||||
}
|
||||
} else if (elem instanceof CPElement) {
|
||||
CPElement curr= (CPElement) elem;
|
||||
CPElement curr = (CPElement)elem;
|
||||
if (curr.getParentContainer() != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method editEntry.
|
||||
*/
|
||||
private void editEntry() {
|
||||
List selElements= fContainersList.getSelectedElements();
|
||||
List selElements = fContainersList.getSelectedElements();
|
||||
if (selElements.size() != 1) {
|
||||
return;
|
||||
}
|
||||
Object elem= selElements.get(0);
|
||||
Object elem = selElements.get(0);
|
||||
if (fContainersList.getIndexOfElement(elem) != -1) {
|
||||
editElementEntry((CPElement) elem);
|
||||
editElementEntry((CPElement)elem);
|
||||
} else if (elem instanceof CPElementAttribute) {
|
||||
// editAttributeEntry((CPElementAttribute) elem);
|
||||
// editAttributeEntry((CPElementAttribute) elem);
|
||||
}
|
||||
}
|
||||
|
||||
// private void editAttributeEntry(CPElementAttribute elem) {
|
||||
// String key= elem.getKey();
|
||||
// if (key.equals(CPElement.SOURCEATTACHMENT)) {
|
||||
// CPElement selElement= elem.getParent();
|
||||
//
|
||||
// IPath containerPath= null;
|
||||
// boolean applyChanges= false;
|
||||
// Object parentContainer= selElement.getParentContainer();
|
||||
// if (parentContainer instanceof CPElement) {
|
||||
// containerPath= ((CPElement) parentContainer).getPath();
|
||||
// applyChanges= true;
|
||||
// }
|
||||
// SourceAttachmentDialog dialog= new SourceAttachmentDialog(getShell(), selElement.getPathEntry(), containerPath, fCurrJProject, applyChanges);
|
||||
// if (dialog.open() == Window.OK) {
|
||||
// selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath());
|
||||
// fContainersList.refresh();
|
||||
// fCPathList.refresh(); // images
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// private void editAttributeEntry(CPElementAttribute elem) {
|
||||
// String key= elem.getKey();
|
||||
// if (key.equals(CPElement.SOURCEATTACHMENT)) {
|
||||
// CPElement selElement= elem.getParent();
|
||||
//
|
||||
// IPath containerPath= null;
|
||||
// boolean applyChanges= false;
|
||||
// Object parentContainer= selElement.getParentContainer();
|
||||
// if (parentContainer instanceof CPElement) {
|
||||
// containerPath= ((CPElement) parentContainer).getPath();
|
||||
// applyChanges= true;
|
||||
// }
|
||||
// SourceAttachmentDialog dialog= new SourceAttachmentDialog(getShell(), selElement.getPathEntry(), containerPath,
|
||||
// fCurrJProject, applyChanges);
|
||||
// if (dialog.open() == Window.OK) {
|
||||
// selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath());
|
||||
// fContainersList.refresh();
|
||||
// fCPathList.refresh(); // images
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private void editElementEntry(CPElement elem) {
|
||||
CPElement[] res= null;
|
||||
|
||||
res= openContainerSelectionDialog(elem);
|
||||
CPElement[] res = null;
|
||||
|
||||
res = openContainerSelectionDialog(elem);
|
||||
if (res != null && res.length > 0) {
|
||||
CPElement curr= res[0];
|
||||
CPElement curr = res[0];
|
||||
curr.setExported(elem.isExported());
|
||||
fContainersList.replaceElement(elem, curr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void containerPageSelectionChanged(DialogField field) {
|
||||
List selElements= fContainersList.getSelectedElements();
|
||||
List selElements = fContainersList.getSelectedElements();
|
||||
fContainersList.enableButton(IDX_EDIT, canEdit(selElements));
|
||||
fContainersList.enableButton(IDX_REMOVE, canRemove(selElements));
|
||||
}
|
||||
|
||||
|
||||
private boolean canEdit(List selElements) {
|
||||
if (selElements.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
Object elem= selElements.get(0);
|
||||
Object elem = selElements.get(0);
|
||||
if (elem instanceof CPElement) {
|
||||
CPElement curr= (CPElement) elem;
|
||||
return !(curr.getResource() instanceof IFolder) && curr.getParentContainer() == null;
|
||||
CPElement curr = (CPElement)elem;
|
||||
return ! (curr.getResource() instanceof IFolder) && curr.getParentContainer() == null;
|
||||
}
|
||||
if (elem instanceof CPElementAttribute) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void containerPageDialogFieldChanged(DialogField field) {
|
||||
if (fCurrJProject != null) {
|
||||
// already initialized
|
||||
updateCPathList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateCPathList() {
|
||||
List projelements= fContainersList.getElements();
|
||||
|
||||
List cpelements= fCPathList.getElements();
|
||||
int nEntries= cpelements.size();
|
||||
List projelements = fContainersList.getElements();
|
||||
|
||||
List cpelements = fCPathList.getElements();
|
||||
int nEntries = cpelements.size();
|
||||
// backwards, as entries will be deleted
|
||||
int lastRemovePos= nEntries;
|
||||
for (int i= nEntries - 1; i >= 0; i--) {
|
||||
CPElement cpe= (CPElement)cpelements.get(i);
|
||||
int kind= cpe.getEntryKind();
|
||||
int lastRemovePos = nEntries;
|
||||
for (int i = nEntries - 1; i >= 0; i--) {
|
||||
CPElement cpe = (CPElement)cpelements.get(i);
|
||||
int kind = cpe.getEntryKind();
|
||||
if (isEntryKind(kind)) {
|
||||
if (!projelements.remove(cpe)) {
|
||||
cpelements.remove(i);
|
||||
lastRemovePos= i;
|
||||
}
|
||||
lastRemovePos = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cpelements.addAll(lastRemovePos, projelements);
|
||||
|
||||
if (lastRemovePos != nEntries || !projelements.isEmpty()) {
|
||||
fCPathList.setElements(cpelements);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private CPElement[] openContainerSelectionDialog(CPElement existing) {
|
||||
IPathEntry elem= null;
|
||||
IPathEntry elem = null;
|
||||
String title;
|
||||
if (existing == null) {
|
||||
title= CPathEntryMessages.getString("ContainerEntryPage.ContainerDialog.new.title"); //$NON-NLS-1$
|
||||
title = CPathEntryMessages.getString("ContainerEntryPage.ContainerDialog.new.title"); //$NON-NLS-1$
|
||||
} else {
|
||||
title= CPathEntryMessages.getString("ContainerEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
|
||||
elem= existing.getPathEntry();
|
||||
title = CPathEntryMessages.getString("ContainerEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
|
||||
elem = existing.getPathEntry();
|
||||
}
|
||||
CPathContainerWizard wizard= new CPathContainerWizard(elem, fCurrJProject, getRawClasspath());
|
||||
CPathContainerWizard wizard = new CPathContainerWizard(elem, fCurrJProject, getRawClasspath());
|
||||
wizard.setWindowTitle(title);
|
||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||
IPathEntry[] created= wizard.getContainers();
|
||||
IPathEntry[] created = wizard.getContainers();
|
||||
if (created != null) {
|
||||
CPElement[] res= new CPElement[created.length];
|
||||
for (int i= 0; i < res.length; i++) {
|
||||
res[i]= new CPElement(fCurrJProject, IPathEntry.CDT_CONTAINER, created[i].getPath(), null);
|
||||
CPElement[] res = new CPElement[created.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
res[i] = new CPElement(fCurrJProject, IPathEntry.CDT_CONTAINER, created[i].getPath(), null);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private IPathEntry[] getRawClasspath() {
|
||||
IPathEntry[] currEntries= new IPathEntry[fCPathList.getSize()];
|
||||
for (int i= 0; i < currEntries.length; i++) {
|
||||
CPElement curr= (CPElement) fCPathList.getElement(i);
|
||||
currEntries[i]= curr.getPathEntry();
|
||||
IPathEntry[] currEntries = new IPathEntry[fCPathList.getSize()];
|
||||
for (int i = 0; i < currEntries.length; i++) {
|
||||
CPElement curr = (CPElement)fCPathList.getElement(i);
|
||||
currEntries[i] = curr.getPathEntry();
|
||||
}
|
||||
return currEntries;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
|
||||
*/
|
||||
public boolean isEntryKind(int kind) {
|
||||
return kind == IPathEntry.CDT_CONTAINER;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see BuildPathBasePage#getSelection
|
||||
*/
|
||||
|
@ -392,18 +416,18 @@ public class CPathContainerEntryPage extends CPathBasePage {
|
|||
|
||||
/*
|
||||
* @see BuildPathBasePage#setSelection
|
||||
*/
|
||||
*/
|
||||
public void setSelection(List selElements) {
|
||||
fContainersList.selectElements(new StructuredSelection(selElements));
|
||||
}
|
||||
|
||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||
// dinglis-TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void performDefaults() {
|
||||
// dinglis-TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -50,7 +50,6 @@ ProjectContainerPage.description=Select the C/C++ Project which contains path en
|
|||
ProjectContainerPage.label=C/C++ Projects:
|
||||
|
||||
# -------- ExtendingCPathBasePage ---------
|
||||
ExtendingCPathBasePage.editSourcePaths=Edit Source Paths...
|
||||
ExtendingCPathBasePage.sourcePaths=Source Paths:
|
||||
|
||||
# -------- SymbolsEntryPage ---------
|
||||
|
@ -225,14 +224,17 @@ ExclusionPatternEntryDialog.ChooseExclusionPattern.title=Exclusion Pattern Selec
|
|||
ExclusionPatternEntryDialog.ChooseExclusionPattern.description=&Choose a folder or file to exclude:
|
||||
|
||||
# ------- CPListLabelProvider -------
|
||||
CPListLabelProvider.new=(new)
|
||||
CPListLabelProvider.willbecreated=(will be created)
|
||||
CPListLabelProvider.none=(None)
|
||||
CPListLabelProvider.source_attachment.label=Source attachment:
|
||||
CPListLabelProvider.source_attachment_root.label=Source attachment root:
|
||||
CPListLabelProvider.exclusion_filter.label=Exclusion filter:
|
||||
CPListLabelProvider.exclusion_filter_separator=;
|
||||
CPListLabelProvider.unknown_element.label=unknown element
|
||||
CPElementLabelProvider.new=(new)
|
||||
CPElementLabelProvider.willbecreated=(will be created)
|
||||
CPElementLabelProvider.none=(None)
|
||||
CPElementLabelProvider.source_attachment.label=Source attachment:
|
||||
CPElementLabelProvider.source_attachment_root.label=Source attachment root:
|
||||
CPElementLabelProvider.exclusion_filter.label=Exclusion filter:
|
||||
CPElementLabelProvider.exclusion_filter_separator=;
|
||||
CPElementLabelProvider.unknown_element.label=unknown element
|
||||
CPElementLabelProvider.Includes=Includes
|
||||
CPElementLabelProvider.PreprocessorSymbols=Preprocessor Symbols
|
||||
CPElementLabelProvider.Libraries=Libraries
|
||||
|
||||
# ------- NewSourceFolderDialog-------
|
||||
NewSourceFolderDialog.useproject.button=&Project as source folder
|
||||
|
|
|
@ -33,7 +33,7 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
private CPathContainerEntryPage fContainerPage;
|
||||
private CPathLibraryEntryPage fLibrariesPage;
|
||||
|
||||
private CPathOrderExportPage fOrderExportPage;
|
||||
// private CPathOrderExportPage fOrderExportPage;
|
||||
|
||||
private class BuildPathAdapter implements IDialogFieldListener {
|
||||
|
||||
|
@ -86,8 +86,8 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
addPage(fLibrariesPage);
|
||||
fContainerPage = new CPathContainerEntryPage(fCPathList);
|
||||
addPage(fContainerPage);
|
||||
fOrderExportPage = new CPathOrderExportPage(fCPathList);
|
||||
addPage(fOrderExportPage);
|
||||
// fOrderExportPage = new CPathOrderExportPage(fCPathList);
|
||||
// addPage(fOrderExportPage);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -53,7 +53,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
|||
private ListDialogField fPathList;
|
||||
private TreeListDialogField fSrcList;
|
||||
|
||||
private class IncludeListAdapter implements IListAdapter, IDialogFieldListener {
|
||||
private class ListAdapter implements IListAdapter, IDialogFieldListener {
|
||||
|
||||
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) {
|
||||
super(title);
|
||||
IncludeListAdapter includeListAdaper = new IncludeListAdapter();
|
||||
ListAdapter includeListAdaper = new ListAdapter();
|
||||
|
||||
fPathList = new ListDialogField(includeListAdaper, buttons, new ModifiedCPListLabelProvider()) {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue