1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

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.

This commit is contained in:
Mikhail Khodjaiants 2005-05-09 21:41:17 +00:00
parent efe6bad409
commit 72807c0c5f
26 changed files with 34 additions and 2924 deletions

View file

@ -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

View file

@ -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

View file

@ -887,16 +887,6 @@
id="org.eclipse.cdt.debug.ui.CEditor.ManageBreakpointRulerAction">
</action>
</editorContribution>
<editorContribution
targetID="org.eclipse.cdt.debug.ui.editor.CDebugEditor"
id="org.eclipse.cdt.debug.ui.CDebugEditor.BreakpointRulerActions">
<action
label="%Dummy.label"
class="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate"
actionID="RulerDoubleClick"
id="org.eclipse.cdt.debug.ui.CEditor.ManageBreakpointRulerAction">
</action>
</editorContribution>
<editorContribution
targetID="org.eclipse.cdt.ui.editor.asm.AsmEditor"
id="org.eclipse.cdt.ui.editor.asm.AsmEditor.BreakpointRulerActions">
@ -941,12 +931,6 @@
</extension>
<extension
point="org.eclipse.ui.propertyPages">
<page
objectClass="org.eclipse.cdt.debug.core.model.ICDebugTarget"
name="%SourcePropertyPage.name"
class="org.eclipse.cdt.debug.ui.sourcelookup.SourcePropertyPage"
id="org.eclipse.cdt.debug.ui.sourcelookup.SourcePropertyPage">
</page>
<page
adaptable="true"
objectClass="org.eclipse.cdt.debug.core.model.ICBreakpoint"
@ -970,17 +954,6 @@
name="%CommonModulePage.label"
id="org.eclipse.cdt.debug.ui.propertypages.module.common"/>
</extension>
<extension
id="org.eclipse.cdt.debug.ui.editors"
point="org.eclipse.ui.editors">
<editor
name="%CDebugEditor.name"
icon="icons/obj16/filenotfound_obj.gif"
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
class="org.eclipse.cdt.debug.internal.ui.editors.CDebugEditor"
id="org.eclipse.cdt.debug.ui.editor.CDebugEditor">
</editor>
</extension>
<extension
point="org.eclipse.debug.core.sourceLocators">
<sourceLocator

View file

@ -41,8 +41,6 @@ import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
import org.eclipse.cdt.debug.core.model.IEnableDisableTarget;
import org.eclipse.cdt.debug.internal.ui.editors.EditorInputDelegate;
import org.eclipse.cdt.debug.internal.ui.editors.FileNotFoundElement;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
@ -142,9 +140,6 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
if ( element instanceof FileStorage || element instanceof LocalFileStorage ) {
return new ExternalEditorInput( (IStorage)element );
}
if ( element instanceof FileNotFoundElement ) {
return new EditorInputDelegate( (FileNotFoundElement)element );
}
return null;
}
@ -152,20 +147,12 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
* @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(org.eclipse.ui.IEditorInput, java.lang.Object)
*/
public String getEditorId( IEditorInput input, Object element ) {
// if ( input instanceof EditorInputDelegate ) {
// if ( ((EditorInputDelegate)input).getDelegate() == null )
// return CDebugEditor.EDITOR_ID;
// return getEditorId( ((EditorInputDelegate)input).getDelegate(), element );
// }
String id = null;
if ( input != null ) {
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor descriptor = registry.getDefaultEditor( input.getName() );
id = (descriptor != null) ? descriptor.getId() : CUIPlugin.EDITOR_ID;
}
// if ( CUIPlugin.EDITOR_ID.equals( id ) ) {
// return CDebugEditor.EDITOR_ID;
// }
return id;
}

View file

@ -1,459 +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.editors;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
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.cdt.debug.ui.sourcelookup.INewSourceLocationWizard;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.ILaunch;
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.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Rectangle;
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.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.part.FileEditorInput;
/**
* The Debugger specific extension fo the C editor.
*/
public class CDebugEditor extends CEditor {
public class AttachSourceForm implements IPropertyChangeListener {
/** The horizontal scroll increment. */
private static final int HORIZONTAL_SCROLL_INCREMENT = 10;
/** The vertical scroll increment. */
private static final int VERTICAL_SCROLL_INCREMENT = 10;
/** The form's root widget */
private Font fFont;
/** The form's root widget */
private ScrolledComposite fScrolledComposite;
/** The background color */
private Color fBackgroundColor;
/** The foreground color */
private Color fForegroundColor;
/** The separator's color */
private Color fSeparatorColor;
/** The form headers */
private List fHeaderLabels = new ArrayList();
/** The form banners */
private List fBannerLabels = new ArrayList();
/** The form text */
private Label fInputLabel;
/** The attach source button */
private Button fAttachButton = null;
/** The preference change listener */
// private IPropertyChangeListener fPropertyChangeListener;
private IEditorInput fInput = null;
public AttachSourceForm( Composite parent, IEditorInput input ) {
Display display = parent.getDisplay();
fBackgroundColor = display.getSystemColor( SWT.COLOR_LIST_BACKGROUND );
fForegroundColor = display.getSystemColor( SWT.COLOR_LIST_FOREGROUND );
fSeparatorColor = new Color( display, 152, 170, 203 );
JFaceResources.getFontRegistry().addListener( AttachSourceForm.this );
fScrolledComposite = new ScrolledComposite( parent, SWT.H_SCROLL | SWT.V_SCROLL );
fScrolledComposite.setAlwaysShowScrollBars( false );
fScrolledComposite.setExpandHorizontal( true );
fScrolledComposite.setExpandVertical( true );
fScrolledComposite.addDisposeListener( new DisposeListener() {
public void widgetDisposed( DisposeEvent e ) {
JFaceResources.getFontRegistry().removeListener( AttachSourceForm.this );
setScrolledComposite( null );
getSeparatorColor().dispose();
setSeparatorColor( null );
getBannerLabels().clear();
getHeaderLabels().clear();
if ( getFont() != null ) {
getFont().dispose();
setFont( null );
}
}
} );
fScrolledComposite.addControlListener( new ControlListener() {
public void controlMoved( ControlEvent e ) {
}
public void controlResized( ControlEvent e ) {
Rectangle clientArea = getScrolledComposite().getClientArea();
ScrollBar verticalBar = getScrolledComposite().getVerticalBar();
verticalBar.setIncrement( VERTICAL_SCROLL_INCREMENT );
verticalBar.setPageIncrement( clientArea.height - verticalBar.getIncrement() );
ScrollBar horizontalBar = getScrolledComposite().getHorizontalBar();
horizontalBar.setIncrement( HORIZONTAL_SCROLL_INCREMENT );
horizontalBar.setPageIncrement( clientArea.width - horizontalBar.getIncrement() );
}
} );
Composite composite = createComposite( fScrolledComposite );
composite.setLayout( new GridLayout() );
createTitleLabel( composite, EditorMessages.getString( "CDebugEditor.0" ) ); //$NON-NLS-1$
createLabel( composite, null );
createLabel( composite, null );
createHeadingLabel( composite, EditorMessages.getString( "CDebugEditor.1" ) ); //$NON-NLS-1$
Composite separator = createCompositeSeparator( composite );
GridData data = new GridData( GridData.FILL_HORIZONTAL );
data.heightHint = 2;
separator.setLayoutData( data );
fInputLabel = createLabel( composite, "" ); //$NON-NLS-1$
createLabel( composite, EditorMessages.getString( "CDebugEditor.2" ) ); //$NON-NLS-1$
createLabel( composite, null );
fAttachButton = createButton( composite, EditorMessages.getString( "CDebugEditor.3" ) ); //$NON-NLS-1$
fAttachButton.addSelectionListener( new SelectionListener() {
public void widgetSelected( SelectionEvent event ) {
attachSourceLocation();
}
public void widgetDefaultSelected( SelectionEvent e ) {
}
} );
separator = createCompositeSeparator( composite );
data = new GridData( GridData.FILL_HORIZONTAL );
data.heightHint = 2;
separator.setLayoutData( data );
fScrolledComposite.setContent( composite );
fScrolledComposite.setMinSize( composite.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
if ( getEditorInput() != null ) {
setInputLabelText( getEditorInput() );
}
fInput = input;
}
private Composite createComposite( Composite parent ) {
Composite composite = new Composite( parent, SWT.NONE );
composite.setBackground( fBackgroundColor );
return composite;
}
private Label createLabel( Composite parent, String text ) {
Label label = new Label( parent, SWT.NONE );
if ( text != null )
label.setText( text );
label.setBackground( fBackgroundColor );
label.setForeground( fForegroundColor );
return label;
}
private Label createTitleLabel( Composite parent, String text ) {
Label label = new Label( parent, SWT.NONE );
if ( text != null )
label.setText( text );
label.setBackground( fBackgroundColor );
label.setForeground( fForegroundColor );
label.setFont( JFaceResources.getHeaderFont() );
fHeaderLabels.add( label );
return label;
}
private Label createHeadingLabel( Composite parent, String text ) {
Label label = new Label( parent, SWT.NONE );
if ( text != null )
label.setText( text );
label.setBackground( fBackgroundColor );
label.setForeground( fForegroundColor );
label.setFont( JFaceResources.getBannerFont() );
fBannerLabels.add( label );
return label;
}
private Composite createCompositeSeparator( Composite parent ) {
Composite composite = new Composite( parent, SWT.NONE );
composite.setBackground( fSeparatorColor );
return composite;
}
private Button createButton( Composite parent, String text ) {
Button button = new Button( parent, SWT.FLAT );
button.setBackground( fBackgroundColor );
button.setForeground( fForegroundColor );
if ( text != null )
button.setText( text );
return button;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public void propertyChange( PropertyChangeEvent event ) {
for( Iterator iterator = fBannerLabels.iterator(); iterator.hasNext(); ) {
Label label = (Label)iterator.next();
label.setFont( JFaceResources.getBannerFont() );
}
for( Iterator iterator = fHeaderLabels.iterator(); iterator.hasNext(); ) {
Label label = (Label)iterator.next();
label.setFont( JFaceResources.getHeaderFont() );
}
Control control = fScrolledComposite.getContent();
fScrolledComposite.setMinSize( control.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
fScrolledComposite.setContent( control );
fScrolledComposite.layout( true );
fScrolledComposite.redraw();
}
private void setInputLabelText( IEditorInput input ) {
FileNotFoundElement element = (FileNotFoundElement)input.getAdapter( FileNotFoundElement.class );
if ( element != null )
fInputLabel.setText( MessageFormat.format( EditorMessages.getString( "CDebugEditor.4" ), new String[]{ element.getFullPath().toOSString() } ) ); //$NON-NLS-1$
}
protected ScrolledComposite getScrolledComposite() {
return fScrolledComposite;
}
protected void setScrolledComposite( ScrolledComposite scrolledComposite ) {
fScrolledComposite = scrolledComposite;
}
protected Color getSeparatorColor() {
return fSeparatorColor;
}
protected void setSeparatorColor( Color separatorColor ) {
fSeparatorColor = separatorColor;
}
protected List getBannerLabels() {
return fBannerLabels;
}
protected void setBannerLabels( List bannerLabels ) {
fBannerLabels = bannerLabels;
}
protected List getHeaderLabels() {
return fHeaderLabels;
}
protected void setHeaderLabels( List headerLabels ) {
fHeaderLabels = headerLabels;
}
protected Font getFont() {
return fFont;
}
protected void setFont( Font font ) {
fFont = font;
}
public Control getControl() {
return fScrolledComposite;
}
public IEditorInput getInput() {
return fInput;
}
}
public static final String EDITOR_ID = CDebugUIPlugin.getUniqueIdentifier() + ".editor.CDebugEditor"; //$NON-NLS-1$
private AttachSourceForm fAttachSourceForm = null;
/**
* Constructor for CDebugEditor.
*/
public CDebugEditor() {
super();
setDocumentProvider( CUIPlugin.getDefault().getDocumentProvider() );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
public void createPartControl( Composite parent ) {
super.createPartControl( parent );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
*/
protected void doSetInput( IEditorInput input ) throws CoreException {
IEditorInput newInput = input;
if ( input instanceof EditorInputDelegate && ((EditorInputDelegate)input).getDelegate() != null ) {
newInput = ((EditorInputDelegate)input).getDelegate();
}
IEditorInput oldInput = getEditorInput();
if ( oldInput instanceof EditorInputDelegate ) {
oldInput = ((EditorInputDelegate)oldInput).getDelegate();
}
if ( oldInput != null ) {
CUIPlugin.getDefault().getWorkingCopyManager().disconnect( oldInput );
}
super.doSetInput( newInput );
// This hack should be after the super.doSetInput();
CUIPlugin.getDefault().getWorkingCopyManager().connect( newInput );
}
protected void attachSourceLocation() {
if ( getEditorInput() != null && getEditorInput().getAdapter( FileNotFoundElement.class ) != null ) {
FileNotFoundElement element = (FileNotFoundElement)getEditorInput().getAdapter( FileNotFoundElement.class );
if ( element.getLaunch() != null && element.getLaunch().getSourceLocator() instanceof IAdaptable ) {
ILaunch launch = element.getLaunch();
ICSourceLocator locator = (ICSourceLocator)((IAdaptable)element.getLaunch().getSourceLocator()).getAdapter( ICSourceLocator.class );
if ( locator != null ) {
IPath path = element.getFullPath();
INewSourceLocationWizard wizard = null;
if ( path.isAbsolute() ) {
path = path.removeLastSegments( 1 );
wizard = new AddDirectorySourceLocationWizard( path );
}
else {
wizard = new AddSourceLocationWizard( locator.getSourceLocations() );
}
WizardDialog dialog = new WizardDialog( CDebugUIPlugin.getActiveWorkbenchShell(), wizard );
if ( dialog.open() == Window.OK ) {
ICSourceLocation[] locations = locator.getSourceLocations();
ArrayList list = new ArrayList( Arrays.asList( locations ) );
list.add( wizard.getSourceLocation() );
locator.setSourceLocations( (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ) );
if ( locator instanceof IPersistableSourceLocator ) {
ILaunchConfiguration configuration = launch.getLaunchConfiguration();
saveChanges( configuration, (IPersistableSourceLocator)launch.getSourceLocator() );
}
Object newElement = locator.getSourceElement( element.getStackFrame() );
IEditorInput newInput = null;
if ( newElement instanceof IFile ) {
newInput = new FileEditorInput( (IFile)newElement );
}
else if ( newElement instanceof FileStorage ) {
newInput = new ExternalEditorInput( (IStorage)newElement );
}
IEditorInput oldInput = ((EditorInputDelegate)getEditorInput()).getDelegate();
CUIPlugin.getDefault().getWorkingCopyManager().disconnect( oldInput );
((EditorInputDelegate)getEditorInput()).setDelegate( newInput );
resetInput( element.getStackFrame() );
}
}
}
}
}
private void resetInput( IStackFrame frame ) {
setInput( getEditorInput() );
IViewPart view = CDebugUIPlugin.getActivePage().findView( IDebugUIConstants.ID_DEBUG_VIEW );
if ( view instanceof IDebugView ) {
((IDebugView)view).getViewer().setSelection( new StructuredSelection( frame ) );
}
}
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 );
}
}
/**
* @see org.eclipse.ui.texteditor.StatusTextEditor#createStatusControl(Composite, IStatus)
*/
protected Control createStatusControl( Composite parent, IStatus status ) {
fAttachSourceForm = new AttachSourceForm( parent, getEditorInput() );
return fAttachSourceForm.getControl();
}
/**
* @see org.eclipse.ui.texteditor.StatusTextEditor#updatePartControl(IEditorInput)
*/
public void updatePartControl( IEditorInput input ) {
if ( fAttachSourceForm != null ) {
if ( fAttachSourceForm.getInput() != null && !fAttachSourceForm.getInput().equals( input ) ) {
fAttachSourceForm = null;
super.updatePartControl( input );
}
}
else
super.updatePartControl( input );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
public void dispose() {
IEditorInput input = getEditorInput();
IEditorInput newInput = input;
if ( input instanceof EditorInputDelegate && ((EditorInputDelegate)input).getDelegate() != null ) {
newInput = ((EditorInputDelegate)input).getDelegate();
}
CUIPlugin.getDefault().getWorkingCopyManager().disconnect( newInput );
super.dispose();
}
}

View file

@ -1,179 +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 java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.eclipse.cdt.ui.IEditorInputDelegate;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.IStorageEditorInput;
/**
*
* Enter type comment.
*
* @since Mar 4, 2003
*/
public class EditorInputDelegate implements IEditorInputDelegate
{
public static final int TYPE_ATTACH_SOURCE = 0;
public static final int TYPE_WORKSPACE_FILE = 1;
public static final int TYPE_EXTERNAL_FILE = 2;
private int fType = TYPE_ATTACH_SOURCE;
private IEditorInput fDelegate = null;
private FileNotFoundElement fElement = null;
/**
* Constructor for EditorInputDelegate.
*/
public EditorInputDelegate( FileNotFoundElement element )
{
fElement = element;
}
/**
* @see org.eclipse.ui.IEditorInput#exists()
*/
public boolean exists()
{
if ( fDelegate != null )
return fDelegate.exists();
return true;
}
/**
* @see org.eclipse.ui.IEditorInput#getImageDescriptor()
*/
public ImageDescriptor getImageDescriptor()
{
if ( fDelegate != null )
return fDelegate.getImageDescriptor();
return null;
}
/**
* @see org.eclipse.ui.IEditorInput#getName()
*/
public String getName()
{
if ( fDelegate != null )
return fDelegate.getName();
return ( fElement != null ) ? fElement.getName() : ""; //$NON-NLS-1$
}
/**
* @see org.eclipse.ui.IEditorInput#getPersistable()
*/
public IPersistableElement getPersistable()
{
if ( fDelegate != null )
return fDelegate.getPersistable();
return null;
}
/**
* @see org.eclipse.ui.IEditorInput#getToolTipText()
*/
public String getToolTipText()
{
if ( fDelegate != null )
return fDelegate.getToolTipText();
return ""; //$NON-NLS-1$
}
/**
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/
public Object getAdapter( Class adapter )
{
if ( adapter.equals( FileNotFoundElement.class ) )
return fElement;
if ( getDelegate() != null )
return getDelegate().getAdapter( adapter );
return null;
}
public int getType()
{
return fType;
}
public void setType( int type )
{
fType = type;
}
public IEditorInput getDelegate()
{
return fDelegate;
}
public void setDelegate( IEditorInput input )
{
fDelegate = input;
}
public IStorage getStorage() throws CoreException
{
if ( getDelegate() instanceof IStorageEditorInput )
return ((IStorageEditorInput)getDelegate()).getStorage();
return getDummyStorage();
}
private IStorage getDummyStorage()
{
return new IStorage()
{
public InputStream getContents() throws CoreException
{
return new ByteArrayInputStream( new byte[0] );
}
public IPath getFullPath()
{
if ( getElement() != null )
return getElement().getFullPath();
return null;
}
public String getName()
{
if ( getElement() != null )
return getElement().getName();
return ""; //$NON-NLS-1$
}
public boolean isReadOnly()
{
return true;
}
public Object getAdapter( Class adapter )
{
if ( adapter.equals( IStorage.class ) )
return this;
return null;
}
};
}
protected FileNotFoundElement getElement()
{
return fElement;
}
}

View file

@ -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.editors;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class EditorMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.editors.EditorMessages";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private EditorMessages() {
}
public static String getString( String key ) {
try {
return RESOURCE_BUNDLE.getString( key );
}
catch( MissingResourceException e ) {
return '!' + key + '!';
}
}
}

View file

@ -1,16 +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
###############################################################################
CDebugEditor.0=C/C++ File Editor
CDebugEditor.1=Source not found
CDebugEditor.2=You can attach a new source location by pressing the button below.
CDebugEditor.3=&Attach Source...
CDebugEditor.4=Can not find the file ''{0}'' in the specified source locations.

View file

@ -1,68 +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.cdt.debug.core.model.ICStackFrame;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IStackFrame;
/**
* The source locator creates an instance of this class if it cannot find the file specified in stack frame.
*
* @since: Feb 21, 2003
*/
public class FileNotFoundElement
{
private IStackFrame fStackFrame;
/**
* Constructor for FileNotFoundElement.
*/
public FileNotFoundElement( IStackFrame stackFrame )
{
fStackFrame = stackFrame;
}
public IPath getFullPath()
{
if ( fStackFrame instanceof ICStackFrame )
{
String fn = ((ICStackFrame)fStackFrame).getFile();
if ( fn != null && fn.trim().length() > 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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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 );
}
}
}

View file

@ -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 ) );
}
}

View file

@ -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$
}
}

View file

@ -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()] );
}
}

View file

@ -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 );
}
}

View file

@ -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 + '!';
}
}
}

View file

@ -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

View file

@ -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();
}

View file

@ -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 <code>"org.eclipse.cdt.debug.ui.DefaultSourceLocator"</code>).
*/
@ -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;
}

View file

@ -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()] );
}
}

View file

@ -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;
}
}

View file

@ -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$
}
}

View file

@ -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.

View file

@ -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();
}
}