? icons/full/wizban ? icons/full/wizban ?
icons/full/wizban ? icons/full/etool16 ? icons/full/etool16 ?
icons/full/dtool16 ? icons/full/dtool16 ? icons/full/ctool16 ?
icons/full/ctool16 Index:
ChangeLog =================================================================== RCS
file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v retrieving revision
1.64 diff -u -r1.64 ChangeLog --- ChangeLog 20 Dec 2002 22:30:00
-0000 1.64 +++ ChangeLog 30 Dec 2002 00:05:28 -0000 @@ -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 Index:
icons/full/add_dir_source_location_wiz.gif =================================================================== RCS
file: icons/full/add_dir_source_location_wiz.gif diff -N
icons/full/add_dir_source_location_wiz.gif Binary files /dev/null and
add_dir_source_location_wiz.gif differ Index:
icons/full/add_prj_source_location_wiz.gif =================================================================== RCS
file: icons/full/add_prj_source_location_wiz.gif diff -N
icons/full/add_prj_source_location_wiz.gif Binary files /dev/null and
add_prj_source_location_wiz.gif differ Index:
icons/full/add_source_location_wiz.gif =================================================================== RCS
file: icons/full/add_source_location_wiz.gif diff -N
icons/full/add_source_location_wiz.gif Binary files /dev/null and
add_source_location_wiz.gif differ Index:
icons/full/adddirsource_wiz.gif =================================================================== RCS
file: icons/full/adddirsource_wiz.gif diff -N
icons/full/adddirsource_wiz.gif Binary files /dev/null and
adddirsource_wiz.gif differ Index:
icons/full/addprjsource_wiz.gif =================================================================== RCS
file: icons/full/addprjsource_wiz.gif diff -N
icons/full/addprjsource_wiz.gif Binary files /dev/null and
addprjsource_wiz.gif differ Index:
src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java,v retrieving
revision 1.10 diff -u -r1.10 CDebugImages.java ---
src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java 20 Dec 2002
22:30:00 -0000 1.10 +++
src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java 30 Dec 2002
00:05:29 -0000 @@ -72,6 +72,13 @@ 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 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. Index:
src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java diff
-N
src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java ---
/dev/null 1 Jan 1970 00:00:00 -0000 +++
src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java 30
Dec 2002 00:05:30 -0000 @@ -0,0 +1,236 @@ +/* + *(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.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.layout.GridData; +import
org.eclipse.swt.layout.GridLayout; +import
org.eclipse.swt.widgets.Button; +import
org.eclipse.swt.widgets.Composite; +import
org.eclipse.swt.widgets.Control; +import
org.eclipse.swt.widgets.DirectoryDialog; +import
org.eclipse.swt.widgets.Label; +import
org.eclipse.swt.widgets.Shell; +import
org.eclipse.swt.widgets.Text; + +/** + * Enter type comment. + *
+ * @since: Dec 12, 2002 + */ +public class
AddDirectorySourceLocationBlock +{ + private Composite fControl =
null; + private Text fLocationText = null; + private Text
fAssociationText = null; + private Button fAssocitedCheckButton =
null; + private Shell fShell = null; + + private IPath
fInitialAssosciationPath = null; + + /** + * Constructor for
AddDirectorySourceLocationBlock. + */ + public
AddDirectorySourceLocationBlock( IPath initialAssosciationPath
) + { + fInitialAssosciationPath =
initialAssosciationPath; + } + + public void
createControl( Composite parent ) + { + fShell =
parent.getShell(); + fControl = new Composite( parent, SWT.NONE
); + fControl.setLayout( new GridLayout()
); + fControl.setLayoutData( new GridData(
GridData.FILL_HORIZONTAL ) ); + fControl.setFont(
JFaceResources.getDialogFont()
); + + createLocationControls( fControl
); + createAssociationControls( fControl
); + + setInitialAssociationPath(); + } + + private
void
setInitialAssociationPath() + { + fAssociationText.setEnabled(
( fInitialAssosciationPath != null )
); + fAssocitedCheckButton.setSelection( (
fInitialAssosciationPath != null ) ); + if (
fInitialAssosciationPath != null
) + { + fAssociationText.setText(
fInitialAssosciationPath.toOSString()
); + } + } + + public Control
getControl() + { + return
fControl; + } + + protected void createLocationControls(
Composite parent ) + { + PixelConverter converter = new
PixelConverter( parent ); + Label label = new Label( parent,
SWT.NONE ); + label.setText( "Select location directory:"
); + label.setLayoutData( new GridData( GridData.FILL_HORIZONTAL |
GridData.GRAB_HORIZONTAL ) ); + Composite composite = new
Composite( parent, SWT.NONE ); + composite.setLayout( new
GridLayout( 2, false ) ); + GridData data = "" GridData(
GridData.FILL_BOTH ); + data.widthHint =
converter.convertWidthInCharsToPixels( 70
); + composite.setLayoutData( data
); + fLocationText = new Text( composite, SWT.SINGLE | SWT.BORDER
); + fLocationText.setLayoutData( new GridData(
GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL ) ); + Button
button = createButton( composite, "&Browse..."
); + button.addSelectionListener( new SelectionAdapter()
+ { + /*
(non-Javadoc) +
* @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(SelectionEvent) +
*/ + public
void widgetSelected( SelectionEvent e
) + { + selectLocation(); + } + }
); + } + + protected void
selectLocation() + { + DirectoryDialog dialog = new
DirectoryDialog( fShell ); + dialog.setMessage( "Select Location
Directory" ); + String result = dialog.open(); + if
( result != null
) + { + fLocationText.setText( result
); + } + } + + protected void
createAssociationControls( Composite parent
) + { + Composite composite = new Composite( parent,
SWT.NONE ); + composite.setLayout( new GridLayout()
); + GridData data = "" GridData( GridData.FILL_BOTH
); + composite.setLayoutData( data
); + fAssocitedCheckButton = new Button( composite, SWT.CHECK
); + fAssocitedCheckButton.setText( "&Associate with"
); + fAssociationText = new Text( composite, SWT.SINGLE |
SWT.BORDER ); + fAssociationText.setLayoutData( new GridData(
GridData.FILL_HORIZONTAL )
); + fAssocitedCheckButton.addSelectionListener( new
SelectionAdapter() + { + /*
(non-Javadoc) +
* @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(SelectionEvent) +
*/ + public
void widgetSelected(SelectionEvent
e) + { + associationSelectionChanged(); + } + + }
); + } + + protected void
associationSelectionChanged() + { + boolean checked =
fAssocitedCheckButton.getSelection(); + fAssociationText.setEnabled(
checked ); + if ( !checked
) + fAssociationText.setText( ""
); + } + + protected Button createButton( Composite parent,
String label ) + { + Button button = new Button( parent,
SWT.PUSH ); + button.setText( label ); + GridData
data = "" GridData( GridData.END ); + button.setLayoutData( data
); + SWTUtil.setButtonDimensionHint( button
); + button.setFont( parent.getFont()
); + + return button; + } + + public
String getLocationPath() + { + return
fLocationText.getText().trim(); + } + + public String
getAssociationPath() + { + if (
fAssocitedCheckButton.getSelection()
) + { + return
fAssociationText.getText().trim(); + } + 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; + } +} Index:
src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationWizard.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationWizard.java diff
-N
src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationWizard.java ---
/dev/null 1 Jan 1970 00:00:00 -0000 +++
src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationWizard.java 30
Dec 2002 00:05:30 -0000 @@ -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; + } +} Index:
src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java diff
-N
src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java ---
/dev/null 1 Jan 1970 00:00:00 -0000 +++
src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java 30
Dec 2002 00:05:31 -0000 @@ -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 = "" 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 ); + } + } +} Index:
src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationWizard.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationWizard.java diff
-N
src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationWizard.java ---
/dev/null 1 Jan 1970 00:00:00 -0000 +++
src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationWizard.java 30
Dec 2002 00:05:30 -0000 @@ -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 ) ); + } +} Index:
src/org/eclipse/cdt/debug/internal/ui/wizards/AddSourceLocationWizard.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddSourceLocationWizard.java,v retrieving
revision 1.1 diff -u -r1.1 AddSourceLocationWizard.java ---
src/org/eclipse/cdt/debug/internal/ui/wizards/AddSourceLocationWizard.java 20
Dec 2002 22:30:00 -0000 1.1 +++
src/org/eclipse/cdt/debug/internal/ui/wizards/AddSourceLocationWizard.java 30
Dec 2002 00:05:30 -0000 @@ -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 - { - - /** - *
Constructor for SourceLocationSelectionPage. - * @param
pageName - */ - public SourceLocationSelectionPage(
String pageName ) - { - super( pageName
); - } + private ICSourceLocation[] fLocations =
null; - /* (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 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
""; } } Index:
src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationSelectionPage.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationSelectionPage.java diff
-N
src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationSelectionPage.java ---
/dev/null 1 Jan 1970 00:00:00 -0000 +++
src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationSelectionPage.java 30
Dec 2002 00:05:30 -0000 @@ -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 = "" 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()]
); + } +} Index:
src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationWizardNode.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationWizardNode.java diff
-N
src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationWizardNode.java ---
/dev/null 1 Jan 1970 00:00:00 -0000 +++
src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationWizardNode.java 30
Dec 2002 00:05:30 -0000 @@ -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 ); + } +} Index:
src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationBlock.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationBlock.java diff
-N
src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationBlock.java ---
src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationBlock.java 19
Dec 2002 19:18:38 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00
-0000 @@ -1,176 +0,0 @@ -/* - *(c) Copyright QNX Software Systems Ltd.
2002. - * All Rights Reserved. - * - */ -package
org.eclipse.cdt.debug.ui.sourcelookup; - -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.jface.resource.JFaceResources; -import
org.eclipse.swt.SWT; -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; -import
org.eclipse.swt.widgets.Composite; -import
org.eclipse.swt.widgets.Control; -import
org.eclipse.swt.widgets.DirectoryDialog; -import
org.eclipse.swt.widgets.Label; -import
org.eclipse.swt.widgets.Shell; -import
org.eclipse.swt.widgets.Text; - -/** - * Enter type comment. - *
- * @since: Dec 12, 2002 - */ -public class
AttachSourceLocationBlock -{ - private Composite fControl =
null; - private Text fLocationText = null; - private Text
fAssociationText = null; - private Button fAssocitedCheckButton =
null; - private FontMetrics fFontMetrics; - private Shell fShell
= null; - - /** - * Constructor for
AttachSourceLocationBlock. - */ - public
AttachSourceLocationBlock() - { - } - - 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()
); - - createLocationControls( fControl
); - createAssociationControls( fControl
); - } - - public void setInitialLocationPath( IPath
path ) - { - if ( path != null
) - { - fLocationText.setText(
path.toOSString() ); - } - } - - public void
setInitialAssociationPath( IPath path
) - { - fAssociationText.setEnabled( ( path != null )
); - fAssocitedCheckButton.setEnabled( ( path != null )
); - fAssocitedCheckButton.setSelection( ( path != null )
); - if ( path != null
) - { - fAssociationText.setText(
path.toOSString() ); - } - } - - public
Control getControl() - { - return
fControl; - } - - protected void createLocationControls(
Composite parent ) - { - PixelConverter converter = new
PixelConverter( parent ); - Label label = new Label( parent,
SWT.NONE ); - label.setText( "Select location directory:"
); - label.setLayoutData( new GridData( GridData.FILL_HORIZONTAL |
GridData.GRAB_HORIZONTAL ) ); - Composite composite = new
Composite( parent, SWT.NONE ); - composite.setLayout( new
GridLayout( 2, false ) ); - GridData data = "" GridData(
GridData.FILL_BOTH ); - data.widthHint =
converter.convertWidthInCharsToPixels( 70
); - composite.setLayoutData( data
); - fLocationText = new Text( composite, SWT.SINGLE | SWT.BORDER
); - fLocationText.setLayoutData( new GridData(
GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL ) ); - Button
button = createButton( composite, "&Browse..."
); - button.addSelectionListener( new SelectionAdapter()
- { - /*
(non-Javadoc) -
* @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(SelectionEvent) -
*/ - public
void widgetSelected( SelectionEvent e
) - { - selectLocation(); - } - }
); - } - - protected void
selectLocation() - { - DirectoryDialog dialog = new
DirectoryDialog( fShell ); - dialog.setMessage( "Select Location
Directory" ); - String result = dialog.open(); - if
( result != null
) - { - fLocationText.setText( result
); - } - } - - protected void
createAssociationControls( Composite parent
) - { - Composite composite = new Composite( parent,
SWT.NONE ); - composite.setLayout( new GridLayout()
); - GridData data = "" GridData( GridData.FILL_BOTH
); - composite.setLayoutData( data
); - fAssocitedCheckButton = new Button( composite, SWT.CHECK
); - fAssocitedCheckButton.setText( "&Associate with"
); - fAssociationText = new Text( composite, SWT.SINGLE |
SWT.BORDER ); - fAssociationText.setLayoutData( new GridData(
GridData.FILL_HORIZONTAL )
); - fAssocitedCheckButton.addSelectionListener( new
SelectionAdapter() - { - /*
(non-Javadoc) -
* @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(SelectionEvent) -
*/ - public
void widgetSelected(SelectionEvent
e) - { - associationSelectionChanged(); - } - - }
); - } - - protected void
associationSelectionChanged() - { - boolean checked =
fAssocitedCheckButton.getSelection(); - fAssociationText.setEnabled(
checked ); - if ( !checked
) - fAssociationText.setText( ""
); - } - - protected Button createButton( Composite parent,
String label ) - { - Button button = new Button( parent,
SWT.PUSH ); - button.setText( label ); - GridData
data = "" GridData( GridData.END ); - button.setLayoutData( data
); - SWTUtil.setButtonDimensionHint( button
); - button.setFont( parent.getFont()
); - - return button; - } - - public
String getLocationPath() - { - return
fLocationText.getText().trim(); - } - - public String
getAssociationPath() - { - if (
fAssocitedCheckButton.getSelection()
) - { - return
fAssociationText.getText().trim(); - } - return
""; - } -} Index:
src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationDialog.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationDialog.java diff
-N
src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationDialog.java ---
src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationDialog.java 17
Dec 2002 20:00:40 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00
-0000 @@ -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; - } -} Index:
src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java,v retrieving
revision 1.3 diff -u -r1.3 CUISourceLocator.java ---
src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java 18 Dec 2002
17:25:38 -0000 1.3 +++
src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java 30 Dec 2002
00:05:31 -0000 @@ -10,15 +10,18 @@ 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
@@ 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; } } Index:
src/org/eclipse/cdt/debug/ui/sourcelookup/INewSourceLocationWizard.java =================================================================== RCS
file:
src/org/eclipse/cdt/debug/ui/sourcelookup/INewSourceLocationWizard.java diff
-N
src/org/eclipse/cdt/debug/ui/sourcelookup/INewSourceLocationWizard.java ---
/dev/null 1 Jan 1970 00:00:00 -0000 +++
src/org/eclipse/cdt/debug/ui/sourcelookup/INewSourceLocationWizard.java 30
Dec 2002 00:05:31 -0000 @@ -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(); +} Index:
src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java,v retrieving
revision 1.2 diff -u -r1.2 SourceLookupBlock.java ---
src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java 20 Dec
2002 22:30:00 -0000 1.2 +++
src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java 30 Dec
2002 00:05:31 -0000 @@ -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 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
@@ 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
@@ { } - 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()
); + } } }
|