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

cpath ui update

This commit is contained in:
David Inglis 2004-04-29 19:26:51 +00:00
parent 4aecba2e95
commit f12fae4a2a
24 changed files with 419 additions and 349 deletions

View file

@ -1,11 +1,10 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -510,7 +510,7 @@ public class CPElement {
elem.setAttribute(BASE, base);
elem.setExported(curr.isExported());
if (project.exists()) {
if (project != null && project.exists()) {
elem.setIsMissing(isMissing);
}
return elem;

View file

@ -1,3 +1,11 @@
/*******************************************************************************
* 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.Arrays;
@ -11,8 +19,8 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
/**
* Viewer filter for archive selection dialogs. Archives are files with file
* extension '.so', '.dll' and '.a'. The filter is not case sensitive.
* Viewer filter for archive selection dialogs. Archives are files with file extension '.so', '.dll' and '.a'. The filter is not
* case sensitive.
*/
public class CPElementFilter extends ViewerFilter {
@ -22,10 +30,9 @@ public class CPElementFilter extends ViewerFilter {
/**
* @param excludedFiles
* Excluded paths will not pass the filter. <code>null</code> is
* allowed if no files should be excluded.
* Excluded paths will not pass the filter. <code>null</code> is allowed if no files should be excluded.
* @param recusive
* Folders are only shown if, searched recursivly, contain an archive
* Folders are only shown if, searched recursivly, contain an archive
*/
public CPElementFilter(CPElement[] excludedElements, int kind, boolean exportedOnly) {
if (excludedElements != null) {
@ -34,20 +41,19 @@ public class CPElementFilter extends ViewerFilter {
fKind = kind;
fExportedOnly = exportedOnly;
}
public CPElementFilter(int kind, boolean exportedOnly) {
this(null, kind, exportedOnly);
}
/*
* @see ViewerFilter#select
*/
public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof CPElement) {
if (((CPElement) element).getEntryKind() == fKind) {
if ( ((CPElement) element).getEntryKind() == fKind) {
if (fExcludes != null && !fExcludes.contains(element)) {
if (fExportedOnly == true && !((CPElement) element).isExported()) {
if (fExportedOnly == true && ! ((CPElement) element).isExported()) {
return false;
}
return true;

View file

@ -16,7 +16,6 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
@ -29,7 +28,7 @@ import org.eclipse.ui.ide.IDE;
class CPElementLabelProvider extends LabelProvider {
private String fNewLabel, fClassLabel, fCreateLabel;
private String fNewLabel, fCreateLabel;
private ImageDescriptor fIncludeIcon, fMacroIcon, fLibWSrcIcon, fLibIcon, fExtLibIcon, fExtLibWSrcIcon;
private ImageDescriptor fFolderImage, fOutputImage, fProjectImage, fContainerImage;
@ -37,7 +36,6 @@ class CPElementLabelProvider extends LabelProvider {
public CPElementLabelProvider() {
fNewLabel = CPathEntryMessages.getString("CPListLabelProvider.new"); //$NON-NLS-1$
fClassLabel = CPathEntryMessages.getString("CPListLabelProvider.classcontainer"); //$NON-NLS-1$
fCreateLabel = CPathEntryMessages.getString("CPListLabelProvider.willbecreated"); //$NON-NLS-1$
fRegistry = CUIPlugin.getImageDescriptorRegistry();
@ -56,11 +54,11 @@ class CPElementLabelProvider extends LabelProvider {
public String getText(Object element) {
if (element instanceof CPElement) {
return getCPListElementText((CPElement) element);
return getCPListElementText((CPElement)element);
} else if (element instanceof CPElementAttribute) {
return getCPListElementAttributeText((CPElementAttribute) element);
return getCPListElementAttributeText((CPElementAttribute)element);
} else if (element instanceof IPathEntry) {
return getCPListElementText(CPElement.createFromExisting((IPathEntry) element, null));
return getCPListElementText(CPElement.createFromExisting((IPathEntry)element, null));
}
return super.getText(element);
}
@ -71,7 +69,7 @@ class CPElementLabelProvider extends LabelProvider {
String key = attrib.getKey();
if (key.equals(CPElement.SOURCEATTACHMENT)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.source_attachment.label")); //$NON-NLS-1$
IPath path = (IPath) attrib.getValue();
IPath path = (IPath)attrib.getValue();
if (path != null && !path.isEmpty()) {
buf.append(getPathString(path, path.getDevice() != null));
} else {
@ -79,7 +77,7 @@ class CPElementLabelProvider extends LabelProvider {
}
} else if (key.equals(CPElement.SOURCEATTACHMENTROOT)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.source_attachment_root.label")); //$NON-NLS-1$
IPath path = (IPath) attrib.getValue();
IPath path = (IPath)attrib.getValue();
if (path != null && !path.isEmpty()) {
buf.append(path.toString());
} else {
@ -88,7 +86,7 @@ class CPElementLabelProvider extends LabelProvider {
}
if (key.equals(CPElement.EXCLUSION)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.exclusion_filter.label")); //$NON-NLS-1$
IPath[] patterns = (IPath[]) attrib.getValue();
IPath[] patterns = (IPath[])attrib.getValue();
if (patterns != null && patterns.length > 0) {
for (int i = 0; i < patterns.length; i++) {
if (i > 0) {
@ -106,47 +104,29 @@ class CPElementLabelProvider extends LabelProvider {
public String getCPListElementText(CPElement cpentry) {
IPath path = cpentry.getPath();
switch (cpentry.getEntryKind()) {
case IPathEntry.CDT_LIBRARY:
{
IResource resource = cpentry.getResource();
if (resource instanceof IContainer) {
StringBuffer buf = new StringBuffer(path.makeRelative().toString());
buf.append(' ');
buf.append(fClassLabel);
if (!resource.exists()) {
buf.append(' ');
if (cpentry.isMissing()) {
buf.append(fCreateLabel);
} else {
buf.append(fNewLabel);
}
}
return buf.toString();
}
// should not come here
return path.makeRelative().toString();
}
case IPathEntry.CDT_PROJECT:
case IPathEntry.CDT_LIBRARY :
return path.makeRelative().toString();
case IPathEntry.CDT_PROJECT :
return path.lastSegment();
case IPathEntry.CDT_INCLUDE:
case IPathEntry.CDT_INCLUDE :
{
StringBuffer str = new StringBuffer(((IPath) cpentry.getAttribute(CPElement.INCLUDE)).toOSString());
IPath base = (IPath) cpentry.getAttribute(CPElement.BASE_REF);
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();
path = ((IPath)cpentry.getAttribute(CPElement.BASE)).addTrailingSeparator();
str.insert(0, path.toOSString());
}
return str.toString();
}
case IPathEntry.CDT_MACRO:
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);
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);
@ -154,7 +134,7 @@ class CPElementLabelProvider extends LabelProvider {
}
return str.toString();
}
case IPathEntry.CDT_CONTAINER:
case IPathEntry.CDT_CONTAINER :
try {
IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
if (container != null) {
@ -163,8 +143,8 @@ class CPElementLabelProvider extends LabelProvider {
} catch (CModelException e) {
}
return path.toString();
case IPathEntry.CDT_SOURCE:
case IPathEntry.CDT_OUTPUT:
case IPathEntry.CDT_SOURCE :
case IPathEntry.CDT_OUTPUT :
{
StringBuffer buf = new StringBuffer(path.makeRelative().toString());
IResource resource = cpentry.getResource();
@ -178,7 +158,7 @@ class CPElementLabelProvider extends LabelProvider {
}
return buf.toString();
}
default:
default :
// pass
}
return CPathEntryMessages.getString("CPListLabelProvider.unknown_element.label"); //$NON-NLS-1$
@ -200,21 +180,21 @@ class CPElementLabelProvider extends LabelProvider {
private ImageDescriptor getCPListElementBaseImage(CPElement cpentry) {
switch (cpentry.getEntryKind()) {
case IPathEntry.CDT_OUTPUT:
case IPathEntry.CDT_OUTPUT :
if (cpentry.getPath().segmentCount() == 1) {
return fProjectImage;
} else {
return fOutputImage;
}
case IPathEntry.CDT_SOURCE:
case IPathEntry.CDT_SOURCE :
if (cpentry.getPath().segmentCount() == 1) {
return fProjectImage;
} else {
return fFolderImage;
}
case IPathEntry.CDT_LIBRARY:
case IPathEntry.CDT_LIBRARY :
IResource res = cpentry.getResource();
IPath path = (IPath) cpentry.getAttribute(CPElement.SOURCEATTACHMENT);
IPath path = (IPath)cpentry.getAttribute(CPElement.SOURCEATTACHMENT);
if (res == null) {
if (path == null || path.isEmpty()) {
return fExtLibIcon;
@ -230,15 +210,15 @@ class CPElementLabelProvider extends LabelProvider {
} else {
return fFolderImage;
}
case IPathEntry.CDT_PROJECT:
case IPathEntry.CDT_PROJECT :
return fProjectImage;
case IPathEntry.CDT_CONTAINER:
case IPathEntry.CDT_CONTAINER :
return fContainerImage;
case IPathEntry.CDT_INCLUDE:
case IPathEntry.CDT_INCLUDE :
return fIncludeIcon;
case IPathEntry.CDT_MACRO:
case IPathEntry.CDT_MACRO :
return fMacroIcon;
default:
default :
return null;
}
}
@ -247,7 +227,7 @@ class CPElementLabelProvider extends LabelProvider {
public Image getImage(Object element) {
if (element instanceof CPElement) {
CPElement cpentry = (CPElement) element;
CPElement cpentry = (CPElement)element;
ImageDescriptor imageDescriptor = getCPListElementBaseImage(cpentry);
if (imageDescriptor != null) {
if (cpentry.isMissing()) {
@ -256,7 +236,7 @@ class CPElementLabelProvider extends LabelProvider {
return fRegistry.get(imageDescriptor);
}
} else if (element instanceof CPElementAttribute) {
String key = ((CPElementAttribute) element).getKey();
String key = ((CPElementAttribute)element).getKey();
if (key.equals(CPElement.SOURCEATTACHMENT)) {
// return
// fRegistry.get(CPluginImages.DESC_OBJS_SOURCE_ATTACH_ATTRIB);
@ -264,7 +244,7 @@ class CPElementLabelProvider extends LabelProvider {
return CPluginImages.get(CPluginImages.IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
}
} else if (element instanceof IPathEntry) {
return getImage(CPElement.createFromExisting((IPathEntry) element, null));
return getImage(CPElement.createFromExisting((IPathEntry)element, null));
}
return null;
}

View file

@ -1,11 +1,10 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -1,14 +1,15 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import org.eclipse.cdt.core.model.IPathEntry;
@ -17,21 +18,29 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.wizards.ICPathContainerPage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Image;
public class CPathContainerDescriptor implements IContainerDescriptor {
private IConfigurationElement fConfigElement;
private static final String ATT_EXTENSION = "PathContainerPage"; //$NON-NLS-1$
private static final String ATT_ID = "id"; //$NON-NLS-1$
private static final String ATT_NAME = "name"; //$NON-NLS-1$
private static final String ATT_ICON = "icon"; //$NON-NLS-1$
private static final String ATT_PAGE_CLASS = "class"; //$NON-NLS-1$
private Image pageImage;
public CPathContainerDescriptor(IConfigurationElement configElement) throws CoreException {
super();
fConfigElement = configElement;
@ -41,30 +50,63 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
String pageClassName = configElement.getAttribute(ATT_PAGE_CLASS);
if (name == null) {
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "Invalid extension (missing name): " + id, null)); //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "Invalid extension (missing name): " + id, //$NON-NLS-1$
null));
}
if (pageClassName == null) {
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "Invalid extension (missing page class name): " + id, null)); //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
"Invalid extension (missing page class name): " + id, null)); //$NON-NLS-1$
}
}
public ICPathContainerPage createPage() throws CoreException {
Object elem= CoreUtility.createExtension(fConfigElement, ATT_PAGE_CLASS);
Object elem = CoreUtility.createExtension(fConfigElement, ATT_PAGE_CLASS);
if (elem instanceof ICPathContainerPage) {
return (ICPathContainerPage) elem;
} else {
String id= fConfigElement.getAttribute(ATT_ID);
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "Invalid extension (page not of type IClasspathContainerPage): " + id, null)); //$NON-NLS-1$
String id = fConfigElement.getAttribute(ATT_ID);
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
"Invalid extension (page not of type IClasspathContainerPage): " + id, null)); //$NON-NLS-1$
}
}
public String getName() {
return fConfigElement.getAttribute(ATT_NAME);
}
public Image getImage() {
if (pageImage == null) {
String imageName = fConfigElement.getAttribute(ATT_ICON);
if (imageName != null) {
IExtension extension = fConfigElement.getDeclaringExtension();
IPluginDescriptor pd = extension.getDeclaringPluginDescriptor();
Image image = getImageFromPlugin(pd, imageName);
pageImage = image;
}
}
return pageImage;
}
public Image getImageFromPlugin(IPluginDescriptor pluginDescriptor, String subdirectoryAndFilename) {
URL installURL = pluginDescriptor.getInstallURL();
return getImageFromURL(installURL, subdirectoryAndFilename);
}
public Image getImageFromURL(URL installURL, String subdirectoryAndFilename) {
Image image = null;
try {
URL newURL = new URL(installURL, subdirectoryAndFilename);
ImageDescriptor desc = ImageDescriptor.createFromURL(newURL);
image = desc.createImage();
} catch (MalformedURLException e) {
} catch (SWTException e) {
}
return image;
}
public String getPageClass() {
return fConfigElement.getAttribute(ATT_PAGE_CLASS);
}
}
public boolean canEdit(IPathEntry entry) {
String id = fConfigElement.getAttribute(ATT_ID);
@ -76,19 +118,19 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
}
public static IContainerDescriptor[] getDescriptors() {
ArrayList containers= new ArrayList();
ArrayList containers = new ArrayList();
IExtensionPoint extensionPoint = Platform.getPluginRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, ATT_EXTENSION);
if (extensionPoint != null) {
IContainerDescriptor defaultPage= null;
String defaultPageName= CPathContainerDefaultPage.class.getName();
IContainerDescriptor defaultPage = null;
String defaultPageName = CPathContainerDefaultPage.class.getName();
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
for (int i = 0; i < elements.length; i++) {
try {
CPathContainerDescriptor curr= new CPathContainerDescriptor(elements[i]);
CPathContainerDescriptor curr = new CPathContainerDescriptor(elements[i]);
if (defaultPageName.equals(curr.getPageClass())) {
defaultPage= curr;
defaultPage = curr;
} else {
containers.add(curr);
}
@ -104,4 +146,4 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
return (CPathContainerDescriptor[]) containers.toArray(new CPathContainerDescriptor[containers.size()]);
}
}
}

View file

@ -1,11 +1,10 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
@ -22,11 +21,12 @@ import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
/**
@ -37,16 +37,27 @@ public class CPathContainerSelectionPage extends WizardPage {
private static final String DIALOGSTORE_CONTAINER_IDX= "index"; //$NON-NLS-1$
private static class ClasspathContainerLabelProvider extends LabelProvider {
private static class CPathContainerLabelProvider extends LabelProvider {
public String getText(Object element) {
return ((IContainerDescriptor) element).getName();
}
public Image getImage(Object element) {
return ((IContainerDescriptor) element).getImage();
}
}
private static class ClasspathContainerSorter extends ViewerSorter {
private static class CPathContainerSorter extends ViewerSorter {
public int category(Object element) {
if ( element instanceof ProjectContainerDescriptor) {
return 0;
}
return 1;
}
}
private ListViewer fListViewer;
private TableViewer fListViewer;
private IContainerDescriptor[] fContainers;
private IDialogSettings fDialogSettings;
@ -75,10 +86,10 @@ public class CPathContainerSelectionPage extends WizardPage {
* @see IDialogPage#createControl(Composite)
*/
public void createControl(Composite parent) {
fListViewer= new ListViewer(parent, SWT.SINGLE | SWT.BORDER);
fListViewer.setLabelProvider(new ClasspathContainerLabelProvider());
fListViewer= new TableViewer(parent, SWT.SINGLE | SWT.BORDER);
fListViewer.setLabelProvider(new CPathContainerLabelProvider());
fListViewer.setContentProvider(new ListContentProvider());
fListViewer.setSorter(new ClasspathContainerSorter());
fListViewer.setSorter(new CPathContainerSorter());
fListViewer.setInput(Arrays.asList(fContainers));
fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
@ -95,10 +106,10 @@ public class CPathContainerSelectionPage extends WizardPage {
if (selectionIndex >= fContainers.length) {
selectionIndex= 0;
}
fListViewer.getList().select(selectionIndex);
fListViewer.getTable().select(selectionIndex);
validatePage();
setControl(fListViewer.getList());
Dialog.applyDialogFont(fListViewer.getList());
setControl(fListViewer.getTable());
Dialog.applyDialogFont(fListViewer.getTable());
}
/**
@ -135,7 +146,7 @@ public class CPathContainerSelectionPage extends WizardPage {
*/
public void setVisible(boolean visible) {
if (!visible && fListViewer != null) {
fDialogSettings.put(DIALOGSTORE_CONTAINER_IDX, fListViewer.getList().getSelectionIndex());
fDialogSettings.put(DIALOGSTORE_CONTAINER_IDX, fListViewer.getTable().getSelectionIndex());
}
super.setVisible(visible);
}

View file

@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation 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
* 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: IBM Corporation - initial API and implementation
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
@ -12,7 +12,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
import org.eclipse.cdt.internal.ui.util.PixelConverter;
@ -33,8 +33,8 @@ public class CPathContainerWizard extends Wizard {
private IPathEntry[] fNewEntries;
private IPathEntry[] fContainerEntries;
private ICPathContainerPage fContainerPage;
private ICProject fCurrProject;
private IPathEntry[] fCurrClasspath;
private ICElement fCurrElement;
private IPathEntry[] fCurrCPath;
private CPathFilterPage fFilterPage;
private CPathContainerSelectionPage fSelectionWizardPage;
@ -43,26 +43,26 @@ public class CPathContainerWizard extends Wizard {
/**
* Constructor for ClasspathContainerWizard.
*/
public CPathContainerWizard(IPathEntry entryToEdit, ICProject currProject, IPathEntry[] currEntries) {
this(entryToEdit, null, currProject, currEntries, -1);
public CPathContainerWizard(IPathEntry entryToEdit, ICElement currElement, IPathEntry[] currEntries) {
this(entryToEdit, null, currElement, currEntries, -1);
}
/**
* Constructor for ClasspathContainerWizard.
*/
public CPathContainerWizard(IContainerDescriptor pageDesc, ICProject currProject, IPathEntry[] currEntries) {
this(null, pageDesc, currProject, currEntries, -1);
public CPathContainerWizard(IContainerDescriptor pageDesc, ICElement currElement, IPathEntry[] currEntries) {
this(null, pageDesc, currElement, currEntries, -1);
}
public CPathContainerWizard(IPathEntry entryToEdit, IContainerDescriptor pageDesc, ICProject currProject,
public CPathContainerWizard(IPathEntry entryToEdit, IContainerDescriptor pageDesc, ICElement currElement,
IPathEntry[] currEntries, int filterType) {
fEntryToEdit = entryToEdit;
fPageDesc = pageDesc;
fNewEntries = null;
fFilterType = filterType;
fCurrProject = currProject;
fCurrClasspath = currEntries;
fCurrElement = currElement;
fCurrCPath = currEntries;
}
public IPathEntry getEntriesParent() {
@ -85,10 +85,9 @@ public class CPathContainerWizard extends Wizard {
public boolean performFinish() {
if (fContainerPage != null) {
if (fContainerPage.finish()) {
fContainerEntries = fContainerPage.getContainerEntries();
if (fFilterType != -1 && fFilterPage.isPageComplete()) {
fNewEntries = fFilterPage.getSelectedEntries();
} else {
fContainerEntries = fContainerPage.getContainerEntries();
}
return true;
}
@ -126,7 +125,8 @@ public class CPathContainerWizard extends Wizard {
addPage(fContainerPage);
}
if (fFilterType != -1) {
fFilterPage = new CPathFilterPage(fCurrProject, fFilterType);
fFilterPage = new CPathFilterPage(fCurrElement, fFilterType);
addPage(fFilterPage);
}
super.addPages();
}
@ -144,7 +144,7 @@ public class CPathContainerWizard extends Wizard {
if (containerPage == null) {
containerPage = new CPathContainerDefaultPage();
}
containerPage.initialize(fCurrProject, fCurrClasspath);
containerPage.initialize(fCurrElement.getCProject(), fCurrCPath);
containerPage.setSelection(fEntryToEdit);
containerPage.setWizard(this);
return containerPage;
@ -162,9 +162,10 @@ public class CPathContainerWizard extends Wizard {
fContainerPage = getContainerPage(selected);
return fContainerPage;
} else if (page == fContainerPage) {
if ( fContainerPage.getContainerEntries().length > 0 ) {
if ( fContainerPage.getContainerEntries().length > 0 && fContainerPage.getContainerEntries()[0] != null) {
fFilterPage.setParentEntry(fContainerPage.getContainerEntries()[0]);
}
return fFilterPage;
}
return super.getNextPage(page);
}

View file

@ -1,11 +1,10 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -17,10 +17,40 @@ CPathsPropertyPage.unsavedchanges.button.save=Apply
CPathsPropertyPage.unsavedchanges.button.discard=Discard
CPathsPropertyPage.unsavedchanges.button.ignore=Apply Later
BuildPathsBlock.tab.libraries=&Libraries
ProjectContainer.label=Project Path Entries
# ------- CPathFilterPage-------
CPathFilterPage.title=Container Paths
CPathFilterPage.description=Select path which are to be contributed to the project.
CPathFilterPage.label=C/C++ Container path:
# ------- CPathContainerSelectionPage-------
CPathContainerSelectionPage.title=Add Contributed
CPathContainerSelectionPage.description=Select the library type to add.
# ------- CPathContainerWizard-------
CPathContainerWizard.pagecreationerror.title= Library Wizard
CPathContainerWizard.pagecreationerror.message=Wizard page creation failed. Check log for details.
# ------- CPathContainerDefaultPage-------
CPathContainerDefaultPage.title=C/C++ Path Container
CPathContainerDefaultPage.description=Edit the C/C++ container path. First segment is the container type.
CPathContainerDefaultPage.path.label=&C/C++ path container path:
CPathContainerDefaultPage.path.error.enterpath=Enter path.
CPathContainerDefaultPage.path.error.invalidpath=Invalid path.
CPathContainerDefaultPage.path.error.needssegment=Path needs at least one segment.
CPathContainerDefaultPage.path.error.alreadyexists=Entry already exists.
# -------- ProjectContainerPage ---------
ProjectContainer.label=C/C++ Project Path Entries
ProjectContainerPage.title=C/C++ Project Path Entries
ProjectContainerPage.description=Select the C/C++ Project which contains path entries to be contributed to this project.
ProjectContainerPage.label=C/C++ Projects:
# -------- ExtendingCPathBasePage ---------
ExtendingCPathBasePage.editSourcePaths=Edit Source Paths...
@ -50,6 +80,10 @@ IncludeEntryPage.addExternal.title=Add External Include Path
IncludeEntryPage.addExternal.message=Include path:
IncludeEntryPage.ContainerDialog.new.title=Contributed Include Path Selection
IncludeEntryPage.ContainerDialog.edit.title=Contributed Include Path Selection
IncludeEntryPage.fromWorkspaceDialog.new.title=New Include Path from Workspace
IncludeEntryPage.fromWorkspaceDialog.new.description=Select a folder as a include path from the workspace.
IncludeEntryPage.fromWorkspaceDialog.edit.title=Edit Include Path from Workspace
IncludeEntryPage.fromWorkspaceDialog.edit.description=Select a folder as a include path from the workspace.
# ------- BuildPathsBlock -------
CPathsBlock.path.up.button=&Up
@ -180,8 +214,6 @@ ExclusionPatternEntryDialog.ChooseExclusionPattern.description=&Choose a folder
# ------- CPListLabelProvider -------
CPListLabelProvider.new=(new)
CPListLabelProvider.classcontainer=(class folder)
CPListLabelProvider.twopart={0} - {1}
CPListLabelProvider.willbecreated=(will be created)
CPListLabelProvider.none=(None)
CPListLabelProvider.source_attachment.label=Source attachment:

View file

@ -1,11 +1,11 @@
/*
* Created on Apr 26, 2004
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
/*******************************************************************************
* 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
***********************************************************************/
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.util.Arrays;
@ -13,9 +13,11 @@ import java.util.List;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.IPathEntryContainer;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IProject;
@ -23,9 +25,6 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@ -33,21 +32,24 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
public class CPathFilterPage extends WizardPage {
private final int fFilterType;
private CheckboxTableViewer viewer;
private IPathEntry fParentEntry;
private List fPaths;
private ICProject fCProject;
protected CPathFilterPage(ICProject cProject, int filterType) {
private ICElement fCElement;
protected CPathFilterPage(ICElement cElement, int filterType) {
super("CPathFilterPage"); //$NON-NLS-1$
setTitle(CPathEntryMessages.getString("CPathFilterPage.title")); //$NON-NLS-1$
setDescription(CPathEntryMessages.getString("CPathFilterPage.description")); //$NON-NLS-1$
setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
fFilterType = filterType;
fCProject = cProject;
fCElement = cElement;
validatePage();
}
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
@ -59,21 +61,13 @@ public class CPathFilterPage extends WizardPage {
GridData gd = new GridData();
gd.horizontalSpan = 2;
label.setLayoutData(gd);
viewer =
CheckboxTableViewer.newCheckList(
container,
SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
viewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
viewer.setContentProvider(new ListContentProvider());
viewer.setLabelProvider(new CPElementLabelProvider());
viewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
// Prevent user to change checkbox states
viewer.setChecked(event.getElement(), !event.getChecked());
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent e) {
handleSelectionChanged((IStructuredSelection) e.getSelection());
validatePage();
}
});
viewer.addFilter(new CPElementFilter(fFilterType, true));
@ -84,14 +78,12 @@ public class CPathFilterPage extends WizardPage {
setControl(container);
Dialog.applyDialogFont(container);
}
public void setVisible(boolean visible) {
if (fPaths != null) {
viewer.setInput(fPaths);
}
}
protected void handleSelectionChanged(IStructuredSelection selection) {
super.setVisible(visible);
}
public void setParentEntry(IPathEntry entry) {
@ -107,15 +99,28 @@ public class CPathFilterPage extends WizardPage {
}
} else if (fParentEntry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
try {
IPathEntryContainer container = CoreModel.getPathEntryContainer(fParentEntry.getPath(), fCProject);
IPathEntryContainer container = CoreModel.getPathEntryContainer(fParentEntry.getPath(), fCElement.getCProject());
fPaths = Arrays.asList(container.getPathEntries());
} catch (CModelException e) {
}
}
}
public IPathEntry[] getSelectedEntries() {
return (IPathEntry[]) viewer.getCheckedElements();
/**
* Method validatePage.
*/
private void validatePage() {
setPageComplete(getSelectedEntries().length > 0);
}
}
public IPathEntry[] getSelectedEntries() {
if (viewer != null) {
Object[] paths = viewer.getCheckedElements();
IPathEntry[] entries = new IPathEntry[paths.length];
System.arraycopy(paths, 0, entries, 0, entries.length);
return entries;
}
return new IPathEntry[0];
}
}

View file

@ -1,11 +1,11 @@
/*
* Created on Apr 26, 2004
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
/*******************************************************************************
* 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
***********************************************************************/
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import org.eclipse.jface.wizard.Wizard;

View file

@ -1,11 +1,10 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
@ -51,7 +50,7 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
private static final int IDX_EDIT = 4;
private static final int IDX_REMOVE = 5;
private static final String[] buttonLabel = new String[] {
private static final String[] buttonLabel = new String[]{
/* 0 */CPathEntryMessages.getString("IncludeEntryPage.addExternal"), //$NON-NLS-1$
/* 1 */CPathEntryMessages.getString("IncludeEntryPage.addFromWorkspace"), //$NON-NLS-1$
/* 2 */CPathEntryMessages.getString("IncludeEntryPage.addContributed"), null, //$NON-NLS-1$
@ -65,23 +64,23 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
protected void buttonPressed(int indx, List selected) {
switch (indx) {
case IDX_ADD_USER:
case IDX_ADD_USER :
addInclude();
break;
case IDX_ADD_WORKSPACE:
case IDX_ADD_WORKSPACE :
addFromWorkspace();
break;
case IDX_ADD_CONTRIBUTED:
case IDX_ADD_CONTRIBUTED :
addContributed();
break;
case IDX_EDIT:
case IDX_EDIT :
if (canEdit(selected)) {
editInclude((CPElement) selected.get(0));
editInclude((CPElement)selected.get(0));
}
break;
case IDX_REMOVE:
case IDX_REMOVE :
if (canRemove(selected)) {
removeInclude((CPElement) selected.get(0));
removeInclude((CPElement)selected.get(0));
}
break;
}
@ -109,7 +108,7 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
protected boolean canEdit(List selected) {
if (!selected.isEmpty()) {
return !isPathInheritedFromSelected((CPElement) selected.get(0));
return !isPathInheritedFromSelected((CPElement)selected.get(0));
}
return false;
}
@ -130,7 +129,7 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
newItem = dialog.getValue();
if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$
List cplist = getPathList().getElements();
ICElement element = (ICElement) getSelection().get(0);
ICElement element = (ICElement)getSelection().get(0);
CPElement newPath = new CPElement(element.getCProject(), IPathEntry.CDT_INCLUDE, element.getPath(),
element.getResource());
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
@ -166,7 +165,7 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
}
protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
Class[] acceptedClasses = new Class[] { ICProject.class, IProject.class, IContainer.class, ICContainer.class};
Class[] acceptedClasses = new Class[]{ICProject.class, IProject.class, IContainer.class, ICContainer.class};
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
@ -191,16 +190,16 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
CPElement[] res = new CPElement[elements.length];
ICElement element = (ICElement) getSelection().get(0);
ICElement element = (ICElement)getSelection().get(0);
for (int i = 0; i < res.length; i++) {
IProject project;
IPath includePath;
if (elements[i] instanceof IResource) {
project = ((IResource) elements[i]).getProject();
includePath = ((IResource) elements[i]).getProjectRelativePath();
project = ((IResource)elements[i]).getProject();
includePath = ((IResource)elements[i]).getProjectRelativePath();
} else {
project = ((ICElement) elements[i]).getCProject().getProject();
includePath = ((ICElement) elements[i]).getResource().getProjectRelativePath();
project = ((ICElement)elements[i]).getCProject().getProject();
includePath = ((ICElement)elements[i]).getResource().getProjectRelativePath();
}
res[i] = new CPElement(element.getCProject(), IPathEntry.CDT_INCLUDE, element.getPath(), element.getResource());
res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative());
@ -220,12 +219,13 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
title = CPathEntryMessages.getString("IncludeEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
elem = existing.getPathEntry();
}
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawClasspath(), IPathEntry.CDT_INCLUDE);
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, (ICElement)getSelection().get(0), getRawClasspath(),
IPathEntry.CDT_INCLUDE);
wizard.setWindowTitle(title);
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
IPathEntry parent = wizard.getEntriesParent();
IPathEntry[] elements = wizard.getEntries();
IResource resource = ((ICElement) getSelection().get(0)).getResource();
IResource resource = ((ICElement)getSelection().get(0)).getResource();
if (elements != null) {
CPElement[] res = new CPElement[elements.length];

View file

@ -1,11 +1,10 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
@ -47,15 +46,16 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
addSymbol();
break;
case IDX_ADD_CONTRIBUTED :
addContributed();
break;
case IDX_EDIT :
if (canEdit(selected)) {
editSymbol((CPElement) selected.get(0));
editSymbol((CPElement)selected.get(0));
}
break;
case IDX_REMOVE :
if (canRemove(selected)) {
removeSymbol((CPElement) selected.get(0));
removeSymbol((CPElement)selected.get(0));
}
break;
}
@ -73,7 +73,7 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
protected boolean canEdit(List selected) {
if (!selected.isEmpty()) {
return !isPathInheritedFromSelected((CPElement) selected.get(0));
return !isPathInheritedFromSelected((CPElement)selected.get(0));
}
return false;
}
@ -105,7 +105,7 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
symbol = dialog.getValue();
if (symbol != null && symbol.length() > 0) {
List cplist = getPathList().getElements();
IResource resource = ((ICElement) getSelection().get(0)).getResource();
IResource resource = ((ICElement)getSelection().get(0)).getResource();
CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, resource.getFullPath(), resource);
String name, value = ""; //$NON-NLS-1$
int index = symbol.indexOf("="); //$NON-NLS-1$
@ -156,17 +156,18 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
title = CPathEntryMessages.getString("SymbolEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
elem = existing.getPathEntry();
}
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawClasspath(), IPathEntry.CDT_INCLUDE);
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, (ICElement)getSelection().get(0), getRawClasspath(),
IPathEntry.CDT_MACRO);
wizard.setWindowTitle(title);
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
IPathEntry parent = wizard.getEntriesParent();
IPathEntry[] elements = wizard.getEntries();
IResource resource = ((ICElement) getSelection().get(0)).getResource();
IResource resource = ((ICElement)getSelection().get(0)).getResource();
if (elements != null) {
CPElement[] res = new CPElement[elements.length];
for (int i = 0; i < res.length; i++) {
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, resource.getFullPath(), resource);
res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry)elements[i]).getMacroName());
res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry)elements[i]).getMacroName());
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
}
return res;

View file

@ -1,13 +1,11 @@
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation 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
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.util.ArrayList;

View file

@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation 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
* 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: IBM Corporation - initial API and implementation
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -1,11 +1,10 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -1,20 +1,22 @@
/*
* Created on Apr 27, 2004
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
/*******************************************************************************
* 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
***********************************************************************/
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.ui.wizards.ICPathContainerPage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
public interface IContainerDescriptor {
public abstract ICPathContainerPage createPage() throws CoreException;
public abstract String getName();
public abstract boolean canEdit(IPathEntry entry);
public ICPathContainerPage createPage() throws CoreException;
public String getName();
public Image getImage();
public boolean canEdit(IPathEntry entry);
}

View file

@ -1,11 +1,10 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -1,11 +1,10 @@
/*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
* 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
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation 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
* 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: IBM Corporation - initial API and implementation
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation 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
* 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: IBM Corporation - initial API and implementation
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -1,16 +1,19 @@
/*
* Created on Apr 27, 2004
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
/*******************************************************************************
* 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
***********************************************************************/
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.wizards.ICPathContainerPage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ide.IDE;
public class ProjectContainerDescriptor implements IContainerDescriptor {
private int fFilterType;
@ -26,6 +29,11 @@ public class ProjectContainerDescriptor implements IContainerDescriptor {
public String getName() {
return CPathEntryMessages.getString("ProjectContainer.label"); //$NON-NLS-1$
}
public Image getImage() {
return CUIPlugin.getDefault().getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT);
}
public boolean canEdit(IPathEntry entry) {
return false;

View file

@ -1,25 +1,30 @@
/***********************************************************************************************************************************
* Created on Apr 27, 2004
/*******************************************************************************
* 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
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
*
* Contributors: QNX Software Systems - Initial API and implementation
**********************************************************************************************************************************/
* Contributors: QNX Software Systems - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.util.SelectionUtil;
import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
import org.eclipse.cdt.ui.wizards.ICPathContainerPage;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.WizardPage;
@ -28,60 +33,14 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
public class ProjectContainerPage extends WizardPage implements ICPathContainerPage {
private int fFilterType;
private CheckboxTableViewer viewer;
private TableViewer viewer;
private ICProject fCProject;
private class WorkbenchCPathContentProvider extends WorkbenchContentProvider {
public Object[] getChildren(Object element) {
if (element instanceof ICProject) {
try {
IPathEntry[] entries = ((ICProject) element).getRawPathEntries();
List list = new ArrayList(entries.length);
for (int i = 0; i < entries.length; i++) {
if (fFilterType == entries[i].getEntryKind() && entries[i].isExported()) {
list.add(CPElement.createFromExisting(entries[i], (ICProject) element));
}
}
return list.toArray();
} catch (CModelException e) {
CUIPlugin.getDefault().log(e);
return new Object[0];
}
}
return super.getChildren(element);
}
public boolean hasChildren(Object element) {
if (element instanceof ICProject) {
try {
IPathEntry[] entries = ((ICProject) element).getRawPathEntries();
for (int i = 0; i < entries.length; i++) {
if (fFilterType == entries[i].getEntryKind() && entries[i].isExported()) {
return true;
}
}
} catch (CModelException e) {
CUIPlugin.getDefault().log(e);
return false;
}
}
return super.hasChildren(element);
}
public Object getParent(Object element) {
if (element instanceof CPElement) {
return ((CPElement) element).getCProject().getProject();
}
return super.getParent(element);
}
}
protected ProjectContainerPage(int filterType) {
super("projectContainerPage"); //$NON-NLS-1$
setTitle(CPathEntryMessages.getString("ProjectContainerPage.title")); //$NON-NLS-1$
@ -100,9 +59,16 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
}
public IPathEntry[] getContainerEntries() {
return /*viewer != null ? (IPathEntry[]) viewer.getCheckedElements(): */new IPathEntry[0];
}
if (viewer != null) {
ISelection selection = viewer.getSelection();
ICProject project = (ICProject)SelectionUtil.getSingleElement(selection);
if (project != null) {
return new IPathEntry[]{CoreModel.newProjectEntry(project.getPath())};
}
}
return new IPathEntry[0];
}
public void setSelection(IPathEntry containerEntry) {
if (containerEntry != null) {
viewer.setSelection(new StructuredSelection(containerEntry));
@ -120,12 +86,13 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
GridData gd = new GridData();
gd.horizontalSpan = 2;
label.setLayoutData(gd);
viewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
viewer.setContentProvider(new WorkbenchCPathContentProvider());
viewer.setLabelProvider(new CPElementLabelProvider());
viewer.addCheckStateListener(new ICheckStateListener() {
viewer = new TableViewer(container, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
public void checkStateChanged(CheckStateChangedEvent event) {
viewer.setContentProvider(new ListContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
validatePage();
}
});
@ -136,13 +103,36 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
viewer.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
return true;
return !element.equals(fCProject);
}
});
setControl(container);
initializeView();
validatePage();
}
private void initializeView() {
List list = new ArrayList();
List current;
try {
current = Arrays.asList(fCProject.getRawPathEntries());
ICProject[] cProjects = CoreModel.getDefault().getCModel().getCProjects();
for (int i = 0; i < cProjects.length; i++) {
if (!cProjects[i].equals(fCProject) && !current.contains(CoreModel.newProjectEntry(cProjects[i].getPath()))) {
IPathEntry[] projEntries = cProjects[i].getRawPathEntries();
for (int j = 0; j < projEntries.length; j++) {
if (projEntries[j].getEntryKind() == fFilterType && projEntries[j].isExported()) {
list.add(cProjects[i]);
break;
}
}
}
}
} catch (CModelException e) {
}
viewer.setInput(list);
}
/**
* Method validatePage.
*/