mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Added a preference page for the source lookup.
It includes two new preferences: 'Source Locations' and 'Search For Duplicate Source Files'.
This commit is contained in:
parent
28ca11c7da
commit
a73f8d56fd
7 changed files with 261 additions and 1 deletions
|
@ -1,3 +1,13 @@
|
|||
2003-10-23 Mikhail Khodjaiants
|
||||
Added a preference page for the source lookup.
|
||||
It includes two new preferences: 'Source Locations' and 'Search For Duplicate Source Files'.
|
||||
* plugin.properties
|
||||
* plugin.xml
|
||||
* ICDebugHelpContextIds.java
|
||||
* SourcePreferencePage.java
|
||||
* SourceListDialogField.java
|
||||
* SourceLookupBlock.java
|
||||
|
||||
2003-10-22 Mikhail Khodjaiants
|
||||
Refactoring: converting nested types 'SourceListDialogField' and 'SourceLookupLabelProvider'
|
||||
of 'SourceLookupBlock' to the top level types.
|
||||
|
|
|
@ -16,6 +16,7 @@ MemoryPreferencePage.name=Memory View
|
|||
RegistersPreferencePage.name=Registers View
|
||||
CDebugPreferencePage.name=Debug
|
||||
SharedLibrariesPreferencePage.name=Shared Libraries View
|
||||
SourcePreferencePage.name=Source
|
||||
|
||||
RunMenu.label=&Run
|
||||
DebugActionSet.label=C/C++ Debug
|
||||
|
|
|
@ -130,6 +130,12 @@
|
|||
class="org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage"
|
||||
id="org.eclipse.cdt.debug.ui.CDebugPreferencePage">
|
||||
</page>
|
||||
<page
|
||||
name="%SourcePreferencePage.name"
|
||||
category="org.eclipse.cdt.debug.ui.CDebugPreferencePage"
|
||||
class="org.eclipse.cdt.debug.internal.ui.preferences.SourcePreferencePage"
|
||||
id="org.eclipse.cdt.debug.ui.SourcePreferencePage">
|
||||
</page>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.actionSets">
|
||||
|
|
|
@ -43,6 +43,7 @@ public interface ICDebugHelpContextIds
|
|||
public static final String SIGNALS_VIEW = PREFIX + "signals_view_context"; //$NON-NLS-1$
|
||||
|
||||
// Preference pages
|
||||
public static final String SOURCE_PREFERENCE_PAGE = PREFIX + "source_preference_page_context"; //$NON-NLS-1$
|
||||
public static final String SHARED_LIBRARIES_PREFERENCE_PAGE = PREFIX + "shared_libraries_preference_page_context"; //$NON-NLS-1$
|
||||
public static final String MEMORY_PREFERENCE_PAGE = PREFIX + "memory_preference_page_context"; //$NON-NLS-1$
|
||||
public static final String REGISTERS_PREFERENCE_PAGE = PREFIX + "registers_preference_page_context"; //$NON-NLS-1$
|
||||
|
|
|
@ -0,0 +1,233 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.preferences;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
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.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.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
|
||||
/**
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since Oct 22, 2003
|
||||
*/
|
||||
public class SourcePreferencePage extends PreferencePage implements IWorkbenchPreferencePage, Observer
|
||||
{
|
||||
private SourceListDialogField fSourceListField;
|
||||
private SelectionButtonDialogField fSearchForDuplicateFiles;
|
||||
|
||||
private boolean fChanged = false;
|
||||
|
||||
public SourcePreferencePage()
|
||||
{
|
||||
super();
|
||||
setPreferenceStore( CDebugUIPlugin.getDefault().getPreferenceStore() );
|
||||
setDescription( "Common source lookup settings." );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected Control createContents( Composite parent )
|
||||
{
|
||||
WorkbenchHelp.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;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
|
||||
*/
|
||||
public void init( IWorkbench 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( "Source Locations",
|
||||
new IListAdapter()
|
||||
{
|
||||
public void customButtonPressed( DialogField field, int index )
|
||||
{
|
||||
sourceButtonPressed( index );
|
||||
}
|
||||
|
||||
public void selectionChanged(DialogField field)
|
||||
{
|
||||
}
|
||||
} );
|
||||
field.addObserver( this );
|
||||
return field;
|
||||
}
|
||||
|
||||
private SelectionButtonDialogField createSearchForDuplicateFilesButton()
|
||||
{
|
||||
SelectionButtonDialogField button = new SelectionButtonDialogField( SWT.CHECK );
|
||||
button.setLabelText( "Search for duplicate source files" );
|
||||
button.setDialogFieldListener(
|
||||
new IDialogFieldListener()
|
||||
{
|
||||
public void dialogFieldChanged( DialogField field )
|
||||
{
|
||||
setChanged( true );
|
||||
}
|
||||
} );
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isChanged()
|
||||
{
|
||||
return fChanged;
|
||||
}
|
||||
|
||||
protected void setChanged( boolean changed )
|
||||
{
|
||||
fChanged = changed;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICSourceLocation[] getSourceLocations()
|
||||
{
|
||||
return ( fSourceListField != null ) ? fSourceListField.getSourceLocations() : new ICSourceLocation[0];
|
||||
}
|
||||
|
||||
public void setSourceLocations( ICSourceLocation[] locations )
|
||||
{
|
||||
if ( fSourceListField != null )
|
||||
fSourceListField.setElements( Arrays.asList( locations ) );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
|
||||
*/
|
||||
protected void performDefaults()
|
||||
{
|
||||
setSourceLocations( new ICSourceLocation[0] );
|
||||
setSearchForDuplicateFiles( false );
|
||||
super.performDefaults();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
|
||||
*/
|
||||
public boolean performOk()
|
||||
{
|
||||
storeValues();
|
||||
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() );
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ 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;
|
||||
|
@ -203,4 +204,10 @@ public class SourceListDialogField extends ListDialogField
|
|||
{
|
||||
fObservable.setChanged();
|
||||
}
|
||||
|
||||
public ICSourceLocation[] getSourceLocations()
|
||||
{
|
||||
List list = getElements();
|
||||
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
|
||||
}
|
||||
}
|
|
@ -11,7 +11,9 @@ 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.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;
|
||||
|
@ -276,7 +278,7 @@ public class SourceLookupBlock implements Observer
|
|||
locations = CSourceLocator.getDefaultSourceLocations( getProject() );
|
||||
resetGeneratedLocations( locations );
|
||||
resetAdditionalLocations( locations );
|
||||
fSearchForDuplicateFiles.setSelection( false );
|
||||
fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) );
|
||||
}
|
||||
|
||||
public IProject getProject()
|
||||
|
|
Loading…
Add table
Reference in a new issue