1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 01:05:38 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2010-12-09 02:51:22 +00:00
parent 82e06db2d9
commit 0c65369079
2 changed files with 157 additions and 159 deletions

View file

@ -51,7 +51,6 @@ import org.osgi.framework.BundleContext;
* The plugin class for C/C++ debug core. * The plugin class for C/C++ debug core.
*/ */
public class CDebugCorePlugin extends Plugin { public class CDebugCorePlugin extends Plugin {
/** /**
* The plug-in identifier (value <code>"org.eclipse.cdt.debug.core"</code>). * The plug-in identifier (value <code>"org.eclipse.cdt.debug.core"</code>).
*/ */
@ -140,18 +139,18 @@ public class CDebugCorePlugin extends Plugin {
* *
* @param t throwable to log * @param t throwable to log
*/ */
public static void log( Throwable t ) { public static void log(Throwable t) {
Throwable top = t; Throwable top = t;
if ( t instanceof DebugException ) { if (t instanceof DebugException) {
DebugException de = (DebugException)t; DebugException de = (DebugException)t;
IStatus status = de.getStatus(); IStatus status = de.getStatus();
if ( status.getException() != null ) { if (status.getException() != null) {
top = status.getException(); top = status.getException();
} }
} }
// this message is intentionally not internationalized, as an exception may // this message is intentionally not internationalized, as an exception may
// be due to the resource bundle itself // be due to the resource bundle itself
log( new Status( IStatus.ERROR, getUniqueIdentifier(), INTERNAL_ERROR, "Internal error logged from CDI Debug: ", top ) ); //$NON-NLS-1$ log(new Status(IStatus.ERROR, getUniqueIdentifier(), INTERNAL_ERROR, "Internal error logged from CDI Debug: ", top)); //$NON-NLS-1$
} }
/** /**
@ -159,8 +158,8 @@ public class CDebugCorePlugin extends Plugin {
* *
* @param status status to log * @param status status to log
*/ */
public static void log( IStatus status ) { public static void log(IStatus status) {
getDefault().getLog().log( status ); getDefault().getLog().log(status);
} }
/** /**
@ -168,81 +167,80 @@ public class CDebugCorePlugin extends Plugin {
* *
* @param status status to log * @param status status to log
*/ */
public static void log( String message ) { public static void log(String message) {
getDefault().getLog().log( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), INTERNAL_ERROR, message, null ) ); getDefault().getLog().log(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), INTERNAL_ERROR, message, null));
} }
private void initializeDebugConfiguration() { private void initializeDebugConfiguration() {
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( getUniqueIdentifier(), CDEBUGGER_EXTENSION_POINT_ID ); IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(getUniqueIdentifier(), CDEBUGGER_EXTENSION_POINT_ID);
IConfigurationElement[] infos = extensionPoint.getConfigurationElements(); IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
fDebugConfigurations = new HashMap<String, DebugConfiguration>( infos.length ); fDebugConfigurations = new HashMap<String, DebugConfiguration>(infos.length);
for( int i = 0; i < infos.length; i++ ) { for(int i = 0; i < infos.length; i++) {
IConfigurationElement configurationElement = infos[i]; IConfigurationElement configurationElement = infos[i];
if (configurationElement.getName().equals(DEBUGGER_ELEMENT)) { if (configurationElement.getName().equals(DEBUGGER_ELEMENT)) {
DebugConfiguration configType = new DebugConfiguration( configurationElement ); DebugConfiguration configType = new DebugConfiguration(configurationElement);
fDebugConfigurations.put( configType.getID(), configType ); fDebugConfigurations.put(configType.getID(), configType);
} }
} }
} }
private void initializeActiveDebugConfigurations() { private void initializeActiveDebugConfigurations() {
fActiveDebugConfigurations = new HashSet<String>( getDebugConfigurations().length ); fActiveDebugConfigurations = new HashSet<String>(getDebugConfigurations().length);
fActiveDebugConfigurations.addAll( fDebugConfigurations.keySet() ); fActiveDebugConfigurations.addAll(fDebugConfigurations.keySet());
String[] filteredTypes = CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_FILTERED_DEBUGGERS ).split( "\\," ); //$NON-NLS-1$ String[] filteredTypes = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_FILTERED_DEBUGGERS).split("\\,"); //$NON-NLS-1$
fActiveDebugConfigurations.removeAll( Arrays.asList( filteredTypes ) ); fActiveDebugConfigurations.removeAll(Arrays.asList(filteredTypes));
} }
public ICDebugConfiguration[] getDebugConfigurations() { public ICDebugConfiguration[] getDebugConfigurations() {
if ( fDebugConfigurations == null ) { if (fDebugConfigurations == null) {
initializeDebugConfiguration(); initializeDebugConfiguration();
} }
return fDebugConfigurations.values().toArray( new ICDebugConfiguration[fDebugConfigurations.size()] ); return fDebugConfigurations.values().toArray(new ICDebugConfiguration[fDebugConfigurations.size()]);
} }
public ICDebugConfiguration[] getActiveDebugConfigurations() { public ICDebugConfiguration[] getActiveDebugConfigurations() {
if ( fDebugConfigurations == null ) { if (fDebugConfigurations == null) {
initializeDebugConfiguration(); initializeDebugConfiguration();
} }
if ( fActiveDebugConfigurations == null ) { if (fActiveDebugConfigurations == null) {
initializeActiveDebugConfigurations(); initializeActiveDebugConfigurations();
} }
ArrayList<DebugConfiguration> list = new ArrayList<DebugConfiguration>( fActiveDebugConfigurations.size() ); ArrayList<DebugConfiguration> list = new ArrayList<DebugConfiguration>(fActiveDebugConfigurations.size());
for ( String id : fActiveDebugConfigurations ) { for (String id : fActiveDebugConfigurations) {
DebugConfiguration dc = fDebugConfigurations.get( id ); DebugConfiguration dc = fDebugConfigurations.get(id);
if ( dc != null ) if (dc != null)
list.add( dc ); list.add(dc);
} }
return list.toArray( new ICDebugConfiguration[list.size()] ); return list.toArray(new ICDebugConfiguration[list.size()]);
} }
public ICDebugConfiguration[] getDefaultActiveDebugConfigurations() { public ICDebugConfiguration[] getDefaultActiveDebugConfigurations() {
List<String> filtered = Arrays.asList( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString( ICDebugConstants.PREF_FILTERED_DEBUGGERS ).split( "\\," ) ); //$NON-NLS-1$ List<String> filtered = Arrays.asList(CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString(ICDebugConstants.PREF_FILTERED_DEBUGGERS).split("\\,")); //$NON-NLS-1$
HashMap<String, DebugConfiguration> all = new HashMap<String, DebugConfiguration>( fDebugConfigurations ); HashMap<String, DebugConfiguration> all = new HashMap<String, DebugConfiguration>(fDebugConfigurations);
all.keySet().removeAll( filtered ); all.keySet().removeAll(filtered);
return all.values().toArray( new ICDebugConfiguration[all.size()] ); return all.values().toArray(new ICDebugConfiguration[all.size()]);
} }
public void saveFilteredDebugConfigurations( ICDebugConfiguration[] configurations ) { public void saveFilteredDebugConfigurations(ICDebugConfiguration[] configurations) {
disposeActiveDebugConfigurations(); disposeActiveDebugConfigurations();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for ( int i = 0; i < configurations.length; ++i ) { for (int i = 0; i < configurations.length; ++i) {
sb.append( configurations[i].getID() ).append( ',' ); sb.append(configurations[i].getID()).append(',');
} }
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_FILTERED_DEBUGGERS, sb.toString() ); CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_FILTERED_DEBUGGERS, sb.toString());
CDebugCorePlugin.getDefault().savePluginPreferences(); CDebugCorePlugin.getDefault().savePluginPreferences();
} }
public void saveDefaultDebugConfiguration( String id ) { public void saveDefaultDebugConfiguration(String id) {
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_DEBUGGER_TYPE, ( id != null ) ? id : "" ); //$NON-NLS-1$ CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_DEFAULT_DEBUGGER_TYPE, (id != null) ? id : ""); //$NON-NLS-1$
} }
public ICDebugConfiguration getDefaultDebugConfiguration() { public ICDebugConfiguration getDefaultDebugConfiguration() {
ICDebugConfiguration result = null; ICDebugConfiguration result = null;
try { try {
result = getDebugConfiguration( CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_DEFAULT_DEBUGGER_TYPE ) ); result = getDebugConfiguration(CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_DEFAULT_DEBUGGER_TYPE));
} } catch (CoreException e) {
catch( CoreException e ) {
} }
return result; return result;
} }
@ -250,27 +248,26 @@ public class CDebugCorePlugin extends Plugin {
public ICDebugConfiguration getDefaultDefaultDebugConfiguration() { public ICDebugConfiguration getDefaultDefaultDebugConfiguration() {
ICDebugConfiguration result = null; ICDebugConfiguration result = null;
try { try {
result = getDebugConfiguration( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString( ICDebugConstants.PREF_DEFAULT_DEBUGGER_TYPE ) ); result = getDebugConfiguration(CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString(ICDebugConstants.PREF_DEFAULT_DEBUGGER_TYPE));
} catch (CoreException e) {
} }
catch( CoreException e ) { if (result == null) {
}
if ( result == null ) {
} }
return result; return result;
} }
public boolean isDefaultDebugConfiguration( String id ) { public boolean isDefaultDebugConfiguration(String id) {
return id.compareTo( CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_DEFAULT_DEBUGGER_TYPE ) ) == 0; return id.compareTo(CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_DEFAULT_DEBUGGER_TYPE)) == 0;
} }
public ICDebugConfiguration getDebugConfiguration( String id ) throws CoreException { public ICDebugConfiguration getDebugConfiguration(String id) throws CoreException {
if ( fDebugConfigurations == null ) { if (fDebugConfigurations == null) {
initializeDebugConfiguration(); initializeDebugConfiguration();
} }
ICDebugConfiguration dbgCfg = fDebugConfigurations.get( id ); ICDebugConfiguration dbgCfg = fDebugConfigurations.get(id);
if ( dbgCfg == null ) { if (dbgCfg == null) {
IStatus status = new Status( IStatus.ERROR, getUniqueIdentifier(), 100, DebugCoreMessages.getString( "CDebugCorePlugin.0" ), null ); //$NON-NLS-1$ IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), 100, DebugCoreMessages.getString("CDebugCorePlugin.0"), null); //$NON-NLS-1$
throw new CoreException( status ); throw new CoreException(status);
} }
return dbgCfg; return dbgCfg;
} }
@ -279,18 +276,18 @@ public class CDebugCorePlugin extends Plugin {
return fSessionManager; return fSessionManager;
} }
protected void setSessionManager( SessionManager sm ) { protected void setSessionManager(SessionManager sm) {
if ( fSessionManager != null ) if (fSessionManager != null)
fSessionManager.dispose(); fSessionManager.dispose();
fSessionManager = sm; fSessionManager = sm;
} }
public void saveCommonSourceLocations( ICSourceLocation[] locations ) { public void saveCommonSourceLocations(ICSourceLocation[] locations) {
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_SOURCE_LOCATIONS, SourceUtils.getCommonSourceLocationsMemento( locations ) ); CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_SOURCE_LOCATIONS, SourceUtils.getCommonSourceLocationsMemento(locations));
} }
public ICSourceLocation[] getCommonSourceLocations() { public ICSourceLocation[] getCommonSourceLocations() {
return SourceUtils.getCommonSourceLocationsFromMemento( CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_SOURCE_LOCATIONS ) ); return SourceUtils.getCommonSourceLocationsFromMemento(CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_SOURCE_LOCATIONS));
} }
/** /**
@ -298,8 +295,8 @@ public class CDebugCorePlugin extends Plugin {
* *
* @param listener breakpoint listener * @param listener breakpoint listener
*/ */
public void addCBreakpointListener( ICBreakpointListener listener ) { public void addCBreakpointListener(ICBreakpointListener listener) {
fBreakpointListeners.add( listener ); fBreakpointListeners.add(listener);
} }
/** /**
@ -307,8 +304,8 @@ public class CDebugCorePlugin extends Plugin {
* *
* @param listener breakpoint listener * @param listener breakpoint listener
*/ */
public void removeCBreakpointListener( ICBreakpointListener listener ) { public void removeCBreakpointListener(ICBreakpointListener listener) {
fBreakpointListeners.remove( listener ); fBreakpointListeners.remove(listener);
} }
/** /**
@ -323,7 +320,7 @@ public class CDebugCorePlugin extends Plugin {
} }
private void createBreakpointListenersList() { private void createBreakpointListenersList() {
fBreakpointListeners = new ListenerList( 1 ); fBreakpointListeners = new ListenerList(1);
} }
private void disposeBreakpointListenersList() { private void disposeBreakpointListenersList() {
@ -335,13 +332,13 @@ public class CDebugCorePlugin extends Plugin {
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/ */
@Override @Override
public void start( BundleContext context ) throws Exception { public void start(BundleContext context) throws Exception {
super.start( context ); super.start(context);
initializeCommonSourceLookupDirector(); initializeCommonSourceLookupDirector();
createCommandAdapterFactory(); createCommandAdapterFactory();
createBreakpointListenersList(); createBreakpointListenersList();
createDisassemblyContextService(); createDisassemblyContextService();
setSessionManager( new SessionManager() ); setSessionManager(new SessionManager());
setDefaultLaunchDelegates(); setDefaultLaunchDelegates();
} }
@ -349,13 +346,13 @@ public class CDebugCorePlugin extends Plugin {
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/ */
@Override @Override
public void stop( BundleContext context ) throws Exception { public void stop(BundleContext context) throws Exception {
setSessionManager( null ); setSessionManager(null);
disposeDisassemblyContextService(); disposeDisassemblyContextService();
disposeBreakpointListenersList(); disposeBreakpointListenersList();
disposeCommonSourceLookupDirector(); disposeCommonSourceLookupDirector();
disposeDebugConfigurations(); disposeDebugConfigurations();
super.stop( context ); super.stop(context);
} }
private void createCommandAdapterFactory() { private void createCommandAdapterFactory() {
@ -365,31 +362,29 @@ public class CDebugCorePlugin extends Plugin {
} }
private void initializeCommonSourceLookupDirector() { private void initializeCommonSourceLookupDirector() {
if ( fCommonSourceLookupDirector == null ) { if (fCommonSourceLookupDirector == null) {
fCommonSourceLookupDirector = new CommonSourceLookupDirector(); fCommonSourceLookupDirector = new CommonSourceLookupDirector();
String newMemento = CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS ); String newMemento = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS);
if ( newMemento.length() == 0 ) { if (newMemento.length() == 0) {
// Add the participant(s). This happens as part of // Add the participant(s). This happens as part of
// initializeFromMemento(), but since we're not calling it, we // initializeFromMemento(), but since we're not calling it, we
// need to do this explicitly. See 299583. // need to do this explicitly. See 299583.
fCommonSourceLookupDirector.initializeParticipants(); fCommonSourceLookupDirector.initializeParticipants();
// Convert source locations to source containers // Convert source locations to source containers
convertSourceLocations( fCommonSourceLookupDirector ); convertSourceLocations(fCommonSourceLookupDirector);
} } else {
else {
try { try {
fCommonSourceLookupDirector.initializeFromMemento( newMemento ); fCommonSourceLookupDirector.initializeFromMemento(newMemento);
} } catch (CoreException e) {
catch( CoreException e ) { log(e.getStatus());
log( e.getStatus() );
} }
} }
} }
} }
private void disposeCommonSourceLookupDirector() { private void disposeCommonSourceLookupDirector() {
if ( fCommonSourceLookupDirector != null ) if (fCommonSourceLookupDirector != null)
fCommonSourceLookupDirector.dispose(); fCommonSourceLookupDirector.dispose();
} }
@ -397,12 +392,12 @@ public class CDebugCorePlugin extends Plugin {
return fCommonSourceLookupDirector; return fCommonSourceLookupDirector;
} }
private void convertSourceLocations( CommonSourceLookupDirector director ) { private void convertSourceLocations(CommonSourceLookupDirector director) {
director.setSourceContainers( SourceUtils.convertSourceLocations( getCommonSourceLocations() ) ); director.setSourceContainers(SourceUtils.convertSourceLocations(getCommonSourceLocations()));
} }
private void disposeActiveDebugConfigurations() { private void disposeActiveDebugConfigurations() {
if ( fActiveDebugConfigurations != null ) { if (fActiveDebugConfigurations != null) {
fActiveDebugConfigurations.clear(); fActiveDebugConfigurations.clear();
fActiveDebugConfigurations = null; fActiveDebugConfigurations = null;
} }
@ -410,7 +405,7 @@ public class CDebugCorePlugin extends Plugin {
private void disposeDebugConfigurations() { private void disposeDebugConfigurations() {
disposeActiveDebugConfigurations(); disposeActiveDebugConfigurations();
if ( fDebugConfigurations != null ) { if (fDebugConfigurations != null) {
fDebugConfigurations.clear(); fDebugConfigurations.clear();
fDebugConfigurations = null; fDebugConfigurations = null;
} }
@ -431,7 +426,7 @@ public class CDebugCorePlugin extends Plugin {
} }
private void disposeDisassemblyContextService() { private void disposeDisassemblyContextService() {
if ( fDisassemblyContextService != null ) if (fDisassemblyContextService != null)
fDisassemblyContextService.dispose(); fDisassemblyContextService.dispose();
} }
@ -453,7 +448,8 @@ public class CDebugCorePlugin extends Plugin {
} }
} }
} }
} catch (CoreException e) {} } catch (CoreException e) {
}
ILaunchConfigurationType remoteCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_REMOTE_APP); ILaunchConfigurationType remoteCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_REMOTE_APP);
try { try {
@ -466,7 +462,8 @@ public class CDebugCorePlugin extends Plugin {
} }
} }
} }
} catch (CoreException e) {} } catch (CoreException e) {
}
ILaunchConfigurationType attachCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH); ILaunchConfigurationType attachCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH);
try { try {
@ -479,7 +476,8 @@ public class CDebugCorePlugin extends Plugin {
} }
} }
} }
} catch (CoreException e) {} } catch (CoreException e) {
}
ILaunchConfigurationType postMortemCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM); ILaunchConfigurationType postMortemCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM);
try { try {
@ -492,7 +490,8 @@ public class CDebugCorePlugin extends Plugin {
} }
} }
} }
} catch (CoreException e) {} } catch (CoreException e) {
}
HashSet<String> runSet = new HashSet<String>(); HashSet<String> runSet = new HashSet<String>();
runSet.add(ILaunchManager.RUN_MODE); runSet.add(ILaunchManager.RUN_MODE);
@ -507,7 +506,7 @@ public class CDebugCorePlugin extends Plugin {
} }
} }
} }
} catch (CoreException e) {} } catch (CoreException e) {
}
} }
} }

View file

@ -44,7 +44,6 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
* The "Common Source Lookup Path" preference page. * The "Common Source Lookup Path" preference page.
*/ */
public class SourcePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { public class SourcePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
private SourceContainerViewer fPathViewer; private SourceContainerViewer fPathViewer;
private List<SourceContainerAction> fActions = new ArrayList<SourceContainerAction>(6); private List<SourceContainerAction> fActions = new ArrayList<SourceContainerAction>(6);
private IWorkbench fWorkbench; private IWorkbench fWorkbench;
@ -54,60 +53,60 @@ public class SourcePreferencePage extends PreferencePage implements IWorkbenchPr
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/ */
protected Control createContents( Composite parent ) { protected Control createContents(Composite parent) {
Font font = parent.getFont(); Font font = parent.getFont();
Composite comp = new Composite( parent, SWT.NONE ); Composite comp = new Composite(parent, SWT.NONE);
GridLayout topLayout = new GridLayout(); GridLayout topLayout = new GridLayout();
topLayout.numColumns = 2; topLayout.numColumns = 2;
comp.setLayout( topLayout ); comp.setLayout(topLayout);
GridData gd = new GridData( GridData.FILL_BOTH ); GridData gd = new GridData(GridData.FILL_BOTH);
comp.setLayoutData( gd ); comp.setLayoutData(gd);
Label viewerLabel = new Label( comp, SWT.LEFT ); Label viewerLabel = new Label(comp, SWT.LEFT);
viewerLabel.setText( PreferenceMessages.getString( "SourcePreferencePage.0" ) ); //$NON-NLS-1$ viewerLabel.setText(PreferenceMessages.getString("SourcePreferencePage.0")); //$NON-NLS-1$
gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL ); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
viewerLabel.setLayoutData( gd ); viewerLabel.setLayoutData(gd);
viewerLabel.setFont( font ); viewerLabel.setFont(font);
fPathViewer = new SourceContainerViewer( comp ); fPathViewer = new SourceContainerViewer(comp);
gd = new GridData( GridData.FILL_BOTH ); gd = new GridData(GridData.FILL_BOTH);
fPathViewer.getControl().setLayoutData( gd ); fPathViewer.getControl().setLayoutData(gd);
fPathViewer.getControl().setFont( font ); fPathViewer.getControl().setFont(font);
Composite pathButtonComp = new Composite( comp, SWT.NONE ); Composite pathButtonComp = new Composite(comp, SWT.NONE);
GridLayout pathButtonLayout = new GridLayout(); GridLayout pathButtonLayout = new GridLayout();
pathButtonLayout.marginHeight = 0; pathButtonLayout.marginHeight = 0;
pathButtonLayout.marginWidth = 0; pathButtonLayout.marginWidth = 0;
pathButtonComp.setLayout( pathButtonLayout ); pathButtonComp.setLayout(pathButtonLayout);
gd = new GridData( GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL ); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
pathButtonComp.setLayoutData( gd ); pathButtonComp.setLayoutData(gd);
pathButtonComp.setFont( font ); pathButtonComp.setFont(font);
createVerticalSpacer( comp, 2 ); createVerticalSpacer(comp, 2);
GC gc = new GC( parent ); GC gc = new GC(parent);
gc.setFont( parent.getFont() ); gc.setFont(parent.getFont());
FontMetrics fontMetrics = gc.getFontMetrics(); FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose(); gc.dispose();
fAddAction = new AddContainerAction(); fAddAction = new AddContainerAction();
Button button = createPushButton( pathButtonComp, fAddAction.getText(), fontMetrics ); Button button = createPushButton(pathButtonComp, fAddAction.getText(), fontMetrics);
fAddAction.setButton( button ); fAddAction.setButton(button);
addAction( fAddAction ); addAction(fAddAction);
fEditAction = new EditContainerAction(); fEditAction = new EditContainerAction();
button = createPushButton( pathButtonComp, fEditAction.getText(), fontMetrics ); button = createPushButton(pathButtonComp, fEditAction.getText(), fontMetrics);
fEditAction.setButton( button ); fEditAction.setButton(button);
addAction( fEditAction ); addAction(fEditAction);
SourceContainerAction action = new RemoveAction(); SourceContainerAction action = new RemoveAction();
button = createPushButton( pathButtonComp, action.getText(), fontMetrics ); button = createPushButton(pathButtonComp, action.getText(), fontMetrics);
action.setButton( button ); action.setButton(button);
addAction( action ); addAction(action);
action = new UpAction(); action = new UpAction();
button = createPushButton( pathButtonComp, action.getText(), fontMetrics ); button = createPushButton(pathButtonComp, action.getText(), fontMetrics);
action.setButton( button ); action.setButton(button);
addAction( action ); addAction(action);
action = new DownAction(); action = new DownAction();
button = createPushButton( pathButtonComp, action.getText(), fontMetrics ); button = createPushButton(pathButtonComp, action.getText(), fontMetrics);
action.setButton( button ); action.setButton(button);
addAction( action ); addAction(action);
retargetActions( fPathViewer ); retargetActions(fPathViewer);
Dialog.applyDialogFont( comp ); Dialog.applyDialogFont(comp);
getWorkbench().getHelpSystem().setHelp( comp, ICDebugHelpContextIds.SOURCE_PREFERENCE_PAGE ); getWorkbench().getHelpSystem().setHelp(comp, ICDebugHelpContextIds.SOURCE_PREFERENCE_PAGE);
initialize(); initialize();
return comp; return comp;
} }
@ -117,23 +116,23 @@ public class SourcePreferencePage extends PreferencePage implements IWorkbenchPr
* *
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/ */
public void init( IWorkbench workbench ) { public void init(IWorkbench workbench) {
fWorkbench = workbench; fWorkbench = workbench;
} }
private Button createPushButton( Composite parent, String label, FontMetrics fontMetrics ) { private Button createPushButton(Composite parent, String label, FontMetrics fontMetrics) {
Button button = new Button( parent, SWT.PUSH ); Button button = new Button(parent, SWT.PUSH);
button.setFont( parent.getFont() ); button.setFont(parent.getFont());
button.setText( label ); button.setText(label);
GridData gd = getButtonGridData( button, fontMetrics ); GridData gd = getButtonGridData(button, fontMetrics);
button.setLayoutData( gd ); button.setLayoutData(gd);
return button; return button;
} }
private GridData getButtonGridData( Button button, FontMetrics fontMetrics ) { private GridData getButtonGridData(Button button, FontMetrics fontMetrics) {
GridData gd = new GridData( GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING ); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
int widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH ); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
gd.widthHint = Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x ); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
return gd; return gd;
} }
@ -141,35 +140,35 @@ public class SourcePreferencePage extends PreferencePage implements IWorkbenchPr
return fWorkbench; return fWorkbench;
} }
private void addAction( SourceContainerAction action ) { private void addAction(SourceContainerAction action) {
fActions.add( action ); fActions.add(action);
} }
private void retargetActions( SourceContainerViewer viewer ) { private void retargetActions(SourceContainerViewer viewer) {
for ( SourceContainerAction action : fActions ) { for (SourceContainerAction action : fActions) {
action.setViewer( viewer ); action.setViewer(viewer);
} }
} }
private void createVerticalSpacer( Composite comp, int colSpan ) { private void createVerticalSpacer(Composite comp, int colSpan) {
Label label = new Label( comp, SWT.NONE ); Label label = new Label(comp, SWT.NONE);
GridData gd = new GridData(); GridData gd = new GridData();
gd.horizontalSpan = colSpan; gd.horizontalSpan = colSpan;
label.setLayoutData( gd ); label.setLayoutData(gd);
} }
private void initialize() { private void initialize() {
ISourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector(); ISourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
fPathViewer.setEntries( director.getSourceContainers() ); fPathViewer.setEntries(director.getSourceContainers());
fAddAction.setSourceLookupDirector( director ); fAddAction.setSourceLookupDirector(director);
fEditAction.setSourceLookupDirector( director ); fEditAction.setSourceLookupDirector(director);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#performDefaults() * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/ */
protected void performDefaults() { protected void performDefaults() {
fPathViewer.setEntries( new ISourceContainer[0] ); fPathViewer.setEntries(new ISourceContainer[0]);
super.performDefaults(); super.performDefaults();
} }
@ -177,7 +176,7 @@ public class SourcePreferencePage extends PreferencePage implements IWorkbenchPr
* @see org.eclipse.jface.preference.PreferencePage#performOk() * @see org.eclipse.jface.preference.PreferencePage#performOk()
*/ */
public boolean performOk() { public boolean performOk() {
CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().setSourceContainers( fPathViewer.getEntries() ); CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().setSourceContainers(fPathViewer.getEntries());
CDebugCorePlugin.getDefault().savePluginPreferences(); CDebugCorePlugin.getDefault().savePluginPreferences();
return true; return true;
} }