diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index e7255d66879..6a3396f9bed 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,32 @@ +2005-05-09 Mikhail Khodjaiants + Bug 80175: Replace the CDT source lookup by the source lookup provided by Eclipse platform. + Removed CDebugEditor and old source lookup related classes and interfaces. + * CDebugModelPresentation.java + - CDebugEditor.java + - EditorInputDelegate.java + - EditorMessages.java + - EditorMessages.properties + - FileNotFoundElement.java + - NoSymbolOrSourceElement.java + - AddDirectorySourceLocationBlock.java + - AddDirectorySourceLocationWizard.java + - AddProjectSourceLocationBlock.java + - AddProjectSourceLocationWizard.java + - AddSourceLocationWizard.java + - SourceLocationSelectionPage.java + - SourceLocationWizardNode.java + - WizardMessages.java + - WizardMessages.properties + - INewSourceLocationWizard.java + * OldDefaultSourceLocator.java + - SourceListDialogField.java + - SourceLookupBlock.java + - SourceLookupLabelProvider.java + * SourceLookupMessages.properties + - SourcePropertyPage.java + * plugin.properties + * plugin.xml + 2005-04-27 Mikhail Khodjaiants Added path validation to CDirectorySourceContainerDialog. * CDirectorySourceContainerDialog.java diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index 847b548b379..283ddc3a627 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -62,12 +62,6 @@ NaturalVariableFormatAction.label=Natural CDebugActionGroup.name=C/C++ Debug -SourcePropertyPage.name=Source Lookup - -DisassemblyEditor.name=Disassembly Editor -AttachSourceEditor.name= Attach Source Editor -CDebugEditor.name= C/C++ Debug Editor - LoadSymbolsAction.label=Load Symbols LoadSymbolsAction.tooltip=Load Modules's Symbols LoadSymbolsForAllAction.label=Load Symbols For All diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 4ed51419fff..2ce34d30fbb 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -887,16 +887,6 @@ id="org.eclipse.cdt.debug.ui.CEditor.ManageBreakpointRulerAction"> - - - - @@ -941,12 +931,6 @@ - - - - - - 0 ) - { - Path path = new Path( fn ); - if ( path.isValidPath( fn ) ) - { - return path; - } - } - } - return null; - } - - public String getName() - { - IPath path = getFullPath(); - return ( path != null ) ? path.lastSegment() : ""; //$NON-NLS-1$ - } - - public IStackFrame getStackFrame() - { - return fStackFrame; - } - - public ILaunch getLaunch() - { - return ( fStackFrame != null ) ? fStackFrame.getLaunch() : null; - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/NoSymbolOrSourceElement.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/NoSymbolOrSourceElement.java deleted file mode 100644 index 23d3388a56d..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/NoSymbolOrSourceElement.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.editors; - -import org.eclipse.debug.core.model.IStackFrame; - -/** - * Enter type comment. - * - * @since Apr 25, 2003 - */ -public class NoSymbolOrSourceElement -{ - private IStackFrame fStackFrame; - - public NoSymbolOrSourceElement( IStackFrame frame ) - { - fStackFrame = frame; - } - - public IStackFrame getStackFrame() - { - return fStackFrame; - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java deleted file mode 100644 index 6d483ab561f..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java +++ /dev/null @@ -1,222 +0,0 @@ -/*************************************************************************************************************************************************************** - * 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.wizards; - -import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation; -import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory; -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; - -public class AddDirectorySourceLocationBlock { - - private Composite fControl = null; - - private Text fLocationText = null; - - private Text fAssociationText = null; - - private Button fAssocitedCheckButton = null; - - private Button fSearchSubfoldersButton = 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 ); - createSearchSubfoldersButton( 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( WizardMessages.getString( "AddDirectorySourceLocationBlock.0" ) ); //$NON-NLS-1$ - 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 = new 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, WizardMessages.getString( "AddDirectorySourceLocationBlock.1" ) ); //$NON-NLS-1$ - 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( WizardMessages.getString( "AddDirectorySourceLocationBlock.2" ) ); //$NON-NLS-1$ - 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 = new GridData( GridData.FILL_BOTH ); - composite.setLayoutData( data ); - fAssocitedCheckButton = new Button( composite, SWT.CHECK ); - fAssocitedCheckButton.setText( WizardMessages.getString( "AddDirectorySourceLocationBlock.3" ) ); //$NON-NLS-1$ - 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( "" ); //$NON-NLS-1$ - } - - protected void createSearchSubfoldersButton( Composite parent ) { - Composite composite = new Composite( parent, SWT.NONE ); - composite.setLayout( new GridLayout() ); - GridData data = new GridData( GridData.FILL_BOTH ); - composite.setLayoutData( data ); - fSearchSubfoldersButton = new Button( composite, SWT.CHECK ); - fSearchSubfoldersButton.setText( WizardMessages.getString( "AddDirectorySourceLocationBlock.4" ) ); //$NON-NLS-1$ - } - - protected Button createButton( Composite parent, String label ) { - Button button = new Button( parent, SWT.PUSH ); - button.setText( label ); - GridData data = new 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 ""; //$NON-NLS-1$ - } - - public boolean searchSubfolders() { - return (fSearchSubfoldersButton != null) ? fSearchSubfoldersButton.getSelection() : false; - } - - public IDirectorySourceLocation getSourceLocation() { - if ( isLocationPathValid() ) { - Path association = (isAssociationPathValid()) ? new Path( getAssociationPath() ) : null; - return SourceLookupFactory.createDirectorySourceLocation( new Path( getLocationPath() ), association, searchSubfolders() ); - } - 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; - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationWizard.java deleted file mode 100644 index 3869d223574..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationWizard.java +++ /dev/null @@ -1,168 +0,0 @@ -/********************************************************************** - * 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.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; - -/** - * The wizard to add a file system directory based source location to the source locator. - */ -public class AddDirectorySourceLocationWizard extends Wizard implements INewSourceLocationWizard { - - protected static final String PAGE_NAME = "AddDirectorySourceLocationWizardPage"; //$NON-NLS-1$ - - 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, WizardMessages.getString( "AddDirectorySourceLocationWizard.0" ), CDebugImages.DESC_WIZBAN_ADD_DIR_SOURCE_LOCATION ); //$NON-NLS-1$ - setWindowTitle( WizardMessages.getString( "AddDirectorySourceLocationWizard.1" ) ); //$NON-NLS-1$ - setMessage( WizardMessages.getString( "AddDirectorySourceLocationWizard.2" ) ); //$NON-NLS-1$ - 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( WizardMessages.getString( "AddDirectorySourceLocationWizard.6" ) ); //$NON-NLS-1$ - complete = false; - } - else { - File file = new File( dirText ); - if ( !file.exists() || !file.isDirectory() ) { - setErrorMessage( WizardMessages.getString( "AddDirectorySourceLocationWizard.3" ) ); //$NON-NLS-1$ - complete = false; - } - else if ( !file.isAbsolute() ) { - setErrorMessage( WizardMessages.getString( "AddDirectorySourceLocationWizard.4" ) ); //$NON-NLS-1$ - 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 WizardMessages.getString( "AddDirectorySourceLocationWizard.5" ); //$NON-NLS-1$ - } - - /** - * @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; - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java deleted file mode 100644 index 6d8782ddde1..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.wizards; - -import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation; -import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory; -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.Table; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * - * Enter type comment. - * - * @since Dec 27, 2002 - */ -public class AddProjectSourceLocationBlock -{ - private Composite fControl = null; - private TableViewer fViewer; - - protected IProject[] fProjects = null; - - /** - * Constructor for AddProjectSourceLocationBlock. - */ - public AddProjectSourceLocationBlock( IProject[] projects ) - { - fProjects = projects; - } - - public void createControl( Composite parent ) - { - 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 SourceLookupFactory.createProjectSourceLocation( (IProject)((IStructuredSelection)fViewer.getSelection()).getFirstElement(), false ); - } - } - 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 ); - } - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationWizard.java deleted file mode 100644 index d5078e89950..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationWizard.java +++ /dev/null @@ -1,129 +0,0 @@ -/********************************************************************** - * 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.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; - -/** - * The wizard to add a project based source location to the source locator. - */ -public class AddProjectSourceLocationWizard extends Wizard implements INewSourceLocationWizard { - - protected static final String PAGE_NAME = "AddProjectSourceLocationWizardPage"; //$NON-NLS-1$ - - protected IProject[] fProjects = null; - - protected IProjectSourceLocation fSourceLocation = null; - - public class AddProjectSourceLocationWizardPage extends WizardPage implements ISelectionChangedListener, IDoubleClickListener { - - private AddProjectSourceLocationBlock fBlock; - - /** - * Constructor for AddProjectSourceLocationWizardPage. - */ - public AddProjectSourceLocationWizardPage( AddProjectSourceLocationWizard wizard ) { - super( PAGE_NAME, WizardMessages.getString( "AddProjectSourceLocationWizard.0" ), CDebugImages.DESC_WIZBAN_ADD_PRJ_SOURCE_LOCATION ); //$NON-NLS-1$ - setWindowTitle( WizardMessages.getString( "AddProjectSourceLocationWizard.1" ) ); //$NON-NLS-1$ - setMessage( WizardMessages.getString( "AddProjectSourceLocationWizard.2" ) ); //$NON-NLS-1$ - 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 WizardMessages.getString( "AddProjectSourceLocationWizard.3" ); //$NON-NLS-1$ - } - - /** - * @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 ) ); - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddSourceLocationWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddSourceLocationWizard.java deleted file mode 100644 index 7a5fd211c44..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddSourceLocationWizard.java +++ /dev/null @@ -1,66 +0,0 @@ -/********************************************************************** - * 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.wizards; - -import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; -import org.eclipse.cdt.debug.ui.sourcelookup.INewSourceLocationWizard; -import org.eclipse.jface.wizard.Wizard; - -/** - * The wizard to add a source location to the source locator. - */ -public class AddSourceLocationWizard extends Wizard implements INewSourceLocationWizard { - - private ICSourceLocation[] fLocations = null; - - /** - * Constructor for AddSourceLocationWizard. - */ - public AddSourceLocationWizard( ICSourceLocation[] locations ) { - super(); - setWindowTitle( WizardMessages.getString( "AddSourceLocationWizard.0" ) ); //$NON-NLS-1$ - setForcePreviousAndNextButtons( true ); - fLocations = locations; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.IWizard#performFinish() - */ - public boolean performFinish() { - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.Wizard#addPages() - */ - public void addPages() { - 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 ""; //$NON-NLS-1$ - } -} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationSelectionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationSelectionPage.java deleted file mode 100644 index 7727e3163b1..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationSelectionPage.java +++ /dev/null @@ -1,190 +0,0 @@ -/********************************************************************** - * 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.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; - -/** - * The source lookup properties of debug sessions. - */ -public class SourceLocationSelectionPage extends WizardSelectionPage implements ISelectionChangedListener, IDoubleClickListener { - - private static final String PAGE_NAME = WizardMessages.getString( "SourceLocationSelectionPage.0" ); //$NON-NLS-1$ - - 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( WizardMessages.getString( "SourceLocationSelectionPage.1" ) ); //$NON-NLS-1$ - 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( WizardMessages.getString( "SourceLocationSelectionPage.2" ) ); //$NON-NLS-1$ - //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 WizardMessages.getString( "SourceLocationSelectionPage.3" ); //$NON-NLS-1$ - } - if ( element instanceof AddDirectorySourceLocationWizard ) { - return WizardMessages.getString( "SourceLocationSelectionPage.4" ); //$NON-NLS-1$ - } - 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.hasCNature( allProjects[i] ) || CoreModel.hasCCNature( allProjects[i] )) && allProjects[i].isOpen() && !projects.contains( allProjects[i] ) ) { - result.add( allProjects[i] ); - } - } - return (IProject[])result.toArray( new IProject[result.size()] ); - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationWizardNode.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationWizardNode.java deleted file mode 100644 index dba190323f8..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/SourceLocationWizardNode.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.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 ); - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/WizardMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/WizardMessages.java deleted file mode 100644 index c1ee40886be..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/WizardMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/********************************************************************** - * 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.wizards; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class WizardMessages { - - private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.wizards.WizardMessages";//$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private WizardMessages() { - } - - public static String getString( String key ) { - try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { - return '!' + key + '!'; - } - } -} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/WizardMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/WizardMessages.properties deleted file mode 100644 index 29967fa8531..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/WizardMessages.properties +++ /dev/null @@ -1,33 +0,0 @@ -############################################################################### -# Copyright (c) 2003, 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 -############################################################################### - -AddProjectSourceLocationWizard.0=Select Project -AddProjectSourceLocationWizard.1=Add Project Source Location -AddProjectSourceLocationWizard.2=Add an existing workspace project to the source locations list. -AddProjectSourceLocationWizard.3=Add an existing project to the source locations list. -AddDirectorySourceLocationWizard.0=Select Directory -AddDirectorySourceLocationWizard.1=Add Directory Source Location -AddDirectorySourceLocationWizard.2=Add a local file system directory to the source locations list. -AddDirectorySourceLocationWizard.3=Directory does not exist. -AddDirectorySourceLocationWizard.4=Directory path must be absolute. -AddDirectorySourceLocationWizard.5=Add a local file system directory to the source locations list. -AddDirectorySourceLocationWizard.6=Directory must not be empty. -AddDirectorySourceLocationBlock.0=Select location directory: -AddDirectorySourceLocationBlock.1=&Browse... -AddDirectorySourceLocationBlock.2=Select Location Directory -AddDirectorySourceLocationBlock.3=&Associate with -AddDirectorySourceLocationBlock.4=Search sub&folders -AddSourceLocationWizard.0=Add Source Location -SourceLocationSelectionPage.0=Add Source Location -SourceLocationSelectionPage.1=Select -SourceLocationSelectionPage.2=Select source location type: -SourceLocationSelectionPage.3=Existing Project Into Workspace -SourceLocationSelectionPage.4=File System Directory diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/INewSourceLocationWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/INewSourceLocationWizard.java deleted file mode 100644 index b6bbf7adc63..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/INewSourceLocationWizard.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.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(); -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java index 0f7b6d90b0a..8848e486a06 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java @@ -13,26 +13,15 @@ package org.eclipse.cdt.debug.ui.sourcelookup; import java.io.IOException; import java.io.StringReader; import java.text.MessageFormat; -import java.util.HashMap; -import java.util.List; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; -import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.debug.core.model.ICStackFrame; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory; -import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry; -import org.eclipse.cdt.debug.internal.ui.CDebugImages; -import org.eclipse.cdt.debug.internal.ui.dialogfields.SelectionButtonDialogField; -import org.eclipse.cdt.debug.internal.ui.editors.FileNotFoundElement; -import org.eclipse.cdt.debug.internal.ui.editors.NoSymbolOrSourceElement; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.cdt.utils.ui.controls.ControlFactory; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.ResourcesPlugin; @@ -41,17 +30,8 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.model.IPersistableSourceLocator; import org.eclipse.debug.core.model.IStackFrame; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.ListDialog; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; @@ -62,58 +42,6 @@ import org.xml.sax.SAXException; */ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdaptable { - public class SourceSelectionDialog extends ListDialog { - - private SelectionButtonDialogField fAlwaysUseThisFileButton = new SelectionButtonDialogField( SWT.CHECK ); - - public SourceSelectionDialog( Shell parent ) { - super( parent ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.dialogs.ListDialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea( Composite parent ) { - Composite comp = ControlFactory.createComposite( parent, 1 ); - super.createDialogArea( comp ); - Composite comp1 = ControlFactory.createComposite( comp, 1 ); - fAlwaysUseThisFileButton.setLabelText( SourceLookupMessages.getString( "OldDefaultSourceLocator.0" ) ); //$NON-NLS-1$ - fAlwaysUseThisFileButton.doFillIntoGrid( comp1, 1 ); - return comp; - } - - public boolean alwaysMapToSelection() { - return fAlwaysUseThisFileButton.isSelected(); - } - } - - public class SourceElementLabelProvider extends LabelProvider { - - protected CDebugImageDescriptorRegistry fDebugImageRegistry = CDebugUIPlugin.getImageDescriptorRegistry(); - - public SourceElementLabelProvider() { - super(); - } - - public String getText( Object element ) { - if ( element instanceof IFile ) - return ((IFile)element).getFullPath().toString(); - if ( element instanceof FileStorage ) - return ((FileStorage)element).getFullPath().toOSString(); - return super.getText( element ); - } - - public Image getImage( Object element ) { - if ( element instanceof IFile ) - return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_WORKSPACE_SOURCE_FILE ); - if ( element instanceof FileStorage ) - return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_EXTERNAL_SOURCE_FILE ); - return super.getImage( element ); - } - } - /** * Identifier for the 'Default C/C++ Source Locator' extension (value "org.eclipse.cdt.debug.ui.DefaultSourceLocator"). */ @@ -133,17 +61,11 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap */ private ICSourceLocator fSourceLocator; - private HashMap fFramesToSource = null; - - private HashMap fNamesToSource = null; - public OldDefaultSourceLocator() { super(); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento() */ public String getMemento() throws CoreException { @@ -175,9 +97,7 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap return null; } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(java.lang.String) */ public void initializeFromMemento( String memento ) throws CoreException { @@ -222,9 +142,7 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap abort( SourceLookupMessages.getString( "OldDefaultSourceLocator.6" ), ex ); //$NON-NLS-1$ } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(org.eclipse.debug.core.ILaunchConfiguration) */ public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException { @@ -234,9 +152,7 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap initializeFromMemento( memento ); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter( Class adapter ) { @@ -251,95 +167,10 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap return null; } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(org.eclipse.debug.core.model.IStackFrame) */ public Object getSourceElement( IStackFrame stackFrame ) { - Object res = cacheLookup( stackFrame ); - if ( res == null ) { - res = getCSourceLocator().getSourceElement( stackFrame ); - if ( res instanceof List ) { - List list = (List)res; - if ( list.size() != 0 ) { - SourceSelectionDialog dialog = createSourceSelectionDialog( list ); - dialog.open(); - Object[] objs = dialog.getResult(); - res = (objs != null && objs.length > 0) ? objs[0] : null; - if ( res != null ) - cacheSourceElement( stackFrame, res, dialog.alwaysMapToSelection() ); - } - else - res = null; - } - } - if ( res == null ) { - if ( stackFrame instanceof ICStackFrame && !isEmpty( ((ICStackFrame)stackFrame).getFile() ) ) { - res = new FileNotFoundElement( stackFrame ); - } - else // don't show in editor - { - res = new NoSymbolOrSourceElement( stackFrame ); - } - } - return res; - } - - protected void saveChanges( ILaunchConfiguration configuration, IPersistableSourceLocator locator ) { - try { - ILaunchConfigurationWorkingCopy copy = configuration.copy( configuration.getName() ); - copy.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() ); - copy.doSave(); - } - catch( CoreException e ) { - CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null ); - } - } - - private SourceSelectionDialog createSourceSelectionDialog( List list ) { - SourceSelectionDialog dialog = new SourceSelectionDialog( CDebugUIPlugin.getActiveWorkbenchShell() ); - dialog.setInput( list.toArray() ); - dialog.setContentProvider( new ArrayContentProvider() ); - dialog.setLabelProvider( new SourceElementLabelProvider() ); - dialog.setTitle( SourceLookupMessages.getString( "OldDefaultSourceLocator.7" ) ); //$NON-NLS-1$ - dialog.setMessage( SourceLookupMessages.getString( "OldDefaultSourceLocator.8" ) ); //$NON-NLS-1$ - dialog.setInitialSelections( new Object[]{ list.get( 0 ) } ); - return dialog; - } - - private void cacheSourceElement( IStackFrame frame, Object sourceElement, boolean alwaysMapToSelection ) { - if ( alwaysMapToSelection ) { - String name = getFileName( frame ); - if ( name != null ) { - if ( fNamesToSource == null ) - fNamesToSource = new HashMap(); - fNamesToSource.put( name, sourceElement ); - } - } - else { - if ( fFramesToSource == null ) - fFramesToSource = new HashMap(); - fFramesToSource.put( frame, sourceElement ); - } - } - - private Object cacheLookup( IStackFrame frame ) { - String name = getFileName( frame ); - if ( name != null && fNamesToSource != null ) { - Object result = fNamesToSource.get( name ); - if ( result != null ) - return result; - } - return (fFramesToSource != null) ? fFramesToSource.get( frame ) : null; - } - - private String getFileName( IStackFrame frame ) { - if ( frame instanceof ICStackFrame ) { - String name = ((ICStackFrame)frame).getFile(); - if ( !isEmpty( name ) ) - return name.trim(); - } return null; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceListDialogField.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceListDialogField.java deleted file mode 100644 index 63e0791e520..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceListDialogField.java +++ /dev/null @@ -1,179 +0,0 @@ -/*************************************************************************************************************************************************************** - * 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.ui.sourcelookup; - -import java.util.List; -import java.util.Observable; -import java.util.Observer; -import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; -import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation; -import org.eclipse.cdt.debug.internal.ui.dialogfields.IListAdapter; -import org.eclipse.cdt.debug.internal.ui.dialogfields.ListDialogField; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; - -public class SourceListDialogField extends ListDialogField { - - public class ObservableSourceList extends Observable { - - protected synchronized void setChanged() { - super.setChanged(); - } - } - - // String constants - protected static final String YES_VALUE = SourceLookupMessages.getString( "SourceListDialogField.0" ); //$NON-NLS-1$ - - protected static final String NO_VALUE = SourceLookupMessages.getString( "SourceListDialogField.1" ); //$NON-NLS-1$ - - // Column properties - private static final String CP_LOCATION = "location"; //$NON-NLS-1$ - - private static final String CP_ASSOCIATION = "association"; //$NON-NLS-1$ - - private static final String CP_SEARCH_SUBFOLDERS = "searchSubfolders"; //$NON-NLS-1$ - - private ObservableSourceList fObservable = new ObservableSourceList(); - - public SourceListDialogField( String title, IListAdapter listAdapter ) { - super( listAdapter, new String[]{ - /* 0 */SourceLookupMessages.getString( "SourceListDialogField.2" ), //$NON-NLS-1$ - /* 1 */null, - /* 2 */SourceLookupMessages.getString( "SourceListDialogField.3" ), //$NON-NLS-1$ - /* 3 */SourceLookupMessages.getString( "SourceListDialogField.4" ), //$NON-NLS-1$ - /* 4 */null, - /* 5 */SourceLookupMessages.getString( "SourceListDialogField.5" ) //$NON-NLS-1$ - }, new SourceLookupLabelProvider() ); - setUpButtonIndex( 2 ); - setDownButtonIndex( 3 ); - setRemoveButtonIndex( 5 ); - setLabelText( title ); - } - - protected boolean managedButtonPressed( int index ) { - super.managedButtonPressed( index ); - return false; - } - - protected TableViewer createTableViewer( Composite parent ) { - TableViewer viewer = super.createTableViewer( parent ); - Table table = viewer.getTable(); - TableLayout tableLayout = new TableLayout(); - table.setLayout( tableLayout ); - GridData gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL ); - gd.grabExcessVerticalSpace = true; - gd.grabExcessHorizontalSpace = true; - table.setLayoutData( gd ); - table.setLinesVisible( true ); - table.setHeaderVisible( true ); - new TableColumn( table, SWT.NULL ); - tableLayout.addColumnData( new ColumnWeightData( 2, true ) ); - new TableColumn( table, SWT.NULL ); - tableLayout.addColumnData( new ColumnWeightData( 2, true ) ); - new TableColumn( table, SWT.NULL ); - tableLayout.addColumnData( new ColumnWeightData( 1, true ) ); - TableColumn[] columns = table.getColumns(); - columns[0].setText( SourceLookupMessages.getString( "SourceListDialogField.6" ) ); //$NON-NLS-1$ - columns[1].setText( SourceLookupMessages.getString( "SourceListDialogField.7" ) ); //$NON-NLS-1$ - columns[2].setText( SourceLookupMessages.getString( "SourceListDialogField.8" ) ); //$NON-NLS-1$ - CellEditor textCellEditor = new TextCellEditor( table ); - CellEditor comboCellEditor = new ComboBoxCellEditor( table, new String[]{ YES_VALUE, NO_VALUE } ); - viewer.setCellEditors( new CellEditor[]{ null, textCellEditor, comboCellEditor } ); - viewer.setColumnProperties( new String[]{ CP_LOCATION, CP_ASSOCIATION, CP_SEARCH_SUBFOLDERS } ); - viewer.setCellModifier( createCellModifier() ); - return viewer; - } - - private ICellModifier createCellModifier() { - return new ICellModifier() { - - public boolean canModify( Object element, String property ) { - return (element instanceof CDirectorySourceLocation && (property.equals( CP_ASSOCIATION ) || property.equals( CP_SEARCH_SUBFOLDERS ))); - } - - public Object getValue( Object element, String property ) { - if ( element instanceof CDirectorySourceLocation && property.equals( CP_ASSOCIATION ) ) { - return (((CDirectorySourceLocation)element).getAssociation() != null) ? ((CDirectorySourceLocation)element).getAssociation().toOSString() : ""; //$NON-NLS-1$ - } - if ( element instanceof CDirectorySourceLocation && property.equals( CP_SEARCH_SUBFOLDERS ) ) { - return (((CDirectorySourceLocation)element).searchSubfolders()) ? new Integer( 0 ) : new Integer( 1 ); - } - return null; - } - - public void modify( Object element, String property, Object value ) { - Object entry = getSelection(); - if ( entry instanceof CDirectorySourceLocation ) { - if ( property.equals( CP_ASSOCIATION ) && value instanceof String ) { - IPath association = new Path( (String)value ); - if ( association.isValidPath( (String)value ) ) { - ((CDirectorySourceLocation)entry).setAssociation( association ); - setChanged(); - } - } - if ( property.equals( CP_SEARCH_SUBFOLDERS ) && value instanceof Integer ) { - ((CDirectorySourceLocation)entry).setSearchSubfolders( ((Integer)value).intValue() == 0 ); - setChanged(); - } - if ( hasChanged() ) { - refresh(); - notifyObservers(); - } - } - } - }; - } - - protected Object getSelection() { - List list = getSelectedElements(); - return (list.size() > 0) ? list.get( 0 ) : null; - } - - public synchronized void addObserver( Observer o ) { - fObservable.addObserver( o ); - } - - public synchronized void deleteObserver( Observer o ) { - fObservable.deleteObserver( o ); - } - - public synchronized boolean hasChanged() { - return fObservable.hasChanged(); - } - - public void notifyObservers() { - fObservable.notifyObservers(); - } - - public void notifyObservers( Object arg ) { - fObservable.notifyObservers( arg ); - } - - public void dispose() { - } - - protected void setChanged() { - fObservable.setChanged(); - } - - public ICSourceLocation[] getSourceLocations() { - List list = getElements(); - return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ); - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java deleted file mode 100644 index f3025023a5c..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java +++ /dev/null @@ -1,448 +0,0 @@ -/********************************************************************** - * 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.ui.sourcelookup; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Observable; -import java.util.Observer; -import org.eclipse.cdt.debug.core.CDebugCorePlugin; -import org.eclipse.cdt.debug.core.CDebugUtils; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.debug.core.ICDebugConstants; -import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; -import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; -import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation; -import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory; -import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator; -import org.eclipse.cdt.debug.internal.ui.PixelConverter; -import org.eclipse.cdt.debug.internal.ui.dialogfields.CheckedListDialogField; -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.IListAdapter; -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.wizards.AddSourceLocationWizard; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.model.IPersistableSourceLocator; -import org.eclipse.debug.ui.ILaunchConfigurationDialog; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -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; - -/** - * The composite widget shared by the source lookup launch tab and property page. - */ -public class SourceLookupBlock implements Observer { - - private Composite fControl = null; - - private CheckedListDialogField fGeneratedSourceListField; - - private SourceListDialogField fAddedSourceListField; - - private SelectionButtonDialogField fSearchForDuplicateFiles; - - private ILaunchConfigurationDialog fLaunchConfigurationDialog = null; - - private boolean fIsDirty = false; - - private IProject fProject = null; - - /** - * Constructor for SourceLookupBlock. - */ - public SourceLookupBlock() { - fGeneratedSourceListField = createGeneratedSourceListField(); - fAddedSourceListField = createAddedSourceListField(); - fSearchForDuplicateFiles = createSearchForDuplicateFilesButton(); - } - - public void createControl( Composite parent ) { - fControl = new Composite( parent, SWT.NONE ); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = 0; - layout.marginHeight = 0; - fControl.setLayout( layout ); - fControl.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - fControl.setFont( JFaceResources.getDialogFont() ); - PixelConverter converter = new PixelConverter( fControl ); - fGeneratedSourceListField.doFillIntoGrid( fControl, 3 ); - LayoutUtil.setHorizontalSpan( fGeneratedSourceListField.getLabelControl( null ), 2 ); - LayoutUtil.setWidthHint( fGeneratedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) ); - LayoutUtil.setHorizontalGrabbing( fGeneratedSourceListField.getListControl( null ) ); - ((CheckboxTableViewer)fGeneratedSourceListField.getTableViewer()).addCheckStateListener( new ICheckStateListener() { - - public void checkStateChanged( CheckStateChangedEvent event ) { - if ( event.getElement() instanceof IProjectSourceLocation ) - doCheckStateChanged(); - } - } ); - new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) ); - fAddedSourceListField.doFillIntoGrid( fControl, 3 ); - LayoutUtil.setHorizontalSpan( fAddedSourceListField.getLabelControl( null ), 2 ); - LayoutUtil.setWidthHint( fAddedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) ); - LayoutUtil.setHorizontalGrabbing( fAddedSourceListField.getListControl( null ) ); - // new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) ); - fSearchForDuplicateFiles.doFillIntoGrid( fControl, 3 ); - } - - public Control getControl() { - return fControl; - } - - public void initialize( ILaunchConfiguration configuration ) { - IProject project = getProjectFromLaunchConfiguration( configuration ); - if ( project != null ) { - setProject( project ); - try { - String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" ); //$NON-NLS-1$ - if ( isEmpty( id ) || CDebugUIPlugin.getDefaultSourceLocatorID().equals( id ) || CDebugUIPlugin.getDefaultSourceLocatorOldID().equals( id ) ) { - String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" ); //$NON-NLS-1$ - if ( !isEmpty( memento ) ) - initializeFromMemento( memento ); - else - initializeDefaults(); - } - } - catch( CoreException e ) { - initializeDefaults(); - } - } - else { - initializeGeneratedLocations( null, new ICSourceLocation[0] ); - resetAdditionalLocations( CDebugCorePlugin.getDefault().getCommonSourceLocations() ); - fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) ); - } - } - - private void initializeFromMemento( String memento ) throws CoreException { - IPersistableSourceLocator locator = CDebugUIPlugin.createDefaultSourceLocator(); - locator.initializeFromMemento( memento ); - if ( locator instanceof IAdaptable ) { - ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ); - if ( clocator != null ) - initializeFromLocator( clocator ); - } - } - - private void initializeDefaults() { - fGeneratedSourceListField.removeAllElements(); - IProject project = getProject(); - if ( project != null && project.exists() && project.isOpen() ) { - ICSourceLocation location = SourceLookupFactory.createProjectSourceLocation( project, true ); - fGeneratedSourceListField.addElement( location ); - fGeneratedSourceListField.setChecked( location, true ); - List list = CDebugUtils.getReferencedProjects( project ); - Iterator it = list.iterator(); - while( it.hasNext() ) { - location = SourceLookupFactory.createProjectSourceLocation( (IProject)it.next(), true ); - fGeneratedSourceListField.addElement( location ); - fGeneratedSourceListField.setChecked( location, true ); - } - } - resetAdditionalLocations( CDebugCorePlugin.getDefault().getCommonSourceLocations() ); - fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) ); - } - - private void initializeFromLocator( ICSourceLocator locator ) { - ICSourceLocation[] locations = locator.getSourceLocations(); - initializeGeneratedLocations( locator.getProject(), locations ); - resetAdditionalLocations( locations ); - fSearchForDuplicateFiles.setSelection( locator.searchForDuplicateFiles() ); - } - - private void initializeGeneratedLocations( IProject project, ICSourceLocation[] locations ) { - fGeneratedSourceListField.removeAllElements(); - if ( project == null || !project.exists() || !project.isOpen() ) - return; - List list = CDebugUtils.getReferencedProjects( project ); - IProject[] refs = (IProject[])list.toArray( new IProject[list.size()] ); - ICSourceLocation loc = getLocationForProject( project, locations ); - boolean checked = (loc != null && ((IProjectSourceLocation)loc).isGeneric()); - if ( loc == null ) - loc = SourceLookupFactory.createProjectSourceLocation( project, true ); - fGeneratedSourceListField.addElement( loc ); - fGeneratedSourceListField.setChecked( loc, checked ); - for( int i = 0; i < refs.length; ++i ) { - loc = getLocationForProject( refs[i], locations ); - checked = (loc != null); - if ( loc == null ) - loc = SourceLookupFactory.createProjectSourceLocation( refs[i], true ); - fGeneratedSourceListField.addElement( loc ); - fGeneratedSourceListField.setChecked( loc, checked ); - } - } - - private void resetGeneratedLocations( ICSourceLocation[] locations ) { - fGeneratedSourceListField.checkAll( false ); - for( int i = 0; i < locations.length; ++i ) { - if ( locations[i] instanceof IProjectSourceLocation && ((IProjectSourceLocation)locations[i]).isGeneric() ) - fGeneratedSourceListField.setChecked( locations[i], true ); - } - } - - private void resetAdditionalLocations( ICSourceLocation[] locations ) { - fAddedSourceListField.removeAllElements(); - for( int i = 0; i < locations.length; ++i ) { - if ( !(locations[i] instanceof IProjectSourceLocation) || !((IProjectSourceLocation)locations[i]).isGeneric() ) - fAddedSourceListField.addElement( locations[i] ); - } - } - - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - IPersistableSourceLocator locator = CDebugUIPlugin.createDefaultSourceLocator(); - try { - locator.initializeDefaults( configuration ); - if ( locator instanceof IAdaptable ) { - ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ); - if ( clocator != null && getProject() != null && getProject().equals( getProjectFromLaunchConfiguration( configuration ) ) ) { - clocator.setSourceLocations( getSourceLocations() ); - clocator.setSearchForDuplicateFiles( searchForDuplicateFiles() ); - } - } - configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() ); - } - catch( CoreException e ) { - } - } - - protected void doCheckStateChanged() { - fIsDirty = true; - updateLaunchConfigurationDialog(); - } - - protected void doGeneratedSourceButtonPressed( int index ) { - switch( index ) { - case 0: // Select All - case 1: // Deselect All - fIsDirty = true; - break; - } - if ( isDirty() ) - updateLaunchConfigurationDialog(); - } - - protected void doGeneratedSourceSelectionChanged() { - } - - protected void doAddedSourceButtonPressed( int index ) { - switch( index ) { - case 0: // Add... - if ( addSourceLocation() ) - fIsDirty = true; - break; - case 2: // Up - case 3: // Down - case 5: // Remove - fIsDirty = true; - break; - } - if ( isDirty() ) - updateLaunchConfigurationDialog(); - } - - public ICSourceLocation[] getSourceLocations() { - ArrayList list = new ArrayList( getGeneratedSourceListField().getElements().size() + getAddedSourceListField().getElements().size() ); - Iterator it = getGeneratedSourceListField().getElements().iterator(); - while( it.hasNext() ) { - IProjectSourceLocation location = (IProjectSourceLocation)it.next(); - if ( getGeneratedSourceListField().isChecked( location ) ) - list.add( location ); - } - list.addAll( getAddedSourceListField().getElements() ); - return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ); - } - - private boolean addSourceLocation() { - AddSourceLocationWizard wizard = new AddSourceLocationWizard( getSourceLocations() ); - WizardDialog dialog = new WizardDialog( fControl.getShell(), wizard ); - if ( dialog.open() == Window.OK ) { - fAddedSourceListField.addElement( wizard.getSourceLocation() ); - return true; - } - return false; - } - - protected void updateLaunchConfigurationDialog() { - if ( getLaunchConfigurationDialog() != null ) { - getLaunchConfigurationDialog().updateMessage(); - getLaunchConfigurationDialog().updateButtons(); - fIsDirty = false; - } - } - - public ILaunchConfigurationDialog getLaunchConfigurationDialog() { - return fLaunchConfigurationDialog; - } - - public void setLaunchConfigurationDialog( ILaunchConfigurationDialog launchConfigurationDialog ) { - fLaunchConfigurationDialog = launchConfigurationDialog; - } - - public boolean isDirty() { - return fIsDirty; - } - - protected Object getSelection() { - List list = fAddedSourceListField.getSelectedElements(); - return (list.size() > 0) ? list.get( 0 ) : null; - } - - protected void restoreDefaults() { - ICSourceLocation[] locations = new ICSourceLocation[0]; - if ( getProject() != null ) - locations = CSourceLocator.getDefaultSourceLocations( getProject() ); - resetGeneratedLocations( locations ); - resetAdditionalLocations( locations ); - fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) ); - } - - public IProject getProject() { - return fProject; - } - - private void setProject( IProject project ) { - fProject = project; - } - - public SourceListDialogField getAddedSourceListField() { - return fAddedSourceListField; - } - - public CheckedListDialogField getGeneratedSourceListField() { - return fGeneratedSourceListField; - } - - private ICSourceLocation getLocationForProject( IProject project, ICSourceLocation[] locations ) { - for( int i = 0; i < locations.length; ++i ) - if ( locations[i] instanceof IProjectSourceLocation && project.equals( ((IProjectSourceLocation)locations[i]).getProject() ) ) - return locations[i]; - return null; - } - - public boolean searchForDuplicateFiles() { - return (fSearchForDuplicateFiles != null) ? fSearchForDuplicateFiles.isSelected() : false; - } - - private CheckedListDialogField createGeneratedSourceListField() { - String[] generatedSourceButtonLabels = new String[]{ - /* 0 */SourceLookupMessages.getString( "SourceLookupBlock.0" ), //$NON-NLS-1$ - /* 1 */SourceLookupMessages.getString( "SourceLookupBlock.1" ), //$NON-NLS-1$ - }; - IListAdapter generatedSourceAdapter = new IListAdapter() { - - public void customButtonPressed( DialogField field, int index ) { - doGeneratedSourceButtonPressed( index ); - } - - public void selectionChanged( DialogField field ) { - doGeneratedSourceSelectionChanged(); - } - }; - CheckedListDialogField field = new CheckedListDialogField( generatedSourceAdapter, generatedSourceButtonLabels, new SourceLookupLabelProvider() ); - field.setLabelText( SourceLookupMessages.getString( "SourceLookupBlock.2" ) ); //$NON-NLS-1$ - field.setCheckAllButtonIndex( 0 ); - field.setUncheckAllButtonIndex( 1 ); - field.setDialogFieldListener( new IDialogFieldListener() { - - public void dialogFieldChanged( DialogField f ) { - doCheckStateChanged(); - } - } ); - return field; - } - - private SourceListDialogField createAddedSourceListField() { - SourceListDialogField field = new SourceListDialogField( SourceLookupMessages.getString( "SourceLookupBlock.3" ), //$NON-NLS-1$ - new IListAdapter() { - - public void customButtonPressed( DialogField f, int index ) { - doAddedSourceButtonPressed( index ); - } - - public void selectionChanged( DialogField f ) { - } - } ); - field.addObserver( this ); - return field; - } - - private SelectionButtonDialogField createSearchForDuplicateFilesButton() { - SelectionButtonDialogField button = new SelectionButtonDialogField( SWT.CHECK ); - button.setLabelText( SourceLookupMessages.getString( "SourceLookupBlock.4" ) ); //$NON-NLS-1$ - button.setDialogFieldListener( new IDialogFieldListener() { - - public void dialogFieldChanged( DialogField field ) { - doCheckStateChanged(); - } - } ); - return button; - } - - /* - * (non-Javadoc) - * - * @see java.util.Observer#update(java.util.Observable, java.lang.Object) - */ - public void update( Observable o, Object arg ) { - if ( arg instanceof Integer && ((Integer)arg).intValue() == 0 ) { - if ( addSourceLocation() ) - fIsDirty = true; - } - else - fIsDirty = true; - if ( fIsDirty ) - updateLaunchConfigurationDialog(); - } - - private boolean isEmpty( String string ) { - return string == null || string.length() == 0; - } - - public void dispose() { - if ( getAddedSourceListField() != null ) { - getAddedSourceListField().deleteObserver( this ); - getAddedSourceListField().dispose(); - } - } - - private IProject getProjectFromLaunchConfiguration( ILaunchConfiguration configuration ) { - try { - String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "" ); //$NON-NLS-1$ - if ( !isEmpty( projectName ) ) { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName ); - if ( project != null && project.exists() && project.isOpen() ) - return project; - } - } - catch( CoreException e ) { - } - return null; - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupLabelProvider.java deleted file mode 100644 index 3ca41b025ca..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupLabelProvider.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.ui.sourcelookup; - -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.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; - - -public class SourceLookupLabelProvider extends LabelProvider implements ITableLabelProvider -{ - public Image getColumnImage( Object element, int columnIndex ) - { - if ( columnIndex == 0 ) - { - if ( element instanceof IProjectSourceLocation ) - { - return ( ((IProjectSourceLocation)element).getProject().isOpen() ) ? - CDebugImages.get( CDebugImages.IMG_OBJS_PROJECT ) : - CDebugImages.get( CDebugImages.IMG_OBJS_CLOSED_PROJECT ); - } - if ( element instanceof IDirectorySourceLocation ) - { - return CDebugImages.get( CDebugImages.IMG_OBJS_FOLDER ); - } - } - return null; - } - - public String getColumnText( Object element, int columnIndex ) - { - if ( columnIndex == 0 ) - { - if ( element instanceof IProjectSourceLocation ) - { - return ((IProjectSourceLocation)element).getProject().getName(); - } - if ( element instanceof IDirectorySourceLocation ) - { - return ((IDirectorySourceLocation)element).getDirectory().toOSString(); - } - } - else if ( columnIndex == 1 ) - { - if ( element instanceof IDirectorySourceLocation && ((IDirectorySourceLocation)element).getAssociation() != null ) - { - return ((IDirectorySourceLocation)element).getAssociation().toOSString(); - } - } - else if ( columnIndex == 2 ) - { - if ( element instanceof IDirectorySourceLocation ) - return ( ((IDirectorySourceLocation)element).searchSubfolders() ) ? SourceListDialogField.YES_VALUE : SourceListDialogField.NO_VALUE; - } - return ""; //$NON-NLS-1$ - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupMessages.properties index 18e9c767fb1..69056ac7b7c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupMessages.properties @@ -9,22 +9,6 @@ # QNX Software Systems - initial API and implementation ############################################################################### -SourceListDialogField.0=yes -SourceListDialogField.1=no -SourceListDialogField.2=Add... -SourceListDialogField.3=Up -SourceListDialogField.4=Down -SourceListDialogField.5=Remove -SourceListDialogField.6=Location -SourceListDialogField.7=Association -SourceListDialogField.8=Search subfolders -SourcePropertyPage.0=Terminated. -SourceLookupBlock.0=Select All -SourceLookupBlock.1=Deselect All -SourceLookupBlock.2=Generic Source Locations -SourceLookupBlock.3=Additional Source Locations -SourceLookupBlock.4=Search for duplicate source files -DefaultSourceLocator.0=Always map to the selection DefaultSourceLocator.1=Unable to create memento for C/C++ source locator. DefaultSourceLocator.2=Unable to restore prompting source locator - invalid format. DefaultSourceLocator.3=Unable to restore prompting source locator - invalid format. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java deleted file mode 100644 index 688e01f2519..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java +++ /dev/null @@ -1,136 +0,0 @@ -/********************************************************************** - * 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.ui.sourcelookup; - -import org.eclipse.cdt.debug.core.model.ICDebugTarget; -import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.model.IPersistableSourceLocator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.dialogs.PropertyPage; - -/** - * The "Source Lookup" property page. - */ -public class SourcePropertyPage extends PropertyPage { - - private SourceLookupBlock fBlock = null; - - /** - * Constructor for SourcePropertyPage. - */ - public SourcePropertyPage() { - noDefaultAndApplyButton(); - fBlock = new SourceLookupBlock(); - } - - /** - * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite) - */ - protected Control createContents( Composite parent ) { - ICDebugTarget target = getDebugTarget(); - if ( target == null || target.isTerminated() || target.isDisconnected() ) { - return createTerminatedContents( parent ); - } - return createActiveContents( parent ); - } - - protected Control createTerminatedContents( Composite parent ) { - Label label = new Label( parent, SWT.LEFT ); - label.setText( SourceLookupMessages.getString( "SourcePropertyPage.0" ) ); //$NON-NLS-1$ - return label; - } - - protected Control createActiveContents( Composite parent ) { - fBlock.initialize( getLaunchConfiguration() ); - fBlock.createControl( parent ); - return fBlock.getControl(); - } - - protected ICDebugTarget getDebugTarget() { - IAdaptable element = getElement(); - if ( element != null ) { - return (ICDebugTarget)element.getAdapter( ICDebugTarget.class ); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - if ( fBlock.isDirty() ) { - try { - setAttributes( fBlock ); - } - catch( DebugException e ) { - CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null ); - return false; - } - } - return true; - } - - private void setAttributes( SourceLookupBlock block ) throws DebugException { - ICDebugTarget target = getDebugTarget(); - if ( target != null ) { - if ( target.getLaunch().getSourceLocator() instanceof IAdaptable ) { - ICSourceLocator locator = (ICSourceLocator)((IAdaptable)target.getLaunch().getSourceLocator()).getAdapter( ICSourceLocator.class ); - if ( locator != null ) { - locator.setSourceLocations( block.getSourceLocations() ); - locator.setSearchForDuplicateFiles( block.searchForDuplicateFiles() ); - if ( target.getLaunch().getSourceLocator() instanceof IPersistableSourceLocator ) { - ILaunchConfiguration configuration = target.getLaunch().getLaunchConfiguration(); - saveChanges( configuration, (IPersistableSourceLocator)target.getLaunch().getSourceLocator() ); - } - } - } - } - } - - protected void saveChanges( ILaunchConfiguration configuration, IPersistableSourceLocator locator ) { - try { - ILaunchConfigurationWorkingCopy copy = configuration.copy( configuration.getName() ); - copy.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() ); - copy.doSave(); - } - catch( CoreException e ) { - CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null ); - } - } - - private ILaunchConfiguration getLaunchConfiguration() { - ICDebugTarget target = getDebugTarget(); - return (target != null) ? target.getLaunch().getLaunchConfiguration() : null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.IDialogPage#dispose() - */ - public void dispose() { - if ( fBlock != null ) - fBlock.dispose(); - super.dispose(); - } -} \ No newline at end of file