Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java17
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java1
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java10
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties5
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/SourcePreferencePage.java276
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddContainerAction.java52
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java155
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/DownAction.java57
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/EditContainerAction.java89
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/MappingSourceContainerBrowser.java25
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/PathMappingDialog.java158
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/RemoveAction.java45
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAction.java176
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java86
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerViewer.java188
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java7
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java34
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties26
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/UpAction.java62
19 files changed, 1264 insertions, 205 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
index ab625e32670..25425edead5 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
@@ -41,7 +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.CDebugEditor;
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;
@@ -153,20 +152,20 @@ 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 );
- }
+// 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;
- }
+// if ( CUIPlugin.EDITOR_ID.equals( id ) ) {
+// return CDebugEditor.EDITOR_ID;
+// }
return id;
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java
index a18f11ea12e..d06781259bd 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java
@@ -66,4 +66,5 @@ public interface ICDebugHelpContextIds
// dialogs
public static final String SOURCE_PATH_MAPPING_DIALOG = PREFIX + "source_path_mapping_dialog_context"; //$NON-NLS-1$
public static final String SOURCE_PATH_MAP_ENTRY_DIALOG = PREFIX + "source_path_map_entry_dialog_context"; //$NON-NLS-1$
+ public static final String ADD_SOURCE_CONTAINER_DIALOG = PREFIX + "add_source_container_dialog"; //$NON-NLS-1$
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java
index e8a220bd7c6..cbc865f945b 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java
@@ -20,10 +20,8 @@ import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
-import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
-import org.eclipse.jface.preference.IPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.PreferenceConverter;
@@ -186,8 +184,8 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
PreferenceConverter.setDefault( store, IInternalCDebugUIConstants.DISASSEMBLY_SOURCE_LINE_COLOR, IInternalCDebugUIConstants.DEFAULT_DISASSEMBLY_SOURCE_LINE_RGB );
}
- /**
- * @see DialogPage#dispose()
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
*/
public void dispose() {
super.dispose();
@@ -274,8 +272,8 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
label.setLayoutData( gd );
}
- /**
- * @see IPreferencePage#performOk() Also, notifies interested listeners
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
public boolean performOk() {
storeValues();
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties
index 40296cbbc26..16ec1a7249c 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties
@@ -22,6 +22,5 @@ CDebugPreferencePage.10=Default register format:
CDebugPreferencePage.11=Disassembly options
CDebugPreferencePage.12=Maximum number of displayed instructions:
CDebugPreferencePage.13=The valid value range is [{0},{1}].
-SourcePreferencePage.0=Common source lookup settings.
-SourcePreferencePage.1=Source Locations
-SourcePreferencePage.2=Search for duplicate source files
+SourcePreferencePage.0=Common source lookup path settings.
+SourcePreferencePage.0=S&ource Lookup Path:
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/SourcePreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/SourcePreferencePage.java
index d7a411d5eb5..968d39720a3 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/SourcePreferencePage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/SourcePreferencePage.java
@@ -1,90 +1,115 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
+ * 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:
+ *
+ * Contributors:
* QNX Software Systems - Initial API and implementation
- ***********************************************************************/
-package org.eclipse.cdt.debug.internal.ui.preferences;
+ ***********************************************************************/
+package org.eclipse.cdt.debug.internal.ui.preferences;
-import java.util.Arrays;
-import java.util.Observable;
-import java.util.Observer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.cdt.debug.core.ICDebugConstants;
-import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
-import org.eclipse.cdt.debug.internal.ui.PixelConverter;
-import org.eclipse.cdt.debug.internal.ui.dialogfields.DialogField;
-import org.eclipse.cdt.debug.internal.ui.dialogfields.IDialogFieldListener;
-import org.eclipse.cdt.debug.internal.ui.dialogfields.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.wizards.AddSourceLocationWizard;
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.cdt.debug.ui.sourcelookup.SourceListDialogField;
+import org.eclipse.cdt.debug.internal.ui.sourcelookup.AddContainerAction;
+import org.eclipse.cdt.debug.internal.ui.sourcelookup.DownAction;
+import org.eclipse.cdt.debug.internal.ui.sourcelookup.EditContainerAction;
+import org.eclipse.cdt.debug.internal.ui.sourcelookup.RemoveAction;
+import org.eclipse.cdt.debug.internal.ui.sourcelookup.SourceContainerAction;
+import org.eclipse.cdt.debug.internal.ui.sourcelookup.SourceContainerViewer;
+import org.eclipse.cdt.debug.internal.ui.sourcelookup.UpAction;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
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.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
/**
- * The "Source Code Locations" preference page.
+ * The "Source Lookup Path" preference page.
*/
-public class SourcePreferencePage extends PreferencePage implements IWorkbenchPreferencePage, Observer {
+public class SourcePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+ private SourceContainerViewer fPathViewer;
+ private List fActions = new ArrayList(6);
private IWorkbench fWorkbench;
+ private AddContainerAction fAddAction;
+ private EditContainerAction fEditAction;
- private SourceListDialogField fSourceListField;
-
- private SelectionButtonDialogField fSearchForDuplicateFiles;
-
- private boolean fChanged = false;
-
- public SourcePreferencePage() {
- super();
- setPreferenceStore( CDebugUIPlugin.getDefault().getPreferenceStore() );
- setDescription( PreferenceMessages.getString( "SourcePreferencePage.0" ) ); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
protected Control createContents( Composite parent ) {
- getWorkbench().getHelpSystem().setHelp( getControl(), ICDebugHelpContextIds.SOURCE_PREFERENCE_PAGE );
- fSourceListField = createSourceListField();
- fSearchForDuplicateFiles = createSearchForDuplicateFilesButton();
- Composite control = new Composite( parent, SWT.NONE );
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 5;
- layout.marginHeight = 5;
- control.setLayout( layout );
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- control.setLayoutData( data );
- control.setFont( JFaceResources.getDialogFont() );
- PixelConverter converter = new PixelConverter( control );
- fSourceListField.doFillIntoGrid( control, 3 );
- LayoutUtil.setHorizontalSpan( fSourceListField.getLabelControl( null ), 2 );
- LayoutUtil.setWidthHint( fSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) );
- LayoutUtil.setHorizontalGrabbing( fSourceListField.getListControl( null ) );
- fSearchForDuplicateFiles.doFillIntoGrid( control, 3 );
- setValues();
- return control;
+ Font font = parent.getFont();
+ Composite comp = new Composite( parent, SWT.NONE );
+ GridLayout topLayout = new GridLayout();
+ topLayout.numColumns = 2;
+ comp.setLayout( topLayout );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ comp.setLayoutData( gd );
+ Label viewerLabel = new Label( comp, SWT.LEFT );
+ viewerLabel.setText( PreferenceMessages.getString( "SourcePreferencePage.0" ) ); //$NON-NLS-1$
+ gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL );
+ gd.horizontalSpan = 2;
+ viewerLabel.setLayoutData( gd );
+ viewerLabel.setFont( font );
+ fPathViewer = new SourceContainerViewer( comp );
+ gd = new GridData( GridData.FILL_BOTH );
+ fPathViewer.getControl().setLayoutData( gd );
+ fPathViewer.getControl().setFont( font );
+ Composite pathButtonComp = new Composite( comp, SWT.NONE );
+ GridLayout pathButtonLayout = new GridLayout();
+ pathButtonLayout.marginHeight = 0;
+ pathButtonLayout.marginWidth = 0;
+ pathButtonComp.setLayout( pathButtonLayout );
+ gd = new GridData( GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL );
+ pathButtonComp.setLayoutData( gd );
+ pathButtonComp.setFont( font );
+ createVerticalSpacer( comp, 2 );
+ GC gc = new GC( parent );
+ gc.setFont( parent.getFont() );
+ FontMetrics fontMetrics = gc.getFontMetrics();
+ gc.dispose();
+ fAddAction = new AddContainerAction();
+ Button button = createPushButton( pathButtonComp, fAddAction.getText(), fontMetrics );
+ fAddAction.setButton( button );
+ addAction( fAddAction );
+ fEditAction = new EditContainerAction();
+ button = createPushButton( pathButtonComp, fEditAction.getText(), fontMetrics );
+ fEditAction.setButton( button );
+ addAction( fEditAction );
+ SourceContainerAction action = new RemoveAction();
+ button = createPushButton( pathButtonComp, action.getText(), fontMetrics );
+ action.setButton( button );
+ addAction( action );
+ action = new UpAction();
+ button = createPushButton( pathButtonComp, action.getText(), fontMetrics );
+ action.setButton( button );
+ addAction( action );
+ action = new DownAction();
+ button = createPushButton( pathButtonComp, action.getText(), fontMetrics );
+ action.setButton( button );
+ addAction( action );
+ retargetActions( fPathViewer );
+ Dialog.applyDialogFont( comp );
+ getWorkbench().getHelpSystem().setHelp( comp, ICDebugHelpContextIds.SOURCE_PREFERENCE_PAGE );
+ initialize();
+ return comp;
}
/*
@@ -96,125 +121,66 @@ public class SourcePreferencePage extends PreferencePage implements IWorkbenchPr
fWorkbench = workbench;
}
- /*
- * (non-Javadoc)
- *
- * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
- */
- public void update( Observable o, Object arg ) {
- setChanged( true );
- }
-
- private SourceListDialogField createSourceListField() {
- SourceListDialogField field = new SourceListDialogField( PreferenceMessages.getString( "SourcePreferencePage.1" ), //$NON-NLS-1$
- new IListAdapter() {
-
- public void customButtonPressed( DialogField f, int index ) {
- sourceButtonPressed( index );
- }
-
- public void selectionChanged( DialogField f ) {
- }
- } );
- field.addObserver( this );
- return field;
- }
-
- private SelectionButtonDialogField createSearchForDuplicateFilesButton() {
- SelectionButtonDialogField button = new SelectionButtonDialogField( SWT.CHECK );
- button.setLabelText( PreferenceMessages.getString( "SourcePreferencePage.2" ) ); //$NON-NLS-1$
- button.setDialogFieldListener( new IDialogFieldListener() {
-
- public void dialogFieldChanged( DialogField field ) {
- setChanged( true );
- }
- } );
+ private Button createPushButton( Composite parent, String label, FontMetrics fontMetrics ) {
+ Button button = new Button( parent, SWT.PUSH );
+ button.setFont( parent.getFont() );
+ button.setText( label );
+ GridData gd = getButtonGridData( button, fontMetrics );
+ button.setLayoutData( gd );
return button;
}
- protected void sourceButtonPressed( int index ) {
- switch( index ) {
- case 0: // Add...
- if ( addSourceLocation() )
- setChanged( true );
- break;
- case 2: // Up
- case 3: // Down
- case 5: // Remove
- setChanged( true );
- break;
- }
+ private GridData getButtonGridData( Button button, FontMetrics fontMetrics ) {
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING );
+ int widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH );
+ gd.widthHint = Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x );
+ return gd;
}
- protected boolean isChanged() {
- return fChanged;
+ private IWorkbench getWorkbench() {
+ return fWorkbench;
}
- protected void setChanged( boolean changed ) {
- fChanged = changed;
+ private void addAction( SourceContainerAction action ) {
+ fActions.add( action );
}
- private boolean addSourceLocation() {
- AddSourceLocationWizard wizard = new AddSourceLocationWizard( getSourceLocations() );
- WizardDialog dialog = new WizardDialog( getShell(), wizard );
- if ( dialog.open() == Window.OK ) {
- fSourceListField.addElement( wizard.getSourceLocation() );
- return true;
+ private void retargetActions( SourceContainerViewer viewer ) {
+ Iterator actions = fActions.iterator();
+ while( actions.hasNext() ) {
+ SourceContainerAction action = (SourceContainerAction)actions.next();
+ action.setViewer( viewer );
}
- return false;
}
- public ICSourceLocation[] getSourceLocations() {
- return (fSourceListField != null) ? fSourceListField.getSourceLocations() : new ICSourceLocation[0];
+ private void createVerticalSpacer( Composite comp, int colSpan ) {
+ Label label = new Label( comp, SWT.NONE );
+ GridData gd = new GridData();
+ gd.horizontalSpan = colSpan;
+ label.setLayoutData( gd );
}
- public void setSourceLocations( ICSourceLocation[] locations ) {
- if ( fSourceListField != null )
- fSourceListField.setElements( Arrays.asList( locations ) );
+ private void initialize() {
+ ISourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
+ fPathViewer.setEntries( director.getSourceContainers() );
+ fAddAction.setSourceLookupDirector( director );
+ fEditAction.setSourceLookupDirector( director );
}
- /*
- * (non-Javadoc)
- *
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/
protected void performDefaults() {
- setSourceLocations( new ICSourceLocation[0] );
- setSearchForDuplicateFiles( false );
+ fPathViewer.setEntries( new ISourceContainer[0] );
super.performDefaults();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
*/
public boolean performOk() {
- storeValues();
+ CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().setSourceContainers( fPathViewer.getEntries() );
CDebugCorePlugin.getDefault().savePluginPreferences();
return true;
}
-
- private boolean searchForDuplicateFiles() {
- return (fSearchForDuplicateFiles != null) ? fSearchForDuplicateFiles.isSelected() : false;
- }
-
- private void setSearchForDuplicateFiles( boolean search ) {
- if ( fSearchForDuplicateFiles != null )
- fSearchForDuplicateFiles.setSelection( search );
- }
-
- private void setValues() {
- setSourceLocations( CDebugCorePlugin.getDefault().getCommonSourceLocations() );
- setSearchForDuplicateFiles( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) );
- }
-
- private void storeValues() {
- CDebugCorePlugin.getDefault().saveCommonSourceLocations( getSourceLocations() );
- CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES, searchForDuplicateFiles() );
- }
-
- private IWorkbench getWorkbench() {
- return fWorkbench;
- }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddContainerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddContainerAction.java
new file mode 100644
index 00000000000..f7309fa14e2
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddContainerAction.java
@@ -0,0 +1,52 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ ***********************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * The action to add a new source container.
+ * Used by the CommonSourceNotFoundEditor, the launch configuration source tab,
+ * and the EditSourceLookupPathDialog.
+ */
+public class AddContainerAction extends SourceContainerAction {
+
+ private ISourceLookupDirector fDirector;
+
+ public AddContainerAction() {
+ super(SourceLookupUIMessages.getString( "AddContainerAction.0" )); //$NON-NLS-1$
+ }
+
+ /**
+ * Prompts for a project to add.
+ *
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run() {
+ AddSourceContainerDialog dialog = new AddSourceContainerDialog(getShell(), getViewer(), fDirector);
+ dialog.open();
+ }
+
+ public void setSourceLookupDirector(ISourceLookupDirector director) {
+ fDirector = director;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ if(selection == null || selection.isEmpty()) {
+ return true;
+ }
+ return getViewer().getTree().getSelection()[0].getParentItem()==null;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java
new file mode 100644
index 00000000000..1a2f28c172a
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+
+import java.util.ArrayList;
+import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIUtils;
+import org.eclipse.debug.ui.sourcelookup.ISourceContainerBrowser;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * The dialog for adding new source containers. Presents the user with a list of
+ * source container types and allows them to select one.
+ *
+ * @since 3.0
+ */
+public class AddSourceContainerDialog extends TitleAreaDialog {
+
+ private TableViewer fViewer;
+ private SourceContainerViewer fSourceContainerViewer;
+ private boolean fDoubleClickSelects = true;
+ private ISourceLookupDirector fDirector;
+
+ /**
+ * Constructor
+ */
+ public AddSourceContainerDialog(Shell shell, SourceContainerViewer viewer, ISourceLookupDirector director) {
+ super(shell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ fSourceContainerViewer=viewer;
+ fDirector = director;
+ }
+
+ /**
+ * Creates the dialog area to display source container types that are "browseable"
+ */
+ protected Control createDialogArea(Composite ancestor) {
+
+ getShell().setText(SourceLookupUIMessages.getString( "AddSourceContainerDialog.0" )); //$NON-NLS-1$
+ setTitle(SourceLookupUIMessages.getString( "AddSourceContainerDialog.1" )); //$NON-NLS-1$
+
+ Composite parent = new Composite(ancestor, SWT.NULL);
+ GridData gd= new GridData(GridData.FILL_BOTH);
+ GridLayout topLayout = new GridLayout();
+ topLayout.numColumns = 1;
+ parent.setLayout(topLayout);
+ parent.setLayoutData(gd);
+
+ ISourceContainerType[] types = filterTypes(DebugPlugin.getDefault().getLaunchManager().getSourceContainerTypes());
+
+ fViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE);
+ final Table table = fViewer.getTable();
+ gd = new GridData(GridData.FILL_BOTH);
+ table.setLayoutData(gd);
+
+ if (fDoubleClickSelects) {
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ if (table.getSelectionCount() == 1)
+ okPressed();
+ }
+ });
+ }
+
+ fViewer.setLabelProvider(new SourceContainerLabelProvider());
+ fViewer.setContentProvider(new ArrayContentProvider());
+ fViewer.setSorter(new ViewerSorter());
+ fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection selection = event.getSelection();
+ String desc = null;
+ if (!selection.isEmpty()) {
+ ISourceContainerType type = (ISourceContainerType) ((IStructuredSelection)selection).getFirstElement();
+ desc = type.getDescription();
+ }
+ setMessage(desc);
+ }
+ });
+ if(types.length != 0) {
+ fViewer.setInput(types);
+ }
+ Dialog.applyDialogFont(parent);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.ADD_SOURCE_CONTAINER_DIALOG );
+ return parent;
+ }
+
+ /**
+ * Removes types without browsers from the provided list of types.
+ * @param types the complete list of source container types
+ * @return the list of source container types that have browsers
+ */
+ private ISourceContainerType[] filterTypes(ISourceContainerType[] types){
+ ArrayList validTypes = new ArrayList();
+ for (int i=0; i< types.length; i++) {
+ ISourceContainerType type = types[i];
+ if (fDirector.supportsSourceContainerType(type)) {
+ ISourceContainerBrowser sourceContainerBrowser = SourceLookupUIUtils.getSourceContainerBrowser(type.getId());
+ if(sourceContainerBrowser != null && sourceContainerBrowser.canAddSourceContainers(fDirector)) {
+ validTypes.add(type);
+ }
+ }
+ }
+ return (ISourceContainerType[]) validTypes.toArray(new ISourceContainerType[validTypes.size()]);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed() {
+ //single selection dialog, so take first item in array
+ //there will always be a selected item since we set it with viewer.setSelection
+ ISourceContainerType type = (ISourceContainerType) ((StructuredSelection) fViewer.getSelection()).getFirstElement();
+ ISourceContainerBrowser browser = SourceLookupUIUtils.getSourceContainerBrowser(type.getId());
+ if (browser != null) {
+ ISourceContainer[] results = browser.addSourceContainers(getShell(), fDirector);
+ if(results != null) {
+ fSourceContainerViewer.addEntries(results);
+ }
+ }
+ super.okPressed();
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/DownAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/DownAction.java
new file mode 100644
index 00000000000..bc9a532bcf9
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/DownAction.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * The action for sorting the order of source containers in the dialog.
+ *
+ */
+public class DownAction extends SourceContainerAction {
+
+ public DownAction() {
+ super(SourceLookupUIMessages.getString( "DownAction.0" )); //$NON-NLS-1$
+ }
+ /**
+ * @see IAction#run()
+ */
+ public void run() {
+ List targets = getOrderedSelection();
+ if (targets.isEmpty()) {
+ return;
+ }
+ List list = getEntriesAsList();
+ int bottom = list.size() - 1;
+ int index = 0;
+ for (int i = targets.size() - 1; i >= 0; i--) {
+ Object target = targets.get(i);
+ index = list.indexOf(target);
+ if (index < bottom) {
+ bottom = index + 1;
+ Object temp = list.get(bottom);
+ list.set(bottom, target);
+ list.set(index, temp);
+ }
+ bottom = index;
+ }
+ setEntries(list);
+ }
+
+ /**
+ * @see SelectionListenerAction#updateSelection(IStructuredSelection)
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ return !selection.isEmpty() && !isIndexSelected(selection, getEntriesAsList().size() - 1) && getViewer().getTree().getSelection()[0].getParentItem()==null;
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/EditContainerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/EditContainerAction.java
new file mode 100644
index 00000000000..9c84a224585
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/EditContainerAction.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+
+import java.util.Iterator;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIUtils;
+import org.eclipse.debug.ui.sourcelookup.ISourceContainerBrowser;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * Action used to edit source containers on a source lookup path
+ */
+public class EditContainerAction extends SourceContainerAction {
+
+ private ISourceLookupDirector fDirector;
+ private ISourceContainer[] fContainers;
+ private ISourceContainerBrowser fBrowser;
+
+ public EditContainerAction() {
+ super(SourceLookupUIMessages.getString( "EditContainerAction.0" )); //$NON-NLS-1$
+ }
+
+ /**
+ * Prompts for a project to add.
+ *
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run() {
+ ISourceContainer[] replacements = fBrowser.editSourceContainers(getShell(), fDirector, fContainers);
+ int j = 0;
+ ISourceContainer[] existing = getViewer().getEntries();
+ for (int i = 0; i < existing.length && j < replacements.length; i++) {
+ ISourceContainer toBeReplaced = fContainers[j];
+ ISourceContainer container = existing[i];
+ if (container.equals(toBeReplaced)) {
+ existing[i] = replacements[j];
+ j++;
+ }
+ }
+ getViewer().setEntries(existing);
+ }
+
+ public void setSourceLookupDirector(ISourceLookupDirector director) {
+ fDirector = director;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ if(selection == null || selection.isEmpty()) {
+ return false;
+ }
+ if (getViewer().getTree().getSelection()[0].getParentItem()==null) {
+ // can only edit top level items of same type
+ fContainers = new ISourceContainer[selection.size()];
+ Iterator iterator = selection.iterator();
+ ISourceContainer container = (ISourceContainer) iterator.next();
+ ISourceContainerType type = container.getType();
+ fContainers[0] = container;
+ int i = 1;
+ while (iterator.hasNext()) {
+ container = (ISourceContainer) iterator.next();
+ fContainers[i] = container;
+ i++;
+ if (!container.getType().equals(type)) {
+ return false;
+ }
+ }
+ // all the same type, see if editing is supported
+ fBrowser = SourceLookupUIUtils.getSourceContainerBrowser(type.getId());
+ if (fBrowser != null) {
+ return fBrowser.canEditSourceContainers(fDirector, fContainers);
+ }
+ }
+ return false;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/MappingSourceContainerBrowser.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/MappingSourceContainerBrowser.java
index 99b56e94bad..ddcd56ed426 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/MappingSourceContainerBrowser.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/MappingSourceContainerBrowser.java
@@ -22,11 +22,13 @@ import org.eclipse.swt.widgets.Shell;
*/
public class MappingSourceContainerBrowser extends AbstractSourceContainerBrowser {
+ private static final String MAPPING = SourceLookupUIMessages.getString( "MappingSourceContainerBrowser.0" ); //$NON-NLS-1$
+
/* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
*/
public ISourceContainer[] addSourceContainers( Shell shell, ISourceLookupDirector director ) {
- return new ISourceContainer[] { new MappingSourceContainer() };
+ return new ISourceContainer[] { new MappingSourceContainer( generateName( director ) ) };
}
/* (non-Javadoc)
@@ -55,4 +57,25 @@ public class MappingSourceContainerBrowser extends AbstractSourceContainerBrowse
}
return new ISourceContainer[0];
}
+
+ private String generateName( ISourceLookupDirector director ) {
+// int counter = 1;
+// ISourceContainer[] containers = director.getSourceContainers();
+// for ( int i = 0; i < containers.length; ++i ) {
+// if ( MappingSourceContainer.TYPE_ID.equals( containers[i].getType().getId() ) ) {
+// String name = containers[i].getName();
+// if ( name.startsWith( MAPPING ) ) {
+// try {
+// int number = Integer.valueOf( name.substring( MAPPING.length() ) ).intValue();
+// if ( number == counter )
+// ++counter;
+// }
+// catch( NumberFormatException e ) {
+// }
+// }
+// }
+// }
+// return MAPPING + counter;
+ return MAPPING;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/PathMappingDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/PathMappingDialog.java
index c22167a2e45..d3448cce343 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/PathMappingDialog.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/PathMappingDialog.java
@@ -10,6 +10,7 @@
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+import java.io.File;
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
@@ -22,9 +23,11 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
+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.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
@@ -57,8 +60,9 @@ public class PathMappingDialog extends TitleAreaDialog {
class MapEntryDialog extends TitleAreaDialog {
- protected Text fBackendPathText;
+ private MapEntrySourceContainer fEntry;
+ protected Text fBackendPathText;
protected Text fLocalPathText;
/**
@@ -66,13 +70,22 @@ public class PathMappingDialog extends TitleAreaDialog {
*/
public MapEntryDialog( Shell parentShell ) {
super( parentShell );
+ fEntry = null;
}
+ /**
+ * Constructor for MapEntryDialog.
+ */
+ public MapEntryDialog( Shell parentShell, MapEntrySourceContainer entry ) {
+ super( parentShell );
+ fEntry = entry;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea( Composite parent ) {
- setTitle( "Specify the mapping paths" );
+ setTitle( SourceLookupUIMessages.getString( "PathMappingDialog.0" ) ); //$NON-NLS-1$
Font font = parent.getFont();
Composite composite = new Composite( parent, SWT.NONE );
@@ -93,7 +106,7 @@ public class PathMappingDialog extends TitleAreaDialog {
setMessage( null );
Label label = new Label( composite, SWT.LEFT );
- label.setText( "Compilation path:" );
+ label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.1" ) ); //$NON-NLS-1$
data = new GridData( GridData.FILL_HORIZONTAL );
data.horizontalSpan = 2;
label.setLayoutData( data );
@@ -111,7 +124,7 @@ public class PathMappingDialog extends TitleAreaDialog {
} );
label = new Label( composite, SWT.LEFT );
- label.setText( "Local file system path:" );
+ label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.2" ) ); //$NON-NLS-1$
data = new GridData( GridData.FILL_HORIZONTAL );
data.horizontalSpan = 2;
label.setLayoutData( data );
@@ -129,7 +142,7 @@ public class PathMappingDialog extends TitleAreaDialog {
Button button = new Button( composite, SWT.PUSH );
button.setFont( font );
- button.setText( "&Browse..." );
+ button.setText( SourceLookupUIMessages.getString( "PathMappingDialog.3" ) ); //$NON-NLS-1$
button.addSelectionListener( new SelectionListener() {
public void widgetSelected( SelectionEvent e ) {
@@ -149,15 +162,23 @@ public class PathMappingDialog extends TitleAreaDialog {
protected Control createContents( Composite parent ) {
Control control = super.createContents( parent );
+ initialize();
update();
return control;
}
protected void configureShell( Shell newShell ) {
- newShell.setText( "Path Mapping" );
+ newShell.setText( SourceLookupUIMessages.getString( "PathMappingDialog.4" ) ); //$NON-NLS-1$
super.configureShell( newShell );
}
+ private void initialize() {
+ if ( fEntry != null ) {
+ fBackendPathText.setText( fEntry.getBackendPath().toOSString() );
+ fLocalPathText.setText( fEntry.getLocalPath().toOSString() );
+ }
+ }
+
protected void update() {
boolean isOk = updateErrorMessage();
Button ok = getButton( IDialogConstants.OK_ID );
@@ -169,20 +190,29 @@ public class PathMappingDialog extends TitleAreaDialog {
setErrorMessage( null );
String backendText = fBackendPathText.getText().trim();
if ( backendText.length() == 0 ) {
- setErrorMessage( "The compilation path must not be empty" );
+ setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.5" ) ); //$NON-NLS-1$
return false;
}
if ( !new Path( backendText ).isValidPath( backendText ) ) {
- setErrorMessage( "Invalid compilation path." );
+ setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.6" ) ); //$NON-NLS-1$
return false;
}
String localText = fLocalPathText.getText().trim();
if ( localText.length() == 0 ) {
- setErrorMessage( "The local file systems path must not be empty" );
+ setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.7" ) ); //$NON-NLS-1$
return false;
}
- if ( !new Path( localText ).isValidPath( localText ) ) {
- setErrorMessage( "Invalid local file system path." );
+ File localPath = new File( localText );
+ if ( !localPath.exists() ) {
+ setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.8" ) ); //$NON-NLS-1$
+ return false;
+ }
+ if ( !localPath.isDirectory() ) {
+ setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.9" ) ); //$NON-NLS-1$
+ return false;
+ }
+ if ( !localPath.isAbsolute() ) {
+ setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.10" ) ); //$NON-NLS-1$
return false;
}
return true;
@@ -197,7 +227,12 @@ public class PathMappingDialog extends TitleAreaDialog {
}
protected void okPressed() {
- fMapping.addMapEntry( new MapEntrySourceContainer( getBackendPath(), getLocalPath() ) );
+ if ( fEntry == null ) {
+ fEntry = new MapEntrySourceContainer();
+ fMapping.addMapEntry( fEntry );
+ }
+ fEntry.setBackendPath( getBackendPath() );
+ fEntry.setLocalPath( getLocalPath() );
super.okPressed();
}
}
@@ -287,26 +322,31 @@ public class PathMappingDialog extends TitleAreaDialog {
private TableViewer fViewer;
+ private Text fNameText;
private Button fAddButton;
+ private Button fEditButton;
private Button fRemoveButton;
public PathMappingDialog( Shell parentShell, MappingSourceContainer mapping ) {
super( parentShell );
fOriginalMapping = mapping;
- fMapping = new MappingSourceContainer();
- try {
- fMapping.addMapEntries( (MapEntrySourceContainer[])mapping.getSourceContainers() );
- }
- catch( CoreException e ) {
- setErrorMessage( e.getMessage() );
- }
+ fMapping = fOriginalMapping.copy();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents( Composite parent ) {
+ Control control = super.createContents( parent );
+ updateButtons();
+ return control;
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea( Composite parent ) {
- setTitle( "Modify the list of path mappings" );
+ setTitle( SourceLookupUIMessages.getString( "PathMappingDialog.11" ) ); //$NON-NLS-1$
//TODO Add image
Font font = parent.getFont();
@@ -325,10 +365,39 @@ public class PathMappingDialog extends TitleAreaDialog {
Dialog.applyDialogFont( composite );
PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAPPING_DIALOG );
+ Composite nameComp = new Composite( composite, SWT.NONE );
+ layout = new GridLayout();
+ layout.numColumns = 2;
+ nameComp.setLayout( layout );
+ data = new GridData( GridData.FILL_HORIZONTAL );
+ data.horizontalSpan = 2;
+ nameComp.setLayoutData( data );
+ nameComp.setFont( font );
+
+ Label label = new Label( nameComp, SWT.LEFT );
+ data = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+ label.setLayoutData( data );
+ label.setFont( font );
+ label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.12" ) ); //$NON-NLS-1$
+ fNameText = new Text( nameComp, SWT.SINGLE | SWT.BORDER );
+ data = new GridData( GridData.FILL_HORIZONTAL );
+ fNameText.setLayoutData( data );
+ fNameText.setFont( font );
+ fNameText.setText( getMapping().getName() );
+ fNameText.addModifyListener( new ModifyListener() {
+ public void modifyText( ModifyEvent e ) {
+ }
+ } );
+
fViewer = createViewer( composite );
data = new GridData( GridData.FILL_BOTH );
fViewer.getControl().setLayoutData( data );
fViewer.getControl().setFont( font );
+ fViewer.addSelectionChangedListener( new ISelectionChangedListener() {
+ public void selectionChanged( SelectionChangedEvent event ) {
+ updateButtons();
+ }
+ } );
Composite buttonComp = new Composite( composite, SWT.NONE );
GridLayout buttonLayout = new GridLayout();
@@ -344,7 +413,7 @@ public class PathMappingDialog extends TitleAreaDialog {
FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose();
- fAddButton = createPushButton( buttonComp, "&Add...", fontMetrics );
+ fAddButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.13" ), fontMetrics ); //$NON-NLS-1$
fAddButton.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent evt ) {
MapEntryDialog dialog = new MapEntryDialog( getShell() );
@@ -354,17 +423,27 @@ public class PathMappingDialog extends TitleAreaDialog {
}
} );
- fRemoveButton = createPushButton( buttonComp, "Re&move", fontMetrics );
+ fEditButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.14" ), fontMetrics ); //$NON-NLS-1$
+ fEditButton.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected( SelectionEvent evt ) {
+ MapEntrySourceContainer[] entries = getSelection();
+ if ( entries.length > 0 ) {
+ MapEntryDialog dialog = new MapEntryDialog( getShell(), entries[0] );
+ if ( dialog.open() == Window.OK ) {
+ getViewer().refresh();
+ }
+ }
+ }
+ } );
+
+ fRemoveButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.15" ), fontMetrics ); //$NON-NLS-1$
fRemoveButton.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent evt ) {
- ISelection s = getViewer().getSelection();
- if ( s instanceof IStructuredSelection ) {
- Object[] ss = ((IStructuredSelection)s).toArray();
- for ( int i = 0; i < ss.length; ++i ) {
- fMapping.removeMapEntry( (MapEntrySourceContainer)ss[i] );
+ MapEntrySourceContainer[] entries = getSelection();
+ for ( int i = 0; i < entries.length; ++i ) {
+ fMapping.removeMapEntry( entries[i] );
}
getViewer().refresh();
- }
}
} );
@@ -406,7 +485,7 @@ public class PathMappingDialog extends TitleAreaDialog {
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/
protected void configureShell( Shell newShell ) {
- newShell.setText( "Path Mappings" );
+ newShell.setText( SourceLookupUIMessages.getString( "PathMappingDialog.16" ) ); //$NON-NLS-1$
super.configureShell( newShell );
}
@@ -419,6 +498,7 @@ public class PathMappingDialog extends TitleAreaDialog {
*/
protected void okPressed() {
fOriginalMapping.clear();
+ fOriginalMapping.setName( fNameText.getText().trim() );
try {
fOriginalMapping.addMapEntries( (MapEntrySourceContainer[])fMapping.getSourceContainers() );
}
@@ -427,4 +507,24 @@ public class PathMappingDialog extends TitleAreaDialog {
fMapping.dispose();
super.okPressed();
}
+
+ protected MapEntrySourceContainer[] getSelection() {
+ MapEntrySourceContainer[] result = new MapEntrySourceContainer[0];
+ ISelection s = getViewer().getSelection();
+ if ( s instanceof IStructuredSelection ) {
+ int size = ((IStructuredSelection)s).size();
+ result = (MapEntrySourceContainer[])((IStructuredSelection)s).toList().toArray( new MapEntrySourceContainer[size] );
+ }
+ return result;
+ }
+
+ protected void updateButtons() {
+ MapEntrySourceContainer[] entries = getSelection();
+ if ( fEditButton != null ) {
+ fEditButton.setEnabled( entries.length == 1 );
+ }
+ if ( fRemoveButton != null ) {
+ fRemoveButton.setEnabled( entries.length > 0 );
+ }
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/RemoveAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/RemoveAction.java
new file mode 100644
index 00000000000..f2449434000
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/RemoveAction.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * The action used to remove source containers in the source location dialog/tab.
+ *
+ */
+public class RemoveAction extends SourceContainerAction {
+ public RemoveAction() {
+ super(SourceLookupUIMessages.getString( "RemoveAction.0" )); //$NON-NLS-1$
+ }
+ /**
+ * Removes all selected entries.
+ *
+ * @see IAction#run()
+ */
+ public void run() {
+ List targets = getOrderedSelection();
+ List list = getEntriesAsList();
+ list.removeAll(targets);
+ setEntries(list);
+ }
+
+ /**
+ * @see SelectionListenerAction#updateSelection(IStructuredSelection)
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ //check that something is selected and it is a root tree node.
+ return !selection.isEmpty() && getViewer().getTree().getSelection()[0].getParentItem()==null;
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAction.java
new file mode 100644
index 00000000000..bd77e60ebac
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAction.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.SelectionListenerAction;
+
+/**
+ * The abstract class for all source lookup actions.
+ */
+public abstract class SourceContainerAction extends SelectionListenerAction {
+ //the viewer that the action is operating on
+ private SourceContainerViewer fViewer;
+ //the button that is used to invoke the action
+ private Button fButton;
+ //the shell used to realize this action's dialog (if any)
+ private Shell fShell;
+
+ /**
+ * The constructor for the action
+ * @param label the label for the action's button
+ */
+ public SourceContainerAction(String label) {
+ super(label);
+ }
+
+ /**
+ * Sets the viewer on which this action operates.
+ *
+ * @param viewer the viewer on which this action operates
+ */
+ public void setViewer(SourceContainerViewer viewer) {
+ if (fViewer != null) {
+ fViewer.removeSelectionChangedListener(this);
+ }
+ fViewer = viewer;
+ if (fViewer != null) {
+ fViewer.addSelectionChangedListener(this);
+ update();
+ }
+ }
+
+ /**
+ * Returns the viewer on which this action operates.
+ *
+ * @return the viewer on which this action operates
+ */
+ protected SourceContainerViewer getViewer() {
+ return fViewer;
+ }
+
+ /**
+ * Returns the selected items in the list, in the order they are
+ * displayed.
+ *
+ * @return targets for an action
+ */
+ protected List getOrderedSelection() {
+ List targets = new ArrayList();
+ List selection =
+ ((IStructuredSelection) getViewer().getSelection()).toList();
+ ISourceContainer[] entries = getViewer().getEntries();
+ for (int i = 0; i < entries.length; i++) {
+ ISourceContainer target = entries[i];
+ if (selection.contains(target)) {
+ targets.add(target);
+ }
+ }
+ return targets;
+ }
+
+ /**
+ * Returns a list (copy) of the entries in the viewer
+ */
+ protected List getEntriesAsList() {
+ ISourceContainer[] entries = getViewer().getEntries();
+ List list = new ArrayList(entries.length);
+ for (int i = 0; i < entries.length; i++) {
+ list.add(entries[i]);
+ }
+ return list;
+ }
+
+ /**
+ * Updates the entries to the entries in the given list
+ */
+ protected void setEntries(List list) {
+ getViewer().setEntries(
+ (ISourceContainer[]) list.toArray(new ISourceContainer[list.size()]));
+ // update all selection listeners
+ getViewer().setSelection(getViewer().getSelection());
+ }
+
+ /**
+ * Returns whether the item at the given index in the list
+ * (visually) is selected.
+ */
+ protected boolean isIndexSelected(
+ IStructuredSelection selection,
+ int index) {
+ if (selection.isEmpty()) {
+ return false;
+ }
+ Iterator entries = selection.iterator();
+ List list = getEntriesAsList();
+ while (entries.hasNext()) {
+ Object next = entries.next();
+ if (list.indexOf(next) == index) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Sets the button that invokes this action
+ */
+ public void setButton(Button button) {
+ fButton = button;
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ run();
+ }
+ });
+ }
+
+ /**
+ * @see IAction#setEnabled(boolean)
+ */
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ if (fButton != null) {
+ fButton.setEnabled(enabled);
+ }
+ }
+
+ /**
+ * Updates the enabled state.
+ */
+ protected void update() {
+ selectionChanged((IStructuredSelection) getViewer().getSelection());
+ }
+
+ /**
+ * Returns the shell used to realize this action's dialog (if any).
+ */
+ protected Shell getShell() {
+ if (fShell == null) {
+ fShell = getViewer().getControl().getShell();
+ }
+ return fShell;
+ }
+
+ /**
+ * Sets the shell used to realize this action's dialog (if any).
+ */
+ public void setShell(Shell shell) {
+ fShell = shell;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java
new file mode 100644
index 00000000000..a210e4c244b
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java
@@ -0,0 +1,86 @@
+/**********************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
+import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIUtils;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * Label provider for source containers and source container types.
+ */
+public class SourceContainerLabelProvider extends LabelProvider {
+
+ private ILabelProvider fLabelProvider = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+ */
+ public Image getImage(Object element) {
+ // first allow workbench adapter to provide image
+ Image image = getWorkbenchLabelProvider().getImage(element);
+ if (image == null) {
+ ISourceContainerType type = null;
+ if (element instanceof ISourceContainer) {
+ type = ((ISourceContainer)element).getType();
+ } else if (element instanceof ISourceContainerType) {
+ type = (ISourceContainerType) element;
+ }
+ if (type != null) {
+ // next consult contributed image
+ image = SourceLookupUIUtils.getSourceContainerImage(type.getId());
+ }
+ }
+ if (image != null) {
+ return image;
+ }
+ return super.getImage(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+ */
+ public String getText(Object element) {
+ // first, allo workbench adapter to provide label
+ String label = getWorkbenchLabelProvider().getText(element);
+ if (label == null || label.length() == 0) {
+ if (element instanceof ISourceContainer) {
+ return ((ISourceContainer) element).getName();
+ } else if (element instanceof ISourceContainerType) {
+ return ((ISourceContainerType)element).getName();
+ }
+ } else {
+ return label;
+ }
+ return super.getText(element);
+ }
+
+ private ILabelProvider getWorkbenchLabelProvider() {
+ if (fLabelProvider == null) {
+ fLabelProvider = new WorkbenchLabelProvider();
+ }
+ return fLabelProvider;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ if (fLabelProvider != null) {
+ fLabelProvider.dispose();
+ }
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerViewer.java
new file mode 100644
index 00000000000..e795b09db10
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerViewer.java
@@ -0,0 +1,188 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ ***********************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The viewer containing the source containers.
+ * It is a tree viewer since the containers are represented in tree form.
+ */
+public class SourceContainerViewer extends TreeViewer {
+
+ /**
+ * Whether enabled/editable.
+ */
+ private boolean fEnabled = true;
+ /**
+ * The source container entries displayed in this viewer
+ */
+ protected List fEntries = new ArrayList();
+
+ class ContentProvider implements ITreeContentProvider {
+
+ /**
+ * @see IStructuredContentProvider#getElements(Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return getEntries();
+ }
+
+ /**
+ * @see IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @see IContentProvider#inputChanged(Viewer, Object, Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object parentElement) {
+ try {
+ return ((ISourceContainer)parentElement).getSourceContainers();
+ } catch (CoreException e) {
+ return new Object[0];
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ public boolean hasChildren(Object element) {
+ return ((ISourceContainer)element).isComposite();
+ }
+
+ }
+
+ /**
+ * Creates a runtime classpath viewer with the given parent.
+ *
+ * @param parent the parent control
+ * @param panel the panel hosting this viewer
+ */
+ public SourceContainerViewer(Composite parent) {
+ super(parent);
+ setContentProvider(new ContentProvider());
+ SourceContainerLabelProvider lp = new SourceContainerLabelProvider();
+ setLabelProvider(lp);
+ }
+
+ /**
+ * Sets the entries in this viewer
+ *
+ * @param entries source container entries
+ */
+ public void setEntries(ISourceContainer[] entries) {
+ fEntries.clear();
+ for (int i = 0; i < entries.length; i++) {
+ if(entries[i] != null)
+ fEntries.add(entries[i]);
+ }
+ if (getInput() == null) {
+ setInput(fEntries);
+ //select first item in list
+ if(!fEntries.isEmpty() && fEntries.get(0)!=null)
+ setSelection(new StructuredSelection(fEntries.get(0)));
+ } else {
+ refresh();
+ }
+ }
+
+ /**
+ * Returns the entries in this viewer
+ *
+ * @return the entries in this viewer
+ */
+ public ISourceContainer[] getEntries() {
+ return (ISourceContainer[])fEntries.toArray(new ISourceContainer[fEntries.size()]);
+ }
+
+ /**
+ * Adds the given entries to the list. If there is no selection
+ * in the list, the entries are added at the end of the list,
+ * otherwise the new entries are added before the (first) selected
+ * entry. The new entries are selected.
+ *
+ * @param entries additions
+ */
+ public void addEntries(ISourceContainer[] entries) {
+ IStructuredSelection sel = (IStructuredSelection)getSelection();
+ if (sel.isEmpty()) {
+ for (int i = 0; i < entries.length; i++) {
+ if (!fEntries.contains(entries[i])) {
+ fEntries.add(entries[i]);
+ }
+ }
+ }
+ else {
+ int index = fEntries.indexOf(sel.getFirstElement());
+ for (int i = 0; i < entries.length; i++) {
+ if (!fEntries.contains(entries[i])) {
+ fEntries.add(index, entries[i]);
+ index++;
+ }
+ }
+ }
+
+ if(!fEntries.isEmpty() && fEntries.get(0)!=null)
+ setSelection(new StructuredSelection(fEntries.get(0)));
+ refresh();
+ }
+
+ /**
+ * Enables/disables this viewer. Note the control is not disabled, since
+ * we still want the user to be able to scroll if required to see the
+ * existing entries. Just actions should be disabled.
+ */
+ public void setEnabled(boolean enabled) {
+ fEnabled = enabled;
+ // fire selection change to upate actions
+ setSelection(getSelection());
+ }
+
+ /**
+ * Returns whether this viewer is enabled
+ */
+ public boolean isEnabled() {
+ return fEnabled;
+ }
+
+ /**
+ * Returns the index of an equivalent entry, or -1 if none.
+ *
+ * @return the index of an equivalent entry, or -1 if none
+ */
+ public int indexOf(ISourceContainer entry) {
+ return fEntries.indexOf(entry);
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java
index 78185f39a4b..47942de407d 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java
@@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
@@ -44,7 +45,9 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
}
if ( o instanceof ProjectSourceContainer ) {
IProject project = ((ProjectSourceContainer)o).getProject();
- return getImageDescriptor( CCorePlugin.getDefault().getCoreModel().create( project ) );
+ ICProject cProject = CCorePlugin.getDefault().getCoreModel().create( project );
+ if ( cProject != null )
+ return getImageDescriptor( cProject );
}
return null;
}
@@ -62,7 +65,7 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
*/
public String getLabel( Object o ) {
if ( o instanceof MappingSourceContainer ) {
- return ((MappingSourceContainer)o).getName();
+ return SourceLookupUIMessages.getString( "SourceContainerWorkbenchAdapter.0" ) + ((MappingSourceContainer)o).getName(); //$NON-NLS-1$
}
if ( o instanceof MapEntrySourceContainer ) {
return ((MapEntrySourceContainer)o).getName();
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java
new file mode 100644
index 00000000000..48a90e5484f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java
@@ -0,0 +1,34 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ ***********************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class SourceLookupUIMessages {
+
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.sourcelookup.SourceLookupUIMessages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+ private SourceLookupUIMessages() {
+ }
+
+ public static String getString( String key ) {
+ // TODO Auto-generated method stub
+ try {
+ return RESOURCE_BUNDLE.getString( key );
+ }
+ catch( MissingResourceException e ) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
new file mode 100644
index 00000000000..0338d993b41
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
@@ -0,0 +1,26 @@
+AddContainerAction.0=&Add...
+AddSourceContainerDialog.0=Add Source
+AddSourceContainerDialog.1=Select the type of source to add to the source lookup path
+DownAction.0=&Down
+EditContainerAction.0=&Edit...
+MappingSourceContainerBrowser.0=New Mapping
+PathMappingDialog.0=Specify the mapping paths
+PathMappingDialog.1=Compilation path:
+PathMappingDialog.2=Local file system path:
+PathMappingDialog.3=&Browse...
+PathMappingDialog.4=Path Mapping
+PathMappingDialog.5=The compilation path must not be empty
+PathMappingDialog.6=Invalid compilation path.
+PathMappingDialog.7=The local file systems path must not be empty
+PathMappingDialog.8=The specified local file system path doesn't exist
+PathMappingDialog.9=The local file system path must be a directory
+PathMappingDialog.10=The local file system path must be absolute
+PathMappingDialog.11=Modify the path mappings
+PathMappingDialog.12=Name:
+PathMappingDialog.13=&Add...
+PathMappingDialog.14=&Edit...
+PathMappingDialog.15=Re&move
+PathMappingDialog.16=Path Mappings
+RemoveAction.0=Re&move
+SourceContainerWorkbenchAdapter.0=Path Mapping:
+UpAction.0=U&p
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/UpAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/UpAction.java
new file mode 100644
index 00000000000..168b558936f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/UpAction.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.sourcelookup;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * The action used to move source containers up in the list
+ */
+public class UpAction extends SourceContainerAction {
+
+ public UpAction() {
+ super(SourceLookupUIMessages.getString( "UpAction.0" )); //$NON-NLS-1$
+ }
+ /**
+ * Moves all selected entries up one position (if possible).
+ *
+ * @see IAction#run()
+ */
+ public void run() {
+ List targets = getOrderedSelection();
+ if (targets.isEmpty()) {
+ return;
+ }
+ int top = 0;
+ int index = 0;
+ List list = getEntriesAsList();
+ Iterator entries = targets.iterator();
+ while (entries.hasNext()) {
+ Object target = entries.next();
+ index = list.indexOf(target);
+ if (index > top) {
+ top = index - 1;
+ Object temp = list.get(top);
+ list.set(top, target);
+ list.set(index, temp);
+ }
+ top = index;
+ }
+ setEntries(list);
+ }
+
+ /**
+ * @see SelectionListenerAction#updateSelection(IStructuredSelection)
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ //check that something is selected, it's not first in the list, and it is a root tree node.
+ return !selection.isEmpty() && !isIndexSelected(selection, 0) && getViewer().getTree().getSelection()[0].getParentItem()==null;
+ }
+
+}

Back to the top