1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +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 * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which accompanies * the Common Public License v1.0 which accompanies this distribution, and is
* this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -510,7 +510,7 @@ public class CPElement {
elem.setAttribute(BASE, base); elem.setAttribute(BASE, base);
elem.setExported(curr.isExported()); elem.setExported(curr.isExported());
if (project.exists()) { if (project != null && project.exists()) {
elem.setIsMissing(isMissing); elem.setIsMissing(isMissing);
} }
return elem; 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.util.Arrays; import java.util.Arrays;
@ -11,8 +19,8 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerFilter;
/** /**
* Viewer filter for archive selection dialogs. Archives are files with file * Viewer filter for archive selection dialogs. Archives are files with file extension '.so', '.dll' and '.a'. The filter is not
* extension '.so', '.dll' and '.a'. The filter is not case sensitive. * case sensitive.
*/ */
public class CPElementFilter extends ViewerFilter { public class CPElementFilter extends ViewerFilter {
@ -22,8 +30,7 @@ public class CPElementFilter extends ViewerFilter {
/** /**
* @param excludedFiles * @param excludedFiles
* Excluded paths will not pass the filter. <code>null</code> is * Excluded paths will not pass the filter. <code>null</code> is allowed if no files should be excluded.
* allowed if no files should be excluded.
* @param recusive * @param recusive
* Folders are only shown if, searched recursivly, contain an archive * Folders are only shown if, searched recursivly, contain an archive
*/ */
@ -39,15 +46,14 @@ public class CPElementFilter extends ViewerFilter {
this(null, kind, exportedOnly); this(null, kind, exportedOnly);
} }
/* /*
* @see ViewerFilter#select * @see ViewerFilter#select
*/ */
public boolean select(Viewer viewer, Object parent, Object element) { public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof CPElement) { if (element instanceof CPElement) {
if (((CPElement) element).getEntryKind() == fKind) { if ( ((CPElement) element).getEntryKind() == fKind) {
if (fExcludes != null && !fExcludes.contains(element)) { if (fExcludes != null && !fExcludes.contains(element)) {
if (fExportedOnly == true && !((CPElement) element).isExported()) { if (fExportedOnly == true && ! ((CPElement) element).isExported()) {
return false; return false;
} }
return true; 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.internal.ui.util.ImageDescriptorRegistry;
import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -29,7 +28,7 @@ import org.eclipse.ui.ide.IDE;
class CPElementLabelProvider extends LabelProvider { class CPElementLabelProvider extends LabelProvider {
private String fNewLabel, fClassLabel, fCreateLabel; private String fNewLabel, fCreateLabel;
private ImageDescriptor fIncludeIcon, fMacroIcon, fLibWSrcIcon, fLibIcon, fExtLibIcon, fExtLibWSrcIcon; private ImageDescriptor fIncludeIcon, fMacroIcon, fLibWSrcIcon, fLibIcon, fExtLibIcon, fExtLibWSrcIcon;
private ImageDescriptor fFolderImage, fOutputImage, fProjectImage, fContainerImage; private ImageDescriptor fFolderImage, fOutputImage, fProjectImage, fContainerImage;
@ -37,7 +36,6 @@ class CPElementLabelProvider extends LabelProvider {
public CPElementLabelProvider() { public CPElementLabelProvider() {
fNewLabel = CPathEntryMessages.getString("CPListLabelProvider.new"); //$NON-NLS-1$ fNewLabel = CPathEntryMessages.getString("CPListLabelProvider.new"); //$NON-NLS-1$
fClassLabel = CPathEntryMessages.getString("CPListLabelProvider.classcontainer"); //$NON-NLS-1$
fCreateLabel = CPathEntryMessages.getString("CPListLabelProvider.willbecreated"); //$NON-NLS-1$ fCreateLabel = CPathEntryMessages.getString("CPListLabelProvider.willbecreated"); //$NON-NLS-1$
fRegistry = CUIPlugin.getImageDescriptorRegistry(); fRegistry = CUIPlugin.getImageDescriptorRegistry();
@ -56,11 +54,11 @@ class CPElementLabelProvider extends LabelProvider {
public String getText(Object element) { public String getText(Object element) {
if (element instanceof CPElement) { if (element instanceof CPElement) {
return getCPListElementText((CPElement) element); return getCPListElementText((CPElement)element);
} else if (element instanceof CPElementAttribute) { } else if (element instanceof CPElementAttribute) {
return getCPListElementAttributeText((CPElementAttribute) element); return getCPListElementAttributeText((CPElementAttribute)element);
} else if (element instanceof IPathEntry) { } else if (element instanceof IPathEntry) {
return getCPListElementText(CPElement.createFromExisting((IPathEntry) element, null)); return getCPListElementText(CPElement.createFromExisting((IPathEntry)element, null));
} }
return super.getText(element); return super.getText(element);
} }
@ -71,7 +69,7 @@ class CPElementLabelProvider extends LabelProvider {
String key = attrib.getKey(); String key = attrib.getKey();
if (key.equals(CPElement.SOURCEATTACHMENT)) { if (key.equals(CPElement.SOURCEATTACHMENT)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.source_attachment.label")); //$NON-NLS-1$ buf.append(CPathEntryMessages.getString("CPListLabelProvider.source_attachment.label")); //$NON-NLS-1$
IPath path = (IPath) attrib.getValue(); IPath path = (IPath)attrib.getValue();
if (path != null && !path.isEmpty()) { if (path != null && !path.isEmpty()) {
buf.append(getPathString(path, path.getDevice() != null)); buf.append(getPathString(path, path.getDevice() != null));
} else { } else {
@ -79,7 +77,7 @@ class CPElementLabelProvider extends LabelProvider {
} }
} else if (key.equals(CPElement.SOURCEATTACHMENTROOT)) { } else if (key.equals(CPElement.SOURCEATTACHMENTROOT)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.source_attachment_root.label")); //$NON-NLS-1$ buf.append(CPathEntryMessages.getString("CPListLabelProvider.source_attachment_root.label")); //$NON-NLS-1$
IPath path = (IPath) attrib.getValue(); IPath path = (IPath)attrib.getValue();
if (path != null && !path.isEmpty()) { if (path != null && !path.isEmpty()) {
buf.append(path.toString()); buf.append(path.toString());
} else { } else {
@ -88,7 +86,7 @@ class CPElementLabelProvider extends LabelProvider {
} }
if (key.equals(CPElement.EXCLUSION)) { if (key.equals(CPElement.EXCLUSION)) {
buf.append(CPathEntryMessages.getString("CPListLabelProvider.exclusion_filter.label")); //$NON-NLS-1$ buf.append(CPathEntryMessages.getString("CPListLabelProvider.exclusion_filter.label")); //$NON-NLS-1$
IPath[] patterns = (IPath[]) attrib.getValue(); IPath[] patterns = (IPath[])attrib.getValue();
if (patterns != null && patterns.length > 0) { if (patterns != null && patterns.length > 0) {
for (int i = 0; i < patterns.length; i++) { for (int i = 0; i < patterns.length; i++) {
if (i > 0) { if (i > 0) {
@ -106,47 +104,29 @@ class CPElementLabelProvider extends LabelProvider {
public String getCPListElementText(CPElement cpentry) { public String getCPListElementText(CPElement cpentry) {
IPath path = cpentry.getPath(); IPath path = cpentry.getPath();
switch (cpentry.getEntryKind()) { switch (cpentry.getEntryKind()) {
case IPathEntry.CDT_LIBRARY: 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(); return path.makeRelative().toString();
} case IPathEntry.CDT_PROJECT :
case IPathEntry.CDT_PROJECT:
return path.lastSegment(); return path.lastSegment();
case IPathEntry.CDT_INCLUDE: case IPathEntry.CDT_INCLUDE :
{ {
StringBuffer str = new StringBuffer(((IPath) cpentry.getAttribute(CPElement.INCLUDE)).toOSString()); StringBuffer str = new StringBuffer( ((IPath)cpentry.getAttribute(CPElement.INCLUDE)).toOSString());
IPath base = (IPath) cpentry.getAttribute(CPElement.BASE_REF); IPath base = (IPath)cpentry.getAttribute(CPElement.BASE_REF);
if (!base.isEmpty()) { if (!base.isEmpty()) {
str.append(" - ("); //$NON-NLS-1$ str.append(" - ("); //$NON-NLS-1$
str.append(base); str.append(base);
str.append(')'); str.append(')');
} else { } else {
path = ((IPath) cpentry.getAttribute(CPElement.BASE)).addTrailingSeparator(); path = ((IPath)cpentry.getAttribute(CPElement.BASE)).addTrailingSeparator();
str.insert(0, path.toOSString()); str.insert(0, path.toOSString());
} }
return str.toString(); return str.toString();
} }
case IPathEntry.CDT_MACRO: case IPathEntry.CDT_MACRO :
{ {
StringBuffer str = new StringBuffer((String) cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$ StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
+ (String) cpentry.getAttribute(CPElement.MACRO_VALUE)); + (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
IPath base = (IPath) cpentry.getAttribute(CPElement.BASE_REF); IPath base = (IPath)cpentry.getAttribute(CPElement.BASE_REF);
if (!base.isEmpty()) { if (!base.isEmpty()) {
str.append('('); str.append('(');
str.append(base); str.append(base);
@ -154,7 +134,7 @@ class CPElementLabelProvider extends LabelProvider {
} }
return str.toString(); return str.toString();
} }
case IPathEntry.CDT_CONTAINER: case IPathEntry.CDT_CONTAINER :
try { try {
IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject()); IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
if (container != null) { if (container != null) {
@ -163,8 +143,8 @@ class CPElementLabelProvider extends LabelProvider {
} catch (CModelException e) { } catch (CModelException e) {
} }
return path.toString(); return path.toString();
case IPathEntry.CDT_SOURCE: case IPathEntry.CDT_SOURCE :
case IPathEntry.CDT_OUTPUT: case IPathEntry.CDT_OUTPUT :
{ {
StringBuffer buf = new StringBuffer(path.makeRelative().toString()); StringBuffer buf = new StringBuffer(path.makeRelative().toString());
IResource resource = cpentry.getResource(); IResource resource = cpentry.getResource();
@ -178,7 +158,7 @@ class CPElementLabelProvider extends LabelProvider {
} }
return buf.toString(); return buf.toString();
} }
default: default :
// pass // pass
} }
return CPathEntryMessages.getString("CPListLabelProvider.unknown_element.label"); //$NON-NLS-1$ return CPathEntryMessages.getString("CPListLabelProvider.unknown_element.label"); //$NON-NLS-1$
@ -200,21 +180,21 @@ class CPElementLabelProvider extends LabelProvider {
private ImageDescriptor getCPListElementBaseImage(CPElement cpentry) { private ImageDescriptor getCPListElementBaseImage(CPElement cpentry) {
switch (cpentry.getEntryKind()) { switch (cpentry.getEntryKind()) {
case IPathEntry.CDT_OUTPUT: case IPathEntry.CDT_OUTPUT :
if (cpentry.getPath().segmentCount() == 1) { if (cpentry.getPath().segmentCount() == 1) {
return fProjectImage; return fProjectImage;
} else { } else {
return fOutputImage; return fOutputImage;
} }
case IPathEntry.CDT_SOURCE: case IPathEntry.CDT_SOURCE :
if (cpentry.getPath().segmentCount() == 1) { if (cpentry.getPath().segmentCount() == 1) {
return fProjectImage; return fProjectImage;
} else { } else {
return fFolderImage; return fFolderImage;
} }
case IPathEntry.CDT_LIBRARY: case IPathEntry.CDT_LIBRARY :
IResource res = cpentry.getResource(); IResource res = cpentry.getResource();
IPath path = (IPath) cpentry.getAttribute(CPElement.SOURCEATTACHMENT); IPath path = (IPath)cpentry.getAttribute(CPElement.SOURCEATTACHMENT);
if (res == null) { if (res == null) {
if (path == null || path.isEmpty()) { if (path == null || path.isEmpty()) {
return fExtLibIcon; return fExtLibIcon;
@ -230,15 +210,15 @@ class CPElementLabelProvider extends LabelProvider {
} else { } else {
return fFolderImage; return fFolderImage;
} }
case IPathEntry.CDT_PROJECT: case IPathEntry.CDT_PROJECT :
return fProjectImage; return fProjectImage;
case IPathEntry.CDT_CONTAINER: case IPathEntry.CDT_CONTAINER :
return fContainerImage; return fContainerImage;
case IPathEntry.CDT_INCLUDE: case IPathEntry.CDT_INCLUDE :
return fIncludeIcon; return fIncludeIcon;
case IPathEntry.CDT_MACRO: case IPathEntry.CDT_MACRO :
return fMacroIcon; return fMacroIcon;
default: default :
return null; return null;
} }
} }
@ -247,7 +227,7 @@ class CPElementLabelProvider extends LabelProvider {
public Image getImage(Object element) { public Image getImage(Object element) {
if (element instanceof CPElement) { if (element instanceof CPElement) {
CPElement cpentry = (CPElement) element; CPElement cpentry = (CPElement)element;
ImageDescriptor imageDescriptor = getCPListElementBaseImage(cpentry); ImageDescriptor imageDescriptor = getCPListElementBaseImage(cpentry);
if (imageDescriptor != null) { if (imageDescriptor != null) {
if (cpentry.isMissing()) { if (cpentry.isMissing()) {
@ -256,7 +236,7 @@ class CPElementLabelProvider extends LabelProvider {
return fRegistry.get(imageDescriptor); return fRegistry.get(imageDescriptor);
} }
} else if (element instanceof CPElementAttribute) { } else if (element instanceof CPElementAttribute) {
String key = ((CPElementAttribute) element).getKey(); String key = ((CPElementAttribute)element).getKey();
if (key.equals(CPElement.SOURCEATTACHMENT)) { if (key.equals(CPElement.SOURCEATTACHMENT)) {
// return // return
// fRegistry.get(CPluginImages.DESC_OBJS_SOURCE_ATTACH_ATTRIB); // 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); return CPluginImages.get(CPluginImages.IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
} }
} else if (element instanceof IPathEntry) { } else if (element instanceof IPathEntry) {
return getImage(CPElement.createFromExisting((IPathEntry) element, null)); return getImage(CPElement.createFromExisting((IPathEntry)element, null));
} }
return null; return null;
} }

View file

@ -1,11 +1,10 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. and others. All * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which * the Common Public License v1.0 which accompanies this distribution, and is
* accompanies this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; 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 * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which * the Common Public License v1.0 which accompanies this distribution, and is
* accompanies this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import org.eclipse.cdt.core.model.IPathEntry; 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.cdt.ui.wizards.ICPathContainerPage;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; 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 { public class CPathContainerDescriptor implements IContainerDescriptor {
private IConfigurationElement fConfigElement; private IConfigurationElement fConfigElement;
private static final String ATT_EXTENSION = "PathContainerPage"; //$NON-NLS-1$ 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_ID = "id"; //$NON-NLS-1$
private static final String ATT_NAME = "name"; //$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 static final String ATT_PAGE_CLASS = "class"; //$NON-NLS-1$
private Image pageImage;
public CPathContainerDescriptor(IConfigurationElement configElement) throws CoreException { public CPathContainerDescriptor(IConfigurationElement configElement) throws CoreException {
super(); super();
fConfigElement = configElement; fConfigElement = configElement;
@ -41,20 +50,23 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
String pageClassName = configElement.getAttribute(ATT_PAGE_CLASS); String pageClassName = configElement.getAttribute(ATT_PAGE_CLASS);
if (name == null) { 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) { 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 { 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) { if (elem instanceof ICPathContainerPage) {
return (ICPathContainerPage) elem; return (ICPathContainerPage) elem;
} else { } else {
String id= fConfigElement.getAttribute(ATT_ID); 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$ throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
"Invalid extension (page not of type IClasspathContainerPage): " + id, null)); //$NON-NLS-1$
} }
} }
@ -62,6 +74,36 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
return fConfigElement.getAttribute(ATT_NAME); 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() { public String getPageClass() {
return fConfigElement.getAttribute(ATT_PAGE_CLASS); return fConfigElement.getAttribute(ATT_PAGE_CLASS);
} }
@ -76,19 +118,19 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
} }
public static IContainerDescriptor[] getDescriptors() { public static IContainerDescriptor[] getDescriptors() {
ArrayList containers= new ArrayList(); ArrayList containers = new ArrayList();
IExtensionPoint extensionPoint = Platform.getPluginRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, ATT_EXTENSION); IExtensionPoint extensionPoint = Platform.getPluginRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, ATT_EXTENSION);
if (extensionPoint != null) { if (extensionPoint != null) {
IContainerDescriptor defaultPage= null; IContainerDescriptor defaultPage = null;
String defaultPageName= CPathContainerDefaultPage.class.getName(); String defaultPageName = CPathContainerDefaultPage.class.getName();
IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
for (int i = 0; i < elements.length; i++) { for (int i = 0; i < elements.length; i++) {
try { try {
CPathContainerDescriptor curr= new CPathContainerDescriptor(elements[i]); CPathContainerDescriptor curr = new CPathContainerDescriptor(elements[i]);
if (defaultPageName.equals(curr.getPageClass())) { if (defaultPageName.equals(curr.getPageClass())) {
defaultPage= curr; defaultPage = curr;
} else { } else {
containers.add(curr); containers.add(curr);
} }

View file

@ -1,11 +1,10 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. and others. All * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which * the Common Public License v1.0 which accompanies this distribution, and is
* accompanies this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; 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.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite; 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 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) { public String getText(Object element) {
return ((IContainerDescriptor) element).getName(); 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 IContainerDescriptor[] fContainers;
private IDialogSettings fDialogSettings; private IDialogSettings fDialogSettings;
@ -75,10 +86,10 @@ public class CPathContainerSelectionPage extends WizardPage {
* @see IDialogPage#createControl(Composite) * @see IDialogPage#createControl(Composite)
*/ */
public void createControl(Composite parent) { public void createControl(Composite parent) {
fListViewer= new ListViewer(parent, SWT.SINGLE | SWT.BORDER); fListViewer= new TableViewer(parent, SWT.SINGLE | SWT.BORDER);
fListViewer.setLabelProvider(new ClasspathContainerLabelProvider()); fListViewer.setLabelProvider(new CPathContainerLabelProvider());
fListViewer.setContentProvider(new ListContentProvider()); fListViewer.setContentProvider(new ListContentProvider());
fListViewer.setSorter(new ClasspathContainerSorter()); fListViewer.setSorter(new CPathContainerSorter());
fListViewer.setInput(Arrays.asList(fContainers)); fListViewer.setInput(Arrays.asList(fContainers));
fListViewer.addSelectionChangedListener(new ISelectionChangedListener() { fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) { public void selectionChanged(SelectionChangedEvent event) {
@ -95,10 +106,10 @@ public class CPathContainerSelectionPage extends WizardPage {
if (selectionIndex >= fContainers.length) { if (selectionIndex >= fContainers.length) {
selectionIndex= 0; selectionIndex= 0;
} }
fListViewer.getList().select(selectionIndex); fListViewer.getTable().select(selectionIndex);
validatePage(); validatePage();
setControl(fListViewer.getList()); setControl(fListViewer.getTable());
Dialog.applyDialogFont(fListViewer.getList()); Dialog.applyDialogFont(fListViewer.getTable());
} }
/** /**
@ -135,7 +146,7 @@ public class CPathContainerSelectionPage extends WizardPage {
*/ */
public void setVisible(boolean visible) { public void setVisible(boolean visible) {
if (!visible && fListViewer != null) { if (!visible && fListViewer != null) {
fDialogSettings.put(DIALOGSTORE_CONTAINER_IDX, fListViewer.getList().getSelectionIndex()); fDialogSettings.put(DIALOGSTORE_CONTAINER_IDX, fListViewer.getTable().getSelectionIndex());
} }
super.setVisible(visible); super.setVisible(visible);
} }

View file

@ -1,10 +1,10 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved. * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* This program and the accompanying materials are made available under the * program and the accompanying materials are made available under the terms of
* terms of the Common Public License v1.0 which accompanies this distribution, * the Common Public License v1.0 which accompanies this distribution, and is
* and is available at http://www.eclipse.org/legal/cpl-v10.html * 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;
@ -12,7 +12,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; 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.core.model.IPathEntry;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler; import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
import org.eclipse.cdt.internal.ui.util.PixelConverter; import org.eclipse.cdt.internal.ui.util.PixelConverter;
@ -33,8 +33,8 @@ public class CPathContainerWizard extends Wizard {
private IPathEntry[] fNewEntries; private IPathEntry[] fNewEntries;
private IPathEntry[] fContainerEntries; private IPathEntry[] fContainerEntries;
private ICPathContainerPage fContainerPage; private ICPathContainerPage fContainerPage;
private ICProject fCurrProject; private ICElement fCurrElement;
private IPathEntry[] fCurrClasspath; private IPathEntry[] fCurrCPath;
private CPathFilterPage fFilterPage; private CPathFilterPage fFilterPage;
private CPathContainerSelectionPage fSelectionWizardPage; private CPathContainerSelectionPage fSelectionWizardPage;
@ -43,26 +43,26 @@ public class CPathContainerWizard extends Wizard {
/** /**
* Constructor for ClasspathContainerWizard. * Constructor for ClasspathContainerWizard.
*/ */
public CPathContainerWizard(IPathEntry entryToEdit, ICProject currProject, IPathEntry[] currEntries) { public CPathContainerWizard(IPathEntry entryToEdit, ICElement currElement, IPathEntry[] currEntries) {
this(entryToEdit, null, currProject, currEntries, -1); this(entryToEdit, null, currElement, currEntries, -1);
} }
/** /**
* Constructor for ClasspathContainerWizard. * Constructor for ClasspathContainerWizard.
*/ */
public CPathContainerWizard(IContainerDescriptor pageDesc, ICProject currProject, IPathEntry[] currEntries) { public CPathContainerWizard(IContainerDescriptor pageDesc, ICElement currElement, IPathEntry[] currEntries) {
this(null, pageDesc, currProject, currEntries, -1); 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) { IPathEntry[] currEntries, int filterType) {
fEntryToEdit = entryToEdit; fEntryToEdit = entryToEdit;
fPageDesc = pageDesc; fPageDesc = pageDesc;
fNewEntries = null; fNewEntries = null;
fFilterType = filterType; fFilterType = filterType;
fCurrProject = currProject; fCurrElement = currElement;
fCurrClasspath = currEntries; fCurrCPath = currEntries;
} }
public IPathEntry getEntriesParent() { public IPathEntry getEntriesParent() {
@ -85,10 +85,9 @@ public class CPathContainerWizard extends Wizard {
public boolean performFinish() { public boolean performFinish() {
if (fContainerPage != null) { if (fContainerPage != null) {
if (fContainerPage.finish()) { if (fContainerPage.finish()) {
fContainerEntries = fContainerPage.getContainerEntries();
if (fFilterType != -1 && fFilterPage.isPageComplete()) { if (fFilterType != -1 && fFilterPage.isPageComplete()) {
fNewEntries = fFilterPage.getSelectedEntries(); fNewEntries = fFilterPage.getSelectedEntries();
} else {
fContainerEntries = fContainerPage.getContainerEntries();
} }
return true; return true;
} }
@ -126,7 +125,8 @@ public class CPathContainerWizard extends Wizard {
addPage(fContainerPage); addPage(fContainerPage);
} }
if (fFilterType != -1) { if (fFilterType != -1) {
fFilterPage = new CPathFilterPage(fCurrProject, fFilterType); fFilterPage = new CPathFilterPage(fCurrElement, fFilterType);
addPage(fFilterPage);
} }
super.addPages(); super.addPages();
} }
@ -144,7 +144,7 @@ public class CPathContainerWizard extends Wizard {
if (containerPage == null) { if (containerPage == null) {
containerPage = new CPathContainerDefaultPage(); containerPage = new CPathContainerDefaultPage();
} }
containerPage.initialize(fCurrProject, fCurrClasspath); containerPage.initialize(fCurrElement.getCProject(), fCurrCPath);
containerPage.setSelection(fEntryToEdit); containerPage.setSelection(fEntryToEdit);
containerPage.setWizard(this); containerPage.setWizard(this);
return containerPage; return containerPage;
@ -162,9 +162,10 @@ public class CPathContainerWizard extends Wizard {
fContainerPage = getContainerPage(selected); fContainerPage = getContainerPage(selected);
return fContainerPage; return fContainerPage;
} else if (page == fContainerPage) { } else if (page == fContainerPage) {
if ( fContainerPage.getContainerEntries().length > 0 ) { if ( fContainerPage.getContainerEntries().length > 0 && fContainerPage.getContainerEntries()[0] != null) {
fFilterPage.setParentEntry(fContainerPage.getContainerEntries()[0]); fFilterPage.setParentEntry(fContainerPage.getContainerEntries()[0]);
} }
return fFilterPage;
} }
return super.getNextPage(page); return super.getNextPage(page);
} }

View file

@ -1,11 +1,10 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. and others. All * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which accompanies * the Common Public License v1.0 which accompanies this distribution, and is
* this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; 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.discard=Discard
CPathsPropertyPage.unsavedchanges.button.ignore=Apply Later CPathsPropertyPage.unsavedchanges.button.ignore=Apply Later
BuildPathsBlock.tab.libraries=&Libraries 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 ---------
ExtendingCPathBasePage.editSourcePaths=Edit Source Paths... ExtendingCPathBasePage.editSourcePaths=Edit Source Paths...
@ -50,6 +80,10 @@ IncludeEntryPage.addExternal.title=Add External Include Path
IncludeEntryPage.addExternal.message=Include path: IncludeEntryPage.addExternal.message=Include path:
IncludeEntryPage.ContainerDialog.new.title=Contributed Include Path Selection IncludeEntryPage.ContainerDialog.new.title=Contributed Include Path Selection
IncludeEntryPage.ContainerDialog.edit.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 ------- # ------- BuildPathsBlock -------
CPathsBlock.path.up.button=&Up CPathsBlock.path.up.button=&Up
@ -180,8 +214,6 @@ ExclusionPatternEntryDialog.ChooseExclusionPattern.description=&Choose a folder
# ------- CPListLabelProvider ------- # ------- CPListLabelProvider -------
CPListLabelProvider.new=(new) CPListLabelProvider.new=(new)
CPListLabelProvider.classcontainer=(class folder)
CPListLabelProvider.twopart={0} - {1}
CPListLabelProvider.willbecreated=(will be created) CPListLabelProvider.willbecreated=(will be created)
CPListLabelProvider.none=(None) CPListLabelProvider.none=(None)
CPListLabelProvider.source_attachment.label=Source attachment: CPListLabelProvider.source_attachment.label=Source attachment:

View file

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

View file

@ -1,11 +1,10 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. and others. All * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which accompanies * the Common Public License v1.0 which accompanies this distribution, and is
* this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; 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_EDIT = 4;
private static final int IDX_REMOVE = 5; 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$ /* 0 */CPathEntryMessages.getString("IncludeEntryPage.addExternal"), //$NON-NLS-1$
/* 1 */CPathEntryMessages.getString("IncludeEntryPage.addFromWorkspace"), //$NON-NLS-1$ /* 1 */CPathEntryMessages.getString("IncludeEntryPage.addFromWorkspace"), //$NON-NLS-1$
/* 2 */CPathEntryMessages.getString("IncludeEntryPage.addContributed"), null, //$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) { protected void buttonPressed(int indx, List selected) {
switch (indx) { switch (indx) {
case IDX_ADD_USER: case IDX_ADD_USER :
addInclude(); addInclude();
break; break;
case IDX_ADD_WORKSPACE: case IDX_ADD_WORKSPACE :
addFromWorkspace(); addFromWorkspace();
break; break;
case IDX_ADD_CONTRIBUTED: case IDX_ADD_CONTRIBUTED :
addContributed(); addContributed();
break; break;
case IDX_EDIT: case IDX_EDIT :
if (canEdit(selected)) { if (canEdit(selected)) {
editInclude((CPElement) selected.get(0)); editInclude((CPElement)selected.get(0));
} }
break; break;
case IDX_REMOVE: case IDX_REMOVE :
if (canRemove(selected)) { if (canRemove(selected)) {
removeInclude((CPElement) selected.get(0)); removeInclude((CPElement)selected.get(0));
} }
break; break;
} }
@ -109,7 +108,7 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
protected boolean canEdit(List selected) { protected boolean canEdit(List selected) {
if (!selected.isEmpty()) { if (!selected.isEmpty()) {
return !isPathInheritedFromSelected((CPElement) selected.get(0)); return !isPathInheritedFromSelected((CPElement)selected.get(0));
} }
return false; return false;
} }
@ -130,7 +129,7 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
newItem = dialog.getValue(); newItem = dialog.getValue();
if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$ if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$
List cplist = getPathList().getElements(); 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(), CPElement newPath = new CPElement(element.getCProject(), IPathEntry.CDT_INCLUDE, element.getPath(),
element.getResource()); element.getResource());
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem)); newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
@ -166,7 +165,7 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
} }
protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) { protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
Class[] acceptedClasses = new Class[] { ICProject.class, IProject.class, IContainer.class, ICContainer.class}; Class[] acceptedClasses = new Class[]{ICProject.class, IProject.class, IContainer.class, ICContainer.class};
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null); TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
ViewerFilter filter = new TypedViewerFilter(acceptedClasses); ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
@ -191,16 +190,16 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult(); Object[] elements = dialog.getResult();
CPElement[] res = new CPElement[elements.length]; 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++) { for (int i = 0; i < res.length; i++) {
IProject project; IProject project;
IPath includePath; IPath includePath;
if (elements[i] instanceof IResource) { if (elements[i] instanceof IResource) {
project = ((IResource) elements[i]).getProject(); project = ((IResource)elements[i]).getProject();
includePath = ((IResource) elements[i]).getProjectRelativePath(); includePath = ((IResource)elements[i]).getProjectRelativePath();
} else { } else {
project = ((ICElement) elements[i]).getCProject().getProject(); project = ((ICElement)elements[i]).getCProject().getProject();
includePath = ((ICElement) elements[i]).getResource().getProjectRelativePath(); includePath = ((ICElement)elements[i]).getResource().getProjectRelativePath();
} }
res[i] = new CPElement(element.getCProject(), IPathEntry.CDT_INCLUDE, element.getPath(), element.getResource()); res[i] = new CPElement(element.getCProject(), IPathEntry.CDT_INCLUDE, element.getPath(), element.getResource());
res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative()); 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$ title = CPathEntryMessages.getString("IncludeEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
elem = existing.getPathEntry(); 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); wizard.setWindowTitle(title);
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) { if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
IPathEntry parent = wizard.getEntriesParent(); IPathEntry parent = wizard.getEntriesParent();
IPathEntry[] elements = wizard.getEntries(); IPathEntry[] elements = wizard.getEntries();
IResource resource = ((ICElement) getSelection().get(0)).getResource(); IResource resource = ((ICElement)getSelection().get(0)).getResource();
if (elements != null) { if (elements != null) {
CPElement[] res = new CPElement[elements.length]; CPElement[] res = new CPElement[elements.length];

View file

@ -1,11 +1,10 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. and others. All * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which accompanies * the Common Public License v1.0 which accompanies this distribution, and is
* this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;
@ -47,15 +46,16 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
addSymbol(); addSymbol();
break; break;
case IDX_ADD_CONTRIBUTED : case IDX_ADD_CONTRIBUTED :
addContributed();
break; break;
case IDX_EDIT : case IDX_EDIT :
if (canEdit(selected)) { if (canEdit(selected)) {
editSymbol((CPElement) selected.get(0)); editSymbol((CPElement)selected.get(0));
} }
break; break;
case IDX_REMOVE : case IDX_REMOVE :
if (canRemove(selected)) { if (canRemove(selected)) {
removeSymbol((CPElement) selected.get(0)); removeSymbol((CPElement)selected.get(0));
} }
break; break;
} }
@ -73,7 +73,7 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
protected boolean canEdit(List selected) { protected boolean canEdit(List selected) {
if (!selected.isEmpty()) { if (!selected.isEmpty()) {
return !isPathInheritedFromSelected((CPElement) selected.get(0)); return !isPathInheritedFromSelected((CPElement)selected.get(0));
} }
return false; return false;
} }
@ -105,7 +105,7 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
symbol = dialog.getValue(); symbol = dialog.getValue();
if (symbol != null && symbol.length() > 0) { if (symbol != null && symbol.length() > 0) {
List cplist = getPathList().getElements(); 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); CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, resource.getFullPath(), resource);
String name, value = ""; //$NON-NLS-1$ String name, value = ""; //$NON-NLS-1$
int index = symbol.indexOf("="); //$NON-NLS-1$ int index = symbol.indexOf("="); //$NON-NLS-1$
@ -156,12 +156,13 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
title = CPathEntryMessages.getString("SymbolEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$ title = CPathEntryMessages.getString("SymbolEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
elem = existing.getPathEntry(); 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); wizard.setWindowTitle(title);
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) { if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
IPathEntry parent = wizard.getEntriesParent(); IPathEntry parent = wizard.getEntriesParent();
IPathEntry[] elements = wizard.getEntries(); IPathEntry[] elements = wizard.getEntries();
IResource resource = ((ICElement) getSelection().get(0)).getResource(); IResource resource = ((ICElement)getSelection().get(0)).getResource();
if (elements != null) { if (elements != null) {
CPElement[] res = new CPElement[elements.length]; CPElement[] res = new CPElement[elements.length];
for (int i = 0; i < res.length; i++) { for (int i = 0; i < res.length; i++) {

View file

@ -1,13 +1,11 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others. * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* All rights reserved. This program and the accompanying materials * program and the accompanying materials are made available under the terms of
* are made available under the terms of the Common Public License v1.0 * the Common Public License v1.0 which accompanies this distribution, and is
* which accompanies this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: * Contributors: QNX Software Systems - initial API and implementation
* IBM Corporation - initial API and implementation ******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths; package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -1,10 +1,10 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved. * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* This program and the accompanying materials are made available under the * program and the accompanying materials are made available under the terms of
* terms of the Common Public License v1.0 which accompanies this distribution, * the Common Public License v1.0 which accompanies this distribution, and is
* and is available at http://www.eclipse.org/legal/cpl-v10.html * 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; 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 * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which accompanies * the Common Public License v1.0 which accompanies this distribution, and is
* this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -1,20 +1,22 @@
/* /*******************************************************************************
* 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.ui.wizards.ICPathContainerPage; import org.eclipse.cdt.ui.wizards.ICPathContainerPage;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
public interface IContainerDescriptor { public interface IContainerDescriptor {
public abstract ICPathContainerPage createPage() throws CoreException; public ICPathContainerPage createPage() throws CoreException;
public abstract String getName(); public String getName();
public abstract boolean canEdit(IPathEntry entry); 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 * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which * the Common Public License v1.0 which accompanies this distribution, and is
* accompanies this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; 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 * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* rights reserved. This program and the accompanying materials are made * program and the accompanying materials are made available under the terms of
* available under the terms of the Common Public License v1.0 which accompanies * the Common Public License v1.0 which accompanies this distribution, and is
* this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* 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; 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. * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* This program and the accompanying materials are made available under the * program and the accompanying materials are made available under the terms of
* terms of the Common Public License v1.0 which accompanies this distribution, * the Common Public License v1.0 which accompanies this distribution, and is
* and is available at http://www.eclipse.org/legal/cpl-v10.html * 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; 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. * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
* This program and the accompanying materials are made available under the * program and the accompanying materials are made available under the terms of
* terms of the Common Public License v1.0 which accompanies this distribution, * the Common Public License v1.0 which accompanies this distribution, and is
* and is available at http://www.eclipse.org/legal/cpl-v10.html * 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;

View file

@ -1,16 +1,19 @@
/* /*******************************************************************************
* 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.wizards.ICPathContainerPage; import org.eclipse.cdt.ui.wizards.ICPathContainerPage;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ide.IDE;
public class ProjectContainerDescriptor implements IContainerDescriptor { public class ProjectContainerDescriptor implements IContainerDescriptor {
private int fFilterType; private int fFilterType;
@ -27,6 +30,11 @@ public class ProjectContainerDescriptor implements IContainerDescriptor {
return CPathEntryMessages.getString("ProjectContainer.label"); //$NON-NLS-1$ 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) { public boolean canEdit(IPathEntry entry) {
return false; 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; package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.internal.ui.CPluginImages; 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.cdt.ui.wizards.ICPathContainerPage;
import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.WizardPage; 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.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; 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 { public class ProjectContainerPage extends WizardPage implements ICPathContainerPage {
private int fFilterType; private int fFilterType;
private CheckboxTableViewer viewer; private TableViewer viewer;
private ICProject fCProject; 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) { protected ProjectContainerPage(int filterType) {
super("projectContainerPage"); //$NON-NLS-1$ super("projectContainerPage"); //$NON-NLS-1$
setTitle(CPathEntryMessages.getString("ProjectContainerPage.title")); //$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() { 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) { public void setSelection(IPathEntry containerEntry) {
if (containerEntry != null) { if (containerEntry != null) {
viewer.setSelection(new StructuredSelection(containerEntry)); viewer.setSelection(new StructuredSelection(containerEntry));
@ -120,12 +86,13 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
GridData gd = new GridData(); GridData gd = new GridData();
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
label.setLayoutData(gd); label.setLayoutData(gd);
viewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); viewer = new TableViewer(container, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
viewer.setContentProvider(new WorkbenchCPathContentProvider());
viewer.setLabelProvider(new CPElementLabelProvider());
viewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) { viewer.setContentProvider(new ListContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
validatePage(); validatePage();
} }
}); });
@ -136,13 +103,36 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
viewer.addFilter(new ViewerFilter() { viewer.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) { public boolean select(Viewer viewer, Object parentElement, Object element) {
return true; return !element.equals(fCProject);
} }
}); });
setControl(container); setControl(container);
initializeView();
validatePage(); 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. * Method validatePage.
*/ */