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

Added the new source container type (CDirectorySourceContainer) to provide the UI support for the subfolders search.

This commit is contained in:
Mikhail Khodjaiants 2005-04-25 23:03:50 +00:00
parent 85f5ea3b48
commit ed389a8c3d
15 changed files with 532 additions and 12 deletions

View file

@ -1,3 +1,14 @@
2005-04-25 Mikhail Khodjaiants
Added the new source container type (CDirectorySourceContainer) to provide
the UI support for the subfolders search.
+ CDirectorySourceContainer.java
+ CDirectorySourceContainerType.java
* CSourceLookupDirector.java
* SourceUtils.java
* InternalSourceLookupMessages.properties
* plugin.properties
* plugin.xml
2005-04-25 Alain Magloire
Changes to the CDI interface.
+ cdi/org/eclipse/cdt/debug/core/cdi/ICDIAddressLocation.java

View file

@ -21,4 +21,6 @@ cWatchpoints.name=C/C++ Watchpoints
containerName.mapping=Path Mapping
containerDescription.mapping=A path mapping.
containerName.mapEntry=Path Map Entry
containerDescription.mapEntry=An entry in a path mapping.
containerDescription.mapEntry=An entry in a path mapping.
containerName.directory=Directory
containerDescription.directory=A directory in the local file system

View file

@ -171,6 +171,11 @@
description="%containerDescription.mapEntry"
id="org.eclipse.cdt.debug.core.containerType.mapEntry"
name="%containerName.mapEntry"/>
<sourceContainerType
class="org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceContainerType"
description="%containerDescription.directory"
id="org.eclipse.cdt.debug.core.containerType.directory"
name="%containerName.directory"/>
</extension>
</plugin>

View file

@ -0,0 +1,178 @@
/**********************************************************************
* 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.debug.core.sourcelookup;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
import org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
/**
* It is not supposed to subclass DirectorySourceContainer, but we need to use
* the different browser.
*/
public class CDirectorySourceContainer extends CompositeSourceContainer {
/**
* Unique identifier for the CDT directory source container type
* (value <code>org.eclipse.cdt.debug.core.containerType.directory</code>).
*/
public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.directory"; //$NON-NLS-1$
// root directory
private File fDirectory;
// whether to search subfolders
private boolean fSubfolders = false;
/**
* Consutructs an external folder container for the
* directory identified by the given path.
*
* @param dirPath path to a directory in the local file system
* @param subfolders whether folders within the root directory
* should be searched for source elements
*/
public CDirectorySourceContainer( IPath dirPath, boolean subfolders ) {
this( dirPath.toFile(), subfolders );
}
/**
* Consutructs an external folder container for the
* directory identified by the given file.
*
* @param dir a directory in the local file system
* @param subfolders whether folders within the root directory
* should be searched for source elements
*/
public CDirectorySourceContainer( File dir, boolean subfolders ) {
fDirectory = dir;
fSubfolders = subfolders;
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#getName()
*/
public String getName() {
return fDirectory.getName();
}
/**
* Returns the root directory in the local file system associated
* with this source container.
*
* @return the root directory in the local file system associated
* with this source container
*/
public File getDirectory() {
return fDirectory;
}
public boolean searchSubfolders() {
return fSubfolders;
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#getType()
*/
public ISourceContainerType getType() {
return getSourceContainerType( TYPE_ID );
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String)
*/
public Object[] findSourceElements( String name ) throws CoreException {
ArrayList sources = new ArrayList();
File directory = getDirectory();
File file = new File( directory, name );
if ( file.exists() && file.isFile() ) {
sources.add( new LocalFileStorage( file ) );
}
// check subfolders
if ( (isFindDuplicates() && fSubfolders) || (sources.isEmpty() && fSubfolders) ) {
ISourceContainer[] containers = getSourceContainers();
for( int i = 0; i < containers.length; i++ ) {
Object[] objects = containers[i].findSourceElements( name );
if ( objects == null || objects.length == 0 ) {
continue;
}
if ( isFindDuplicates() ) {
for( int j = 0; j < objects.length; j++ )
sources.add( objects[j] );
}
else {
sources.add( objects[0] );
break;
}
}
}
if ( sources.isEmpty() )
return EMPTY;
return sources.toArray();
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#isComposite()
*/
public boolean isComposite() {
return fSubfolders;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals( Object obj ) {
if ( obj instanceof CDirectorySourceContainer ) {
CDirectorySourceContainer container = (CDirectorySourceContainer)obj;
return container.getDirectory().equals( getDirectory() );
}
return false;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return getDirectory().hashCode();
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.containers.CompositeSourceContainer#createSourceContainers()
*/
protected ISourceContainer[] createSourceContainers() throws CoreException {
if ( isComposite() ) {
String[] files = fDirectory.list();
if ( files != null ) {
List dirs = new ArrayList();
for( int i = 0; i < files.length; i++ ) {
String name = files[i];
File file = new File( getDirectory(), name );
if ( file.exists() && file.isDirectory() ) {
dirs.add( new CDirectorySourceContainer( file, true ) );
}
}
ISourceContainer[] containers = (ISourceContainer[])dirs.toArray( new ISourceContainer[dirs.size()] );
for( int i = 0; i < containers.length; i++ ) {
ISourceContainer container = containers[i];
container.init( getDirector() );
}
return containers;
}
}
return new ISourceContainer[0];
}
}

View file

@ -0,0 +1,65 @@
/**********************************************************************
* 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.debug.internal.core.sourcelookup;
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
* See <code>CDirectorySourceContainer</code>.
*/
public class CDirectorySourceContainerType extends AbstractSourceContainerTypeDelegate {
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#createSourceContainer(java.lang.String)
*/
public ISourceContainer createSourceContainer( String memento ) throws CoreException {
Node node = parseDocument( memento );
if ( node.getNodeType() == Node.ELEMENT_NODE ) {
Element element = (Element)node;
if ( "directory".equals( element.getNodeName() ) ) { //$NON-NLS-1$
String string = element.getAttribute( "path" ); //$NON-NLS-1$
if ( string == null || string.length() == 0 ) {
abort( InternalSourceLookupMessages.getString( "CDirectorySourceContainerType.0" ), null ); //$NON-NLS-1$
}
String nest = element.getAttribute( "nest" ); //$NON-NLS-1$
boolean nested = "true".equals( nest ); //$NON-NLS-1$
return new CDirectorySourceContainer( new Path( string ), nested );
}
abort( InternalSourceLookupMessages.getString( "CDirectorySourceContainerType.1" ), null ); //$NON-NLS-1$
}
abort( InternalSourceLookupMessages.getString( "CDirectorySourceContainerType.2" ), null ); //$NON-NLS-1$
return null;
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
*/
public String getMemento( ISourceContainer container ) throws CoreException {
CDirectorySourceContainer folder = (CDirectorySourceContainer)container;
Document document = newDocument();
Element element = document.createElement( "directory" ); //$NON-NLS-1$
element.setAttribute( "path", folder.getDirectory().getAbsolutePath() ); //$NON-NLS-1$
String nest = "false"; //$NON-NLS-1$
if ( folder.isComposite() ) {
nest = "true"; //$NON-NLS-1$
}
element.setAttribute( "nest", nest ); //$NON-NLS-1$
document.appendChild( element );
return serializeDocument( document );
}
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.internal.core.sourcelookup;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@ -20,7 +21,6 @@ import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
@ -30,15 +30,15 @@ import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
*/
public class CSourceLookupDirector extends AbstractSourceLookupDirector {
private static Set fFilteredTypes;
private static Set fSupportedTypes;
static {
fFilteredTypes = new HashSet();
fFilteredTypes.add( WorkspaceSourceContainer.TYPE_ID );
fFilteredTypes.add( ProjectSourceContainer.TYPE_ID );
fFilteredTypes.add( FolderSourceContainer.TYPE_ID );
fFilteredTypes.add( DirectorySourceContainer.TYPE_ID );
fFilteredTypes.add( MappingSourceContainer.TYPE_ID );
fSupportedTypes = new HashSet();
fSupportedTypes.add( WorkspaceSourceContainer.TYPE_ID );
fSupportedTypes.add( ProjectSourceContainer.TYPE_ID );
fSupportedTypes.add( FolderSourceContainer.TYPE_ID );
fSupportedTypes.add( CDirectorySourceContainer.TYPE_ID );
fSupportedTypes.add( MappingSourceContainer.TYPE_ID );
}
/* (non-Javadoc)
@ -51,7 +51,7 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
* @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#supportsSourceContainerType(org.eclipse.debug.core.sourcelookup.ISourceContainerType)
*/
public boolean supportsSourceContainerType( ISourceContainerType type ) {
return fFilteredTypes.contains( type.getId() );
return fSupportedTypes.contains( type.getId() );
}
public boolean contains( IProject project ) {

View file

@ -13,6 +13,9 @@ CDirectorySourceLocation.0=Unable to create memento for C/C++ directory source l
CDirectorySourceLocation.1=Unable to initialize source location - missing directory path.
CDirectorySourceLocation.2=Unable to initialize source location - invalid directory path {0}.
CDirectorySourceLocation.3=Exception occurred initializing source location.
CDirectorySourceContainerType.0=Unable to restore directory source lookup entry - missing path attribute.
CDirectorySourceContainerType.1=Unable to restore directory source lookup entry - expecting directory element.
CDirectorySourceContainerType.2=Unable to restore directory source lookup entry - invalid memento.
CProjectSourceLocation.0=Unable to create memento for C/C++ project source location {0}.
CProjectSourceLocation.1=Unable to initialize source location - missing project name
CProjectSourceLocation.2=Exception occurred initializing source location.

View file

@ -22,6 +22,7 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
@ -31,7 +32,6 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -181,7 +181,7 @@ public class SourceUtils {
containers.add( mapping );
}
containers.add( new DirectorySourceContainer( d.getDirectory(), d.searchSubfolders() ) );
containers.add( new CDirectorySourceContainer( d.getDirectory(), d.searchSubfolders() ) );
}
}
return (ISourceContainer[])containers.toArray( new ISourceContainer[containers.size()] );

View file

@ -1,3 +1,13 @@
2005-04-25 Mikhail Khodjaiants
Added the new source container type (CDirectorySourceContainer) to provide
the UI support for the subfolders search.
* ICDebugHelpContextIds.java
+ CDirectorySourceContainerBrowser.java
+ CDirectorySourceContainerDialog.java
* SourceContainerWorkbenchAdapter.java
* SourceLookupUIMessages.properties
* plugin.xml
2005-04-22 Mikhail Khodjaiants
Initalize the particiapants of the source lookup director when converting
from an old memento.

View file

@ -1145,6 +1145,11 @@
adaptableType="org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer"
class="org.eclipse.cdt.debug.internal.ui.sourcelookup.SourceContainerAdapterFactory">
<adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
</factory>
<factory
adaptableType="org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer"
class="org.eclipse.cdt.debug.internal.ui.sourcelookup.SourceContainerAdapterFactory">
<adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
</factory> </extension>
<extension
point="org.eclipse.ui.themes">
@ -1199,6 +1204,11 @@
containerTypeID="org.eclipse.cdt.debug.core.containerType.mapEntry"
icon="icons/obj16/mapentry_obj.gif"
id="org.eclipse.cdt.debug.ui.sourceContainerPresentation.mapEntry"/>
<sourceContainerPresentation
browserClass="org.eclipse.cdt.debug.internal.ui.sourcelookup.CDirectorySourceContainerBrowser"
containerTypeID="org.eclipse.cdt.debug.core.containerType.directory"
icon="icons/obj16/folder_obj.gif"
id="org.eclipse.cdt.debug.ui.containerPresentation.directory"/>
</extension>
</plugin>

View file

@ -67,4 +67,5 @@ public interface ICDebugHelpContextIds
public static final String SOURCE_PATH_MAPPING_DIALOG = PREFIX + "source_path_mapping_dialog_context"; //$NON-NLS-1$
public static final String SOURCE_PATH_MAP_ENTRY_DIALOG = PREFIX + "source_path_map_entry_dialog_context"; //$NON-NLS-1$
public static final String ADD_SOURCE_CONTAINER_DIALOG = PREFIX + "add_source_container_dialog"; //$NON-NLS-1$
public static final String ADD_DIRECTORY_CONTAINER_DIALOG = PREFIX + "add_directory_container_dialog"; //$NON-NLS-1$
}

View file

@ -0,0 +1,42 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
/**
* The browser for adding and editing a directory source container.
*/
public class CDirectorySourceContainerBrowser extends AbstractSourceContainerBrowser {
/* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
*/
public ISourceContainer[] addSourceContainers( Shell shell, ISourceLookupDirector director ) {
CDirectorySourceContainerDialog dialog = new CDirectorySourceContainerDialog( shell );
if ( dialog.open() == Window.OK ) {
return new ISourceContainer[] { new CDirectorySourceContainer( dialog.getDirectory(), dialog.isSearchSubfolders() ) };
}
return new ISourceContainer[0];
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canAddSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
*/
public boolean canAddSourceContainers( ISourceLookupDirector director ) {
return true;
}
}

View file

@ -0,0 +1,158 @@
/**********************************************************************
* 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.debug.internal.ui.sourcelookup;
import java.io.File;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
import org.eclipse.cdt.debug.internal.ui.dialogfields.DialogField;
import org.eclipse.cdt.debug.internal.ui.dialogfields.IDialogFieldListener;
import org.eclipse.cdt.debug.internal.ui.dialogfields.IStringButtonAdapter;
import org.eclipse.cdt.debug.internal.ui.dialogfields.LayoutUtil;
import org.eclipse.cdt.debug.internal.ui.dialogfields.SelectionButtonDialogField;
import org.eclipse.cdt.debug.internal.ui.dialogfields.Separator;
import org.eclipse.cdt.debug.internal.ui.dialogfields.StringButtonDialogField;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
/**
* The dialog for selecting the local file system for which a source
* container will be created.
*/
public class CDirectorySourceContainerDialog extends TitleAreaDialog {
private StringButtonDialogField fDirectoryField;
private SelectionButtonDialogField fSubfoldersField;
private File fDirectory;
private boolean fSearchSubfolders;
/**
* Constructor for CDirectorySourceContainerDialog.
*/
public CDirectorySourceContainerDialog( Shell parentShell ) {
this( parentShell, new File( "" ), false ); //$NON-NLS-1$
}
/**
* Constructor for CDirectorySourceContainerDialog.
*/
public CDirectorySourceContainerDialog( Shell parentShell, File directory, boolean searchSubfolders ) {
super( parentShell );
fDirectory = directory;
fSearchSubfolders = searchSubfolders;
fDirectoryField = new StringButtonDialogField(
new IStringButtonAdapter() {
public void changeControlPressed( DialogField field ) {
browse();
}
} );
fDirectoryField.setLabelText( SourceLookupUIMessages.getString( "CDirectorySourceContainerDialog.0" ) ); //$NON-NLS-1$
fDirectoryField.setButtonLabel( SourceLookupUIMessages.getString( "CDirectorySourceContainerDialog.1" ) ); //$NON-NLS-1$
fDirectoryField.setDialogFieldListener(
new IDialogFieldListener() {
public void dialogFieldChanged( DialogField field ) {
// TODO Auto-generated method stub
}
} );
fSubfoldersField = new SelectionButtonDialogField( SWT.CHECK );
fSubfoldersField.setLabelText( SourceLookupUIMessages.getString( "CDirectorySourceContainerDialog.2" ) ); //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea( Composite parent ) {
setTitle( SourceLookupUIMessages.getString( "CDirectorySourceContainerDialog.3" ) ); //$NON-NLS-1$
Font font = parent.getFont();
Composite composite = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout();
layout.numColumns = Math.max( fDirectoryField.getNumberOfControls(), fSubfoldersField.getNumberOfControls() );
layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN );
layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN );
// layout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING );
// layout.horizontalSpacing = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING );
composite.setLayout( layout );
GridData data = new GridData( GridData.FILL_BOTH );
composite.setLayoutData( data );
composite.setFont( font );
Dialog.applyDialogFont( composite );
PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.ADD_DIRECTORY_CONTAINER_DIALOG );
PixelConverter converter = new PixelConverter( composite );
fDirectoryField.doFillIntoGrid( composite, layout.numColumns );
LayoutUtil.setHorizontalGrabbing( fDirectoryField.getTextControl( null ) );
new Separator().doFillIntoGrid( composite, layout.numColumns, converter.convertHeightInCharsToPixels( 1 ) );
fSubfoldersField.doFillIntoGrid( composite, layout.numColumns );
initialize();
setMessage( null );
return super.createDialogArea( parent );
}
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/
protected void configureShell( Shell newShell ) {
newShell.setText( SourceLookupUIMessages.getString( "CDirectorySourceContainerDialog.4" ) ); //$NON-NLS-1$
super.configureShell( newShell );
}
protected void browse() {
String last = fDirectoryField.getText();
DirectoryDialog dialog = new DirectoryDialog( getShell(), SWT.SINGLE );
dialog.setFilterPath( last );
String result = dialog.open();
if ( result == null ) {
return;
}
fDirectoryField.setText( result );
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
protected void okPressed() {
fDirectory = new File( fDirectoryField.getText() );
fSearchSubfolders = fSubfoldersField.isSelected();
super.okPressed();
}
public File getDirectory() {
return fDirectory;
}
public boolean isSearchSubfolders() {
return fSearchSubfolders;
}
private void initialize() {
fDirectoryField.setText( getDirectory().getPath() );
fSubfoldersField.setSelection( isSearchSubfolders() );
}
}

View file

@ -10,13 +10,17 @@
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import java.io.File;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;
@ -64,6 +68,12 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
* @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
*/
public String getLabel( Object o ) {
if ( o instanceof CDirectorySourceContainer ) {
CDirectorySourceContainer container = (CDirectorySourceContainer)o;
File file = container.getDirectory();
IPath path = new Path( file.getAbsolutePath() );
return getQualifiedName( path );
}
if ( o instanceof MappingSourceContainer ) {
return SourceLookupUIMessages.getString( "SourceContainerWorkbenchAdapter.0" ) + ((MappingSourceContainer)o).getName(); //$NON-NLS-1$
}
@ -79,4 +89,24 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
public Object getParent( Object o ) {
return null;
}
public String getQualifiedName( IPath path ) {
StringBuffer buffer = new StringBuffer();
String[] segments = path.segments();
if ( segments.length > 0 ) {
buffer.append( path.lastSegment() );
if ( segments.length > 1 ) {
buffer.append( " - " ); //$NON-NLS-1$
if ( path.getDevice() != null ) {
buffer.append( path.getDevice() );
}
for( int i = 0; i < segments.length - 1; i++ ) {
buffer.append( File.separatorChar );
buffer.append( segments[i] );
}
}
return buffer.toString();
}
return ""; //$NON-NLS-1$
}
}

View file

@ -24,3 +24,8 @@ PathMappingDialog.16=Path Mappings
RemoveAction.0=Re&move
SourceContainerWorkbenchAdapter.0=Path Mapping:
UpAction.0=U&p
CDirectorySourceContainerDialog.0=&Directory:
CDirectorySourceContainerDialog.1=&Browse...
CDirectorySourceContainerDialog.2=Search sub&folders
CDirectorySourceContainerDialog.3=Choose directory to add:
CDirectorySourceContainerDialog.4=Directory Selection