1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Implementation of the 'Source Lookup' property page.

This commit is contained in:
Mikhail Khodjaiants 2002-12-30 00:07:15 +00:00
parent ef8512f6c9
commit 48a6c457d4
22 changed files with 953 additions and 211 deletions

View file

@ -1,3 +1,19 @@
2002-12-29 Mikhail Khodjaiants
Implementation of the 'Source Lookup' property page.
* AddDirectorySourceLocationBlock.java (new)
* AddDirectorySourceLocationWizard.java (new)
* AddProjectSourceLocationBlock.java (new)
* AddProjectSourceLocationWizard.java (new)
* AddSourceLocationWizard.java
* SourceLocationSelectionPage.java (new)
* SourceLocationWizardNode.java (new)
* CDebugImages.java
* AttachSourceLocationBlock.java renamed to AddDirectorySourceLocationBlock.java
* AttachSourceLocationDialog.java (deleted - dialog replaced by wizard).
* INewSourceLocationWizard.java (new)
* SourceLookupBlock.java
Added new wizard and tool icons.
2002-12-19 Mikhail Khodjaiants
Implementing the 'Source Lookup' property page.
* AddSourceLocationWizard.java

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -72,6 +72,13 @@ public class CDebugImages
public static final String IMG_LCL_MEMORY_CLEAR = NAME_PREFIX + "memory_clear.gif"; //$NON-NLS-1$
public static final String IMG_LCL_SHOW_ASCII = NAME_PREFIX + "show_ascii.gif"; //$NON-NLS-1$
public static final String IMG_TOOLS_ADD_DIR_SOURCE_LOCATION = NAME_PREFIX + "adddirsource_wiz.gif"; //$NON-NLS-1$
public static final String IMG_TOOLS_ADD_PRJ_SOURCE_LOCATION = NAME_PREFIX + "addprjsource_wiz.gif"; //$NON-NLS-1$
public static final String IMG_WIZBAN_ADD_SOURCE_LOCATION = NAME_PREFIX + "add_source_location_wiz.gif"; //$NON-NLS-1$
public static final String IMG_WIZBAN_ADD_DIR_SOURCE_LOCATION = NAME_PREFIX + "add_dir_source_location_wiz.gif"; //$NON-NLS-1$
public static final String IMG_WIZBAN_ADD_PRJ_SOURCE_LOCATION = NAME_PREFIX + "add_prj_source_location_wiz.gif"; //$NON-NLS-1$
/*
* Set of predefined Image Descriptors.
*/
@ -101,6 +108,11 @@ public class CDebugImages
public static final ImageDescriptor DESC_OBJS_DISASSEMBLY = createManaged( T_OBJ, IMG_OBJS_DISASSEMBLY );
public static final ImageDescriptor DESC_OBJS_PROJECT = createManaged( T_OBJ, IMG_OBJS_PROJECT );
public static final ImageDescriptor DESC_OBJS_FOLDER = createManaged( T_OBJ, IMG_OBJS_FOLDER );
public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_SOURCE_LOCATION ); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_ADD_PRJ_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_PRJ_SOURCE_LOCATION ); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_ADD_DIR_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_DIR_SOURCE_LOCATION ); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOLS_ADD_PRJ_SOURCE_LOCATION = createManaged( T_CTOOL, IMG_TOOLS_ADD_PRJ_SOURCE_LOCATION ); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOLS_ADD_DIR_SOURCE_LOCATION = createManaged( T_CTOOL, IMG_TOOLS_ADD_DIR_SOURCE_LOCATION ); //$NON-NLS-1$
/**
* Returns the image managed under the given key in this registry.

View file

@ -3,16 +3,19 @@
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.ui.sourcelookup;
package org.eclipse.cdt.debug.internal.ui.wizards;
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
import org.eclipse.cdt.debug.internal.ui.SWTUtil;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -28,20 +31,22 @@ import org.eclipse.swt.widgets.Text;
*
* @since: Dec 12, 2002
*/
public class AttachSourceLocationBlock
public class AddDirectorySourceLocationBlock
{
private Composite fControl = null;
private Text fLocationText = null;
private Text fAssociationText = null;
private Button fAssocitedCheckButton = null;
private FontMetrics fFontMetrics;
private Shell fShell = null;
private IPath fInitialAssosciationPath = null;
/**
* Constructor for AttachSourceLocationBlock.
* Constructor for AddDirectorySourceLocationBlock.
*/
public AttachSourceLocationBlock()
public AddDirectorySourceLocationBlock( IPath initialAssosciationPath )
{
fInitialAssosciationPath = initialAssosciationPath;
}
public void createControl( Composite parent )
@ -49,29 +54,22 @@ public class AttachSourceLocationBlock
fShell = parent.getShell();
fControl = new Composite( parent, SWT.NONE );
fControl.setLayout( new GridLayout() );
fControl.setLayoutData( new GridData( GridData.FILL_BOTH ) );
fControl.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
fControl.setFont( JFaceResources.getDialogFont() );
createLocationControls( fControl );
createAssociationControls( fControl );
}
public void setInitialLocationPath( IPath path )
{
if ( path != null )
{
fLocationText.setText( path.toOSString() );
}
setInitialAssociationPath();
}
public void setInitialAssociationPath( IPath path )
private void setInitialAssociationPath()
{
fAssociationText.setEnabled( ( path != null ) );
fAssocitedCheckButton.setEnabled( ( path != null ) );
fAssocitedCheckButton.setSelection( ( path != null ) );
if ( path != null )
fAssociationText.setEnabled( ( fInitialAssosciationPath != null ) );
fAssocitedCheckButton.setSelection( ( fInitialAssosciationPath != null ) );
if ( fInitialAssosciationPath != null )
{
fAssociationText.setText( path.toOSString() );
fAssociationText.setText( fInitialAssosciationPath.toOSString() );
}
}
@ -173,4 +171,66 @@ public class AttachSourceLocationBlock
}
return "";
}
public IDirectorySourceLocation getSourceLocation()
{
if ( isLocationPathValid() )
{
Path association = ( isAssociationPathValid() ) ? new Path( getAssociationPath() ) : null;
return new CDirectorySourceLocation( new Path( getLocationPath() ), association );
}
return null;
}
public void addDirectoryModifyListener( ModifyListener listener )
{
if ( fLocationText != null )
{
fLocationText.addModifyListener( listener );
}
}
public void addAssociationModifyListener( ModifyListener listener )
{
if ( fAssociationText != null )
{
fAssociationText.addModifyListener( listener );
}
}
public void removeDirectoryModifyListener( ModifyListener listener )
{
if ( fLocationText != null )
{
fLocationText.removeModifyListener( listener );
}
}
public void removeAssociationModifyListener( ModifyListener listener )
{
if ( fAssociationText != null )
{
fAssociationText.removeModifyListener( listener );
}
}
private boolean isLocationPathValid()
{
if ( fLocationText != null && Path.EMPTY.isValidPath( fLocationText.getText().trim() ) )
{
Path path = new Path( fLocationText.getText().trim() );
return ( path.toFile().exists() && path.toFile().isAbsolute() );
}
return false;
}
public boolean isAssociationPathValid()
{
String pathString = getAssociationPath();
if ( pathString.length() > 0 )
{
return Path.EMPTY.isValidPath( pathString );
}
return true;
}
}

View file

@ -0,0 +1,194 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.wizards;
import java.io.File;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
/**
*
* Enter type comment.
*
* @since Dec 23, 2002
*/
public class AddDirectorySourceLocationWizard extends Wizard implements INewSourceLocationWizard
{
protected static final String PAGE_NAME = "AddDirectorySourceLocationWizardPage";
/**
*
* Enter type comment.
*
* @since Dec 25, 2002
*/
public class AddDirtectorySourceLocationWizardPage extends WizardPage
{
private AddDirectorySourceLocationBlock fAttachBlock;
/**
* Constructor for AddDirtectorySourceLocationWizardPage.
* @param pageName
* @param title
* @param titleImage
*/
public AddDirtectorySourceLocationWizardPage( AddDirectorySourceLocationWizard wizard, IPath initialAssociationPath )
{
super( PAGE_NAME, "Select Directory", CDebugImages.DESC_WIZBAN_ADD_DIR_SOURCE_LOCATION );
setWindowTitle( "Add Directory Source Location" );
setMessage( "Add a local file system directory to the source locations list." );
setWizard( wizard );
fAttachBlock = new AddDirectorySourceLocationBlock( initialAssociationPath );
}
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
*/
public void createControl( Composite parent )
{
Composite composite = new Composite( parent, SWT.NULL );
composite.setLayout( new GridLayout() );
composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
fAttachBlock.createControl( composite );
fAttachBlock.addDirectoryModifyListener( new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
directoryChanged();
}
} );
fAttachBlock.addAssociationModifyListener( new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
associationChanged();
}
} );
setControl( composite );
updateState();
}
protected void directoryChanged()
{
updateState();
}
protected void associationChanged()
{
updateState();
}
private void updateState()
{
boolean complete = true;
setErrorMessage( null );
String dirText = fAttachBlock.getLocationPath();
if ( dirText.length() == 0 )
{
setErrorMessage( "Directory must not be empty." );
complete = false;
}
else
{
File file = new File( dirText );
if ( !file.exists() || !file.isDirectory() )
{
setErrorMessage( "Directory does not exist." );
complete = false;
}
else if ( !file.isAbsolute() )
{
setErrorMessage( "Directory must be absolute." );
complete = false;
}
}
setPageComplete( complete );
}
private IDirectorySourceLocation getSourceLocation()
{
return fAttachBlock.getSourceLocation();
}
protected boolean finish()
{
fSourceLocation = getSourceLocation();
return ( fSourceLocation != null );
}
}
protected IDirectorySourceLocation fSourceLocation = null;
private IPath fInitialAssociationPath = null;
/**
* Constructor for AddDirectorySourceLocationWizard.
*/
public AddDirectorySourceLocationWizard()
{
super();
}
/**
* Constructor for AddDirectorySourceLocationWizard.
*/
public AddDirectorySourceLocationWizard( IPath initialAssociationPath )
{
super();
fInitialAssociationPath = initialAssociationPath;
}
/**
* @see org.eclipse.jface.wizard.IWizard#performFinish()
*/
public boolean performFinish()
{
AddDirtectorySourceLocationWizardPage page = (AddDirtectorySourceLocationWizardPage)getStartingPage();
if ( page != null )
{
return page.finish();
}
return false;
}
/**
* @see org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard#getDescription()
*/
public String getDescription()
{
return "Add a local file system directory to the source locations list.";
}
/**
* @see org.eclipse.jface.wizard.IWizard#addPages()
*/
public void addPages()
{
addPage( new AddDirtectorySourceLocationWizardPage( this, fInitialAssociationPath ) );
}
/**
* @see org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard#getSourceLocation()
*/
public ICSourceLocation getSourceLocation()
{
return fSourceLocation;
}
}

View file

@ -0,0 +1,132 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.wizards;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CProjectSourceLocation;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
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.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
*
* Enter type comment.
*
* @since Dec 27, 2002
*/
public class AddProjectSourceLocationBlock
{
private Composite fControl = null;
private Shell fShell = null;
private TableViewer fViewer;
protected IProject[] fProjects = null;
/**
* Constructor for AddProjectSourceLocationBlock.
*/
public AddProjectSourceLocationBlock( IProject[] projects )
{
fProjects = projects;
}
public void createControl( Composite parent )
{
fShell = parent.getShell();
fControl = new Composite( parent, SWT.NONE );
fControl.setLayout( new GridLayout() );
fControl.setLayoutData( new GridData( GridData.FILL_BOTH ) );
fControl.setFont( JFaceResources.getDialogFont() );
//Create a table for the list
Table table = new Table( fControl, SWT.BORDER | SWT.SINGLE );
GridData data = new GridData( GridData.FILL_BOTH );
table.setLayoutData( data );
// the list viewer
fViewer = new TableViewer( table );
fViewer.setContentProvider( new IStructuredContentProvider()
{
public Object[] getElements( Object inputElement )
{
return fProjects;
}
public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
{
}
public void dispose()
{
}
} );
fViewer.setLabelProvider( new WorkbenchLabelProvider() );
fViewer.setInput( fProjects );
}
public Control getControl()
{
return fControl;
}
public IProjectSourceLocation getSourceLocation()
{
if ( fViewer != null )
{
if ( !((IStructuredSelection)fViewer.getSelection()).isEmpty() )
{
return new CProjectSourceLocation( (IProject)((IStructuredSelection)fViewer.getSelection()).getFirstElement() );
}
}
return null;
}
public void addSelectionChangedListener( ISelectionChangedListener listener )
{
if ( fViewer != null )
{
fViewer.addSelectionChangedListener( listener );
}
}
public void removeSelectionChangedListener( ISelectionChangedListener listener )
{
if ( fViewer != null )
{
fViewer.removeSelectionChangedListener( listener );
}
}
public void addDoubleClickListener( IDoubleClickListener listener )
{
if ( fViewer != null )
{
fViewer.addDoubleClickListener( listener );
}
}
public void removeDoubleClickListener( IDoubleClickListener listener )
{
if ( fViewer != null )
{
fViewer.removeDoubleClickListener( listener );
}
}
}

View file

@ -0,0 +1,149 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.wizards;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
/**
*
* Enter type comment.
*
* @since Dec 23, 2002
*/
public class AddProjectSourceLocationWizard extends Wizard implements INewSourceLocationWizard
{
protected static final String PAGE_NAME = "AddProjectSourceLocationWizardPage";
protected IProject[] fProjects = null;
protected IProjectSourceLocation fSourceLocation = null;
/**
*
* Enter type comment.
*
* @since Dec 27, 2002
*/
public class AddProjectSourceLocationWizardPage extends WizardPage
implements ISelectionChangedListener, IDoubleClickListener
{
private AddProjectSourceLocationBlock fBlock;
/**
* Constructor for AddProjectSourceLocationWizardPage.
* @param pageName
*/
public AddProjectSourceLocationWizardPage( AddProjectSourceLocationWizard wizard )
{
super( PAGE_NAME, "Select Project", CDebugImages.DESC_WIZBAN_ADD_PRJ_SOURCE_LOCATION );
setWindowTitle( "Add Project Source Location" );
setMessage( "Add an existing workspace project to the source locations list." );
setWizard( wizard );
fBlock = new AddProjectSourceLocationBlock( fProjects );
setPageComplete( false );
}
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
*/
public void createControl( Composite parent )
{
Composite composite = new Composite( parent, SWT.NULL );
composite.setLayout( new GridLayout() );
composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
fBlock.createControl( composite );
fBlock.addDoubleClickListener( this );
fBlock.addSelectionChangedListener( this );
setControl( composite );
}
/**
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
*/
public void selectionChanged( SelectionChangedEvent event )
{
setPageComplete( !event.getSelection().isEmpty() );
}
/**
* @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(DoubleClickEvent)
*/
public void doubleClick( DoubleClickEvent event )
{
}
protected boolean finish()
{
if ( fBlock != null )
{
fSourceLocation = fBlock.getSourceLocation();
}
return ( fSourceLocation != null );
}
}
/**
* Constructor for AddProjectSourceLocationWizard.
*/
public AddProjectSourceLocationWizard( IProject[] projects )
{
super();
fProjects = projects;
}
/**
* @see org.eclipse.jface.wizard.IWizard#performFinish()
*/
public boolean performFinish()
{
AddProjectSourceLocationWizardPage page = (AddProjectSourceLocationWizardPage)getStartingPage();
if ( page != null )
{
return page.finish();
}
return false;
}
/**
* @see org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard#getDescription()
*/
public String getDescription()
{
return "Add an existing project to the source locations list.";
}
/**
* @see org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard#getSourceLocation()
*/
public ICSourceLocation getSourceLocation()
{
return fSourceLocation;
}
/**
* @see org.eclipse.jface.wizard.IWizard#addPages()
*/
public void addPages()
{
addPage( new AddProjectSourceLocationWizardPage( this ) );
}
}

View file

@ -5,47 +5,28 @@
*/
package org.eclipse.cdt.debug.internal.ui.wizards;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardSelectionPage;
import org.eclipse.swt.widgets.Composite;
/**
* Enter type comment.
*
* @since: Dec 20, 2002
*/
public class AddSourceLocationWizard extends Wizard
public class AddSourceLocationWizard extends Wizard implements INewSourceLocationWizard
{
/**
* Enter type comment.
*
* @since: Dec 20, 2002
*/
public class SourceLocationSelectionPage extends WizardSelectionPage
{
private ICSourceLocation[] fLocations = null;
/**
* Constructor for SourceLocationSelectionPage.
* @param pageName
*/
public SourceLocationSelectionPage( String pageName )
{
super( pageName );
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
*/
public void createControl( Composite parent )
{
}
}
/**
* Constructor for AddSourceLocationWizard.
*/
public AddSourceLocationWizard()
public AddSourceLocationWizard( ICSourceLocation[] locations )
{
super();
setWindowTitle( "Add Source Location" );
setForcePreviousAndNextButtons( true );
fLocations = locations;
}
/* (non-Javadoc)
@ -61,6 +42,24 @@ public class AddSourceLocationWizard extends Wizard
*/
public void addPages()
{
addPage( new SourceLocationSelectionPage( "Add Source Location" ) );
addPage( new SourceLocationSelectionPage( fLocations ) );
}
public ICSourceLocation getSourceLocation()
{
SourceLocationSelectionPage page = (SourceLocationSelectionPage)getStartingPage();
if ( page != null )
{
return page.getSourceLocation();
}
return null;
}
/**
* @see org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard#getDescription()
*/
public String getDescription()
{
return "";
}
}

View file

@ -0,0 +1,222 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.wizards;
import java.util.ArrayList;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.IWizardNode;
import org.eclipse.jface.wizard.WizardSelectionPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
/**
*
* Enter type comment.
*
* @since Dec 24, 2002
*/
public class SourceLocationSelectionPage extends WizardSelectionPage
implements ISelectionChangedListener,
IDoubleClickListener
{
private static final String PAGE_NAME = "Add Source Location";
private final static int SIZING_LISTS_HEIGHT = 200;
private final static int SIZING_LISTS_WIDTH = 150;
protected TableViewer fWizardSelectionViewer;
protected Object[] fElements = null;
/**
* Constructor for SourceLocationSelectionPage.
* @param pageName
*/
public SourceLocationSelectionPage( ICSourceLocation[] locations )
{
super( PAGE_NAME );
setTitle( "Select" );
setImageDescriptor( CDebugImages.DESC_WIZBAN_ADD_SOURCE_LOCATION );
fElements = new Object[] { new AddProjectSourceLocationWizard( getProjectList( locations ) ),
new AddDirectorySourceLocationWizard() };
}
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
*/
public void createControl( Composite parent )
{
// create composite for page.
Composite outerContainer = new Composite( parent, SWT.NONE );
outerContainer.setLayout( new GridLayout() );
outerContainer.setLayoutData( new GridData( GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL ) );
new Label( outerContainer, SWT.NONE ).setText( "Select source location type:" );
//Create a table for the list
Table table = new Table( outerContainer, SWT.BORDER );
GridData data = new GridData( GridData.FILL_HORIZONTAL );
data.widthHint = SIZING_LISTS_WIDTH;
data.heightHint = SIZING_LISTS_HEIGHT;
table.setLayoutData( data );
// the list viewer
fWizardSelectionViewer = new TableViewer( table );
fWizardSelectionViewer.setContentProvider( new IStructuredContentProvider()
{
public Object[] getElements( Object inputElement )
{
return fElements;
}
public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
{
}
public void dispose()
{
}
} );
fWizardSelectionViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof AddProjectSourceLocationWizard )
{
return "Existing Project Into Workspace";
}
if ( element instanceof AddDirectorySourceLocationWizard )
{
return "File System Directory";
}
return super.getText( element );
}
/**
* @see org.eclipse.jface.viewers.LabelProvider#getImage(Object)
*/
public Image getImage(Object element)
{
if ( element instanceof AddProjectSourceLocationWizard )
{
return CDebugImages.get( CDebugImages.IMG_TOOLS_ADD_PRJ_SOURCE_LOCATION );
}
if ( element instanceof AddDirectorySourceLocationWizard )
{
return CDebugImages.get( CDebugImages.IMG_TOOLS_ADD_DIR_SOURCE_LOCATION );
}
return super.getImage( element );
}
} );
fWizardSelectionViewer.addSelectionChangedListener( this );
fWizardSelectionViewer.addDoubleClickListener( this );
fWizardSelectionViewer.setInput( fElements );
fWizardSelectionViewer.setSelection( new StructuredSelection( fElements[0] ) );
setControl( outerContainer );
}
/**
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
*/
public void selectionChanged( SelectionChangedEvent event )
{
setErrorMessage( null );
IStructuredSelection selection = (IStructuredSelection)event.getSelection();
INewSourceLocationWizard currentWizardSelection = (INewSourceLocationWizard)selection.getFirstElement();
if ( currentWizardSelection == null )
{
setMessage( null );
setSelectedNode( null );
return;
}
setSelectedNode( createWizardNode( currentWizardSelection ) );
setMessage( currentWizardSelection.getDescription() );
}
/**
* @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(DoubleClickEvent)
*/
public void doubleClick( DoubleClickEvent event )
{
selectionChanged( new SelectionChangedEvent( fWizardSelectionViewer, fWizardSelectionViewer.getSelection() ) );
getContainer().showPage( getNextPage() );
}
private IWizardNode createWizardNode( INewSourceLocationWizard wizard )
{
return new SourceLocationWizardNode( wizard );
}
/**
* @see org.eclipse.jface.dialogs.IDialogPage#dispose()
*/
public void dispose()
{
if ( fElements != null )
{
for ( int i = 0; i < fElements.length; ++i )
{
((INewSourceLocationWizard)fElements[i]).dispose();
}
fElements = null;
}
super.dispose();
}
public ICSourceLocation getSourceLocation()
{
return ((INewSourceLocationWizard)getSelectedNode().getWizard()).getSourceLocation();
}
private IProject[] getProjectList( ICSourceLocation[] locations )
{
ArrayList projects = new ArrayList( locations.length );
for ( int i = 0; i < locations.length; ++i )
{
if ( locations[i] instanceof IProjectSourceLocation )
{
projects.add( ((IProjectSourceLocation)locations[i]).getProject() );
}
}
IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
ArrayList result = new ArrayList( allProjects.length );
for ( int i = 0; i < allProjects.length; ++i )
{
if ( ( CoreModel.getDefault().hasCNature( allProjects[i] ) || CoreModel.getDefault().hasCNature( allProjects[i] ) ) &&
allProjects[i].isOpen() &&
!projects.contains( allProjects[i] ) )
{
result.add( allProjects[i] );
}
}
return (IProject[])result.toArray( new IProject[result.size()] );
}
}

View file

@ -0,0 +1,61 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.wizards;
import org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardNode;
import org.eclipse.swt.graphics.Point;
/**
*
* Enter type comment.
*
* @since Dec 25, 2002
*/
public class SourceLocationWizardNode implements IWizardNode
{
private INewSourceLocationWizard fWizard = null;
/**
* Constructor for SourceLocationWizardNode.
*/
public SourceLocationWizardNode( INewSourceLocationWizard wizard )
{
fWizard = wizard;
}
/**
* @see org.eclipse.jface.wizard.IWizardNode#dispose()
*/
public void dispose()
{
}
/**
* @see org.eclipse.jface.wizard.IWizardNode#getExtent()
*/
public Point getExtent()
{
return new Point( -1, -1 );
}
/**
* @see org.eclipse.jface.wizard.IWizardNode#getWizard()
*/
public IWizard getWizard()
{
return fWizard;
}
/**
* @see org.eclipse.jface.wizard.IWizardNode#isContentCreated()
*/
public boolean isContentCreated()
{
return ( fWizard != null && fWizard.getPageCount() > 0 );
}
}

View file

@ -1,130 +0,0 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.ui.sourcelookup;
import java.text.MessageFormat;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
/**
* Enter type comment.
*
* @since: Dec 12, 2002
*/
public class AttachSourceLocationDialog extends Dialog
{
private IPath fLocationPath = null;
private IPath fAssociationPath = null;
private AttachSourceLocationBlock fAttachBlock;
/**
* Constructor for AttachSourceLocationDialog.
* @param parentShell
*/
public AttachSourceLocationDialog( Shell parentShell )
{
super( parentShell );
fAttachBlock = new AttachSourceLocationBlock();
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
*/
protected Control createDialogArea( Composite parent )
{
Composite composite = (Composite)super.createDialogArea( parent );
getShell().setText( "Attach Source Location" );
fAttachBlock.createControl( composite );
fAttachBlock.setInitialAssociationPath( fAssociationPath );
return composite;
}
public void setInitialPath( IPath path )
{
fAssociationPath = path;
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
protected void okPressed()
{
String locationString = fAttachBlock.getLocationPath();
if ( locationString.length() == 0 )
{
MessageDialog.openError( getShell(), getShell().getText(), "Location directory is not selected" );
return;
}
if ( !isLocationPathValid( locationString ) )
{
MessageDialog.openError( getShell(), getShell().getText(), MessageFormat.format( "Invalid path: ''{0}''", new String[] { locationString } ) );
return;
}
String associationString = fAttachBlock.getAssociationPath();
if ( !isAssociationPathValid( associationString ) )
{
MessageDialog.openError( getShell(), getShell().getText(), MessageFormat.format( "Invalid path: ''{0}''", new String[] { associationString } ) );
return;
}
fLocationPath = getLocation0();
fAssociationPath = getAssociation0();
super.okPressed();
}
public boolean isLocationPathValid( String pathString )
{
if ( Path.EMPTY.isValidPath( pathString ) )
{
Path path = new Path( pathString );
return path.toFile().exists();
}
return false;
}
public boolean isAssociationPathValid( String pathString )
{
if ( pathString.length() > 0 )
{
return Path.EMPTY.isValidPath( pathString );
}
return true;
}
public IPath getLocation()
{
return fLocationPath;
}
private IPath getLocation0()
{
if ( Path.EMPTY.isValidPath( fAttachBlock.getLocationPath() ) )
{
return new Path( fAttachBlock.getLocationPath() );
}
return null;
}
public IPath getAssociation()
{
return fAssociationPath;
}
private IPath getAssociation0()
{
if ( Path.EMPTY.isValidPath( fAttachBlock.getAssociationPath() ) )
{
return new Path( fAttachBlock.getAssociationPath() );
}
return null;
}
}

View file

@ -10,15 +10,18 @@ import java.text.MessageFormat;
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
import org.eclipse.cdt.debug.internal.ui.wizards.AddDirectorySourceLocationWizard;
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@ -244,19 +247,22 @@ public class CUISourceLocator implements IAdaptable
protected void attachSourceLocation( String fileName )
{
AttachSourceLocationDialog dialog = new AttachSourceLocationDialog( CDebugUIPlugin.getActiveWorkbenchShell() );
Path path = new Path( fileName );
IPath path = new Path( fileName );
INewSourceLocationWizard wizard = null;
if ( path.isAbsolute() )
{
dialog.setInitialPath( path.removeLastSegments( 1 ) );
path = path.removeLastSegments( 1 );
wizard = new AddDirectorySourceLocationWizard( path );
}
if ( dialog.open() == Dialog.OK )
else
{
if ( dialog.getLocation() != null )
{
fSourceLocator.addSourceLocation( new CDirectorySourceLocation( dialog.getLocation(), dialog.getAssociation() ) );
fNewLocationAttached = true;
}
wizard = new AddSourceLocationWizard( fSourceLocator.getSourceLocations() );
}
WizardDialog dialog = new WizardDialog( CDebugUIPlugin.getActiveWorkbenchShell(), wizard );
if ( dialog.open() == dialog.OK )
{
fSourceLocator.addSourceLocation( wizard.getSourceLocation() );
fNewLocationAttached = true;
}
}

View file

@ -0,0 +1,21 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.ui.sourcelookup;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.jface.wizard.IWizard;
/**
*
* Enter type comment.
*
* @since Dec 25, 2002
*/
public interface INewSourceLocationWizard extends IWizard
{
String getDescription();
ICSourceLocation getSourceLocation();
}

View file

@ -6,8 +6,8 @@
package org.eclipse.cdt.debug.ui.sourcelookup;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CProjectSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
import org.eclipse.cdt.debug.internal.ui.dialogfields.DialogField;
@ -51,24 +51,24 @@ public class SourceLookupBlock
{
public String getText( Object element )
{
if ( element instanceof CProjectSourceLocation )
if ( element instanceof IProjectSourceLocation )
{
return ((CProjectSourceLocation)element).getProject().getName();
return ((IProjectSourceLocation)element).getProject().getName();
}
if ( element instanceof CDirectorySourceLocation )
if ( element instanceof IDirectorySourceLocation )
{
return ((CDirectorySourceLocation)element).getDirectory().toOSString();
return ((IDirectorySourceLocation)element).getDirectory().toOSString();
}
return null;
}
public Image getImage( Object element )
{
if ( element instanceof CProjectSourceLocation )
if ( element instanceof IProjectSourceLocation )
{
return CDebugImages.get( CDebugImages.IMG_OBJS_PROJECT );
}
if ( element instanceof CDirectorySourceLocation )
if ( element instanceof IDirectorySourceLocation )
{
return CDebugImages.get( CDebugImages.IMG_OBJS_FOLDER );
}
@ -88,23 +88,20 @@ public class SourceLookupBlock
String[] buttonLabels = new String[]
{
/* 0 */ "Add...",
/* 1 */ "Edit...",
/* 2 */ null,
/* 3 */ "Up",
/* 4 */ "Down",
/* 5 */ null,
/* 6 */ "Remove",
/* 1 */ null,
/* 2 */ "Up",
/* 3 */ "Down",
/* 4 */ null,
/* 5 */ "Remove",
};
SourceLookupAdapter adapter = new SourceLookupAdapter();
fSourceListField = new ListDialogField( adapter, buttonLabels, new SourceLookupLabelProvider() );
fSourceListField.setLabelText( "Source Locations" );
fSourceListField.setUpButtonIndex( 3 );
fSourceListField.setDownButtonIndex( 4 );
fSourceListField.setRemoveButtonIndex( 6 );
fSourceListField.enableButton( 1, false );
fSourceListField.setUpButtonIndex( 2 );
fSourceListField.setDownButtonIndex( 3 );
fSourceListField.setRemoveButtonIndex( 5 );
}
public void createControl( Composite parent )
@ -155,15 +152,18 @@ public class SourceLookupBlock
{
}
protected ICSourceLocation[] getSourceLocations()
public ICSourceLocation[] getSourceLocations()
{
return (ICSourceLocation[])fSourceListField.getElements().toArray( new ICSourceLocation[fSourceListField.getElements().size()] );
}
private void addSourceLocation()
{
AddSourceLocationWizard wizard = new AddSourceLocationWizard();
AddSourceLocationWizard wizard = new AddSourceLocationWizard( getSourceLocations() );
WizardDialog dialog = new WizardDialog( fControl.getShell(), wizard );
dialog.open();
if ( dialog.open() == dialog.OK )
{
fSourceListField.addElement( wizard.getSourceLocation() );
}
}
}