From eeb3c6825a189e28bb6c10ad2f65468839b8cd58 Mon Sep 17 00:00:00 2001 From: John Cortell Date: Mon, 28 Mar 2011 23:11:24 +0000 Subject: Bug 341175 - Address FindBugs issues in debug.core and debug.ui --- .../breakpointactions/BreakpointActionManager.java | 2 +- .../debug/internal/core/CBreakpointManager.java | 6 +- .../internal/core/CGlobalVariableManager.java | 2 +- .../debug/internal/core/model/CDebugElement.java | 2 +- .../debug/internal/core/model/CDebugTarget.java | 6 +- .../cdt/debug/internal/core/model/CModule.java | 18 +- .../cdt/debug/internal/core/model/CType.java | 2 +- .../cdt/debug/internal/core/model/CValue.java | 11 +- .../core/model/DisassemblyInstruction.java | 2 - .../core/sourcelookup/CSourceLookupDirector.java | 2 +- .../debug/internal/ui/CDebugModelPresentation.java | 2 +- .../internal/ui/actions/AddWatchpointDialog.java | 2 +- .../SelectionButtonDialogFieldGroup.java | 2 +- .../commands/DisassemblyDisplayModeHandler.java | 6 +- .../internal/ui/pinclone/ViewIDCounterManager.java | 2 +- .../ui/preferences/CDebugPreferencePage.java | 3 - .../ui/propertypages/ModuleProperties.java | 4 +- .../internal/ui/views/executables/BaseViewer.java | 10 +- .../ui/views/memory/AddMemoryBlockDialog.java | 2 +- .../ui/breakpointactions/ExternalToolAction.java | 4 +- .../ExternalToolActionComposite.java | 10 +- .../cdt/debug/ui/breakpointactions/LogAction.java | 2 +- .../debug/ui/breakpointactions/ResumeAction.java | 8 +- .../debug/ui/breakpointactions/SoundAction.java | 4 +- .../ui/breakpointactions/SoundActionPage.java | 474 ++++++++++----------- .../AbstractImportExecutableWizard.java | 6 +- 26 files changed, 293 insertions(+), 301 deletions(-) (limited to 'debug') diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java index 43c8750a0db..50532cfe732 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java @@ -237,7 +237,7 @@ public class BreakpointActionManager { } public void saveActionData() { - String actionData = new String(""); //$NON-NLS-1$ + String actionData = ""; //$NON-NLS-1$ DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = null; diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java index 531c58b6dac..9646c7b77ab 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java @@ -455,11 +455,11 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana } public IBreakpoint getBreakpoint( ICDIBreakpoint cdiBreakpoint ) { - Object b = null; + ICBreakpoint b; synchronized ( getBreakpointMap() ) { b = getBreakpointMap().getCBreakpoint( cdiBreakpoint ); } - return ( b instanceof IBreakpoint ) ? (IBreakpoint)b : null; + return b; } /** @@ -781,7 +781,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana ArrayList installedCDIBplist = new ArrayList(); ArrayList installedCBplist = new ArrayList(); - ICBreakpoint[] breakpoints = new ICBreakpoint[0]; + ICBreakpoint[] breakpoints; synchronized( getBreakpointMap() ) { breakpoints = getBreakpointMap().getAllCBreakpoints(); for ( int i = 0; i < breakpoints.length; ++i ) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CGlobalVariableManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CGlobalVariableManager.java index e67320e453a..a2e56b1f6b2 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CGlobalVariableManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CGlobalVariableManager.java @@ -143,7 +143,7 @@ public class CGlobalVariableManager implements ICGlobalVariableManager { return; } - ICGlobalVariable[] globals = new ICGlobalVariable[0]; + ICGlobalVariable[] globals; synchronized( fGlobals ) { globals = fGlobals.toArray( new ICGlobalVariable[fGlobals.size()] ); fGlobals.clear(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java index 3900e7a2656..e867d0da235 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java @@ -331,7 +331,7 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle fSeverity = severity; fMessage = message; if ( fMessage != null ) - fMessage.trim(); + fMessage = fMessage.trim(); } protected void resetStatus() { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java index ffc25add58e..a759a9a5e0c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java @@ -1438,7 +1438,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv */ public IGlobalVariableDescriptor[] getGlobals() throws DebugException { ICDITarget cdiTarget = getCDITarget(); - IGlobalVariableDescriptor[] globals = new IGlobalVariableDescriptor[0]; // If the backend can give us the globals... boolean hasCDIGlobals = false; ArrayList list = new ArrayList(); @@ -1458,8 +1457,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv list.addAll(getCFileGlobals(file)); } } - globals = list.toArray(new IGlobalVariableDescriptor[list.size()]); - return globals; + return list.toArray(new IGlobalVariableDescriptor[list.size()]); } private List getCFileGlobals(IBinaryObject file) { @@ -1952,7 +1950,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv } protected void stopInMain() throws DebugException { - String mainSymbol = new String(ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT); + String mainSymbol = ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT; try { final ICDITarget cdiTarget = getCDITarget(); if (cdiTarget != null) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModule.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModule.java index 8a7aac02040..ecf94bc2f15 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModule.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModule.java @@ -47,7 +47,7 @@ public class CModule extends CDebugElement implements ICModule { private int fType = 0; - private ICElement fCElement; + private Binary fBinary; private ICDIObject fCDIObject; @@ -70,7 +70,7 @@ public class CModule extends CDebugElement implements ICModule { private CModule( int type, CDebugTarget target, IPath path ) { super( target ); fType = type; - fCElement = createBinary(path); + fBinary = createBinary(path); fCDIObject = null; fImageName = path; fSymbolsFileName = path; @@ -84,7 +84,7 @@ public class CModule extends CDebugElement implements ICModule { fType = type; if ( cdiObject instanceof ICDISharedLibrary ) { ICDISharedLibrary cdiSharedLib = (ICDISharedLibrary)cdiObject; - fCElement = createBinary(new Path(cdiSharedLib.getFileName())); + fBinary = createBinary(new Path(cdiSharedLib.getFileName())); } fCDIObject = cdiObject; fImageName = ( ( cdiObject instanceof ICDISharedLibrary ) ) ? new Path( ((ICDISharedLibrary)cdiObject).getFileName() ) : new Path( CoreModelMessages.getString( "CModule.0" ) ); //$NON-NLS-1$ @@ -203,8 +203,8 @@ public class CModule extends CDebugElement implements ICModule { if (fCDIObject instanceof ICDISharedLibrary) return ((ICDISharedLibrary)fCDIObject).areSymbolsLoaded(); - if (fCElement instanceof IBinary) - return ((IBinary)fCElement).hasDebug(); + if (fBinary != null) + return fBinary.hasDebug(); return false; } @@ -227,14 +227,14 @@ public class CModule extends CDebugElement implements ICModule { * @see org.eclipse.cdt.debug.core.model.ICModule#getPlatform() */ public String getPlatform() { - return ( fCElement instanceof IBinary ) ? ((IBinary)fCElement).getCPU() : CoreModelMessages.getString( "CModule.1" ); //$NON-NLS-1$ + return ( fBinary != null ) ? fBinary.getCPU() : CoreModelMessages.getString( "CModule.1" ); //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICModule#isLittleEndian() */ public boolean isLittleEndian() { - return ( fCElement instanceof IBinary ) ? ((IBinary)fCElement).isLittleEndian() : ((CDebugTarget)getDebugTarget()).isLittleEndian(); + return ( fBinary != null ) ? fBinary.isLittleEndian() : ((CDebugTarget)getDebugTarget()).isLittleEndian(); } /* (non-Javadoc) @@ -248,7 +248,7 @@ public class CModule extends CDebugElement implements ICModule { * @see org.eclipse.cdt.debug.core.model.ICModule#getCPU() */ public String getCPU() { - return ( fCElement instanceof IBinary ) ? ((IBinary)fCElement).getCPU() : null; + return ( fBinary != null ) ? fBinary.getCPU() : null; } /* (non-Javadoc) @@ -273,7 +273,7 @@ public class CModule extends CDebugElement implements ICModule { } protected ICElement getCElement() { - return fCElement; + return fBinary; } private void loadSymbolsFromFile(IPath path) throws DebugException { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CType.java index f9cb362f08d..8a30af3f49e 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CType.java @@ -57,7 +57,7 @@ public class CType implements ICType { ICDIType type = getCDIType(); while( type instanceof ICDIArrayType ) { ++length; - type = ( type instanceof ICDIDerivedType ) ? ((ICDIDerivedType)type).getComponentType() : null; + type = ((ICDIDerivedType)type).getComponentType(); } int[] dims = new int[length]; type = getCDIType(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java index fd944a008e1..e3bc0665af7 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java @@ -179,16 +179,17 @@ public class CValue extends AbstractCValue { ICDIValue value = getUnderlyingValue(); if ( value != null ) { vars = value.getVariables(); - // Quick fix. - // getVariables should return an empty array instead of null. - if ( vars == null ) { - vars = new ICDIVariable[0]; - } } } catch( CDIException e ) { requestFailed( e.getMessage(), e ); } + + // getVariables should return an empty array instead of null. + if ( vars == null ) { + vars = new ICDIVariable[0]; + } + return Arrays.asList( vars ); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyInstruction.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyInstruction.java index 7473d9ae706..097cacf486d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyInstruction.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyInstruction.java @@ -19,13 +19,11 @@ import org.eclipse.cdt.debug.core.model.IDisassemblyInstruction; public class DisassemblyInstruction extends CDebugElement implements IDisassemblyInstruction { - private BigInteger fBaseElement; private ICDIInstruction fCDIInstruction; private IAddress fAddress; public DisassemblyInstruction( CDebugTarget target, BigInteger baseElement, ICDIInstruction instruction ) { super( target ); - fBaseElement = baseElement; fCDIInstruction = instruction; fAddress = target.getAddressFactory().createAddress( fCDIInstruction.getAdress() ); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java index 113d1c5ab83..400593eea87 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java @@ -103,7 +103,7 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector { if (container instanceof CProjectSourceContainer && project.equals(((CProjectSourceContainer) container).getProject())) { return true; } - if (container instanceof ProjectSourceContainer && project.equals(((CProjectSourceContainer) container).getProject())) { + if (container instanceof ProjectSourceContainer && project.equals(((ProjectSourceContainer) container).getProject())) { return true; } try { 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 5355ae3e700..2e126b9cb9a 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 @@ -685,7 +685,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode reason = ' ' + MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.5" ), new String[]{ sigInfo.getName(), sigInfo.getDescription() } ); //$NON-NLS-1$ } else if ( info != null && info instanceof ICDIExitInfo ) { - reason = ' ' + MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.6" ), new Integer[] { new Integer( ((ICDIExitInfo)info).getCode() ) } ); //$NON-NLS-1$ + reason = ' ' + MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.6" ), new Integer[] { Integer.valueOf( ((ICDIExitInfo)info).getCode() ) } ); //$NON-NLS-1$ } return MessageFormat.format( label, new String[] { target.getName(), reason } ); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java index df1012b4bcf..8851f4048a7 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java @@ -59,7 +59,7 @@ public class AddWatchpointDialog extends Dialog implements ModifyListener, Selec private boolean fRangeInitialEnable; private Button fRangeEnableButton; private Text fRangeField; - private String fRange = new String(); + private String fRange = ""; //$NON-NLS-1$ private Button fChkBtnWrite; private Button fChkBtnRead; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java index c28a15424af..451899b7ef2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java @@ -64,7 +64,7 @@ public class SelectionButtonDialogFieldGroup extends DialogField { fButtonsSelected[i]= false; fButtonsEnabled[i]= true; } - if (fButtonsStyle == SWT.RADIO) { + if (buttonsStyle == SWT.RADIO) { fButtonsSelected[0]= true; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java index 18fa55ac938..dd0ca22db0a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java @@ -89,9 +89,9 @@ public class DisassemblyDisplayModeHandler extends AbstractHandler implements IE if ( s instanceof IStructuredSelection ) { Object o = ((IStructuredSelection)s).getFirstElement(); if ( o instanceof DisassemblyEditorInput ) { - IDocumentProvider dp = CDebugUIPlugin.getDefault().getDisassemblyEditorManager().getDocumentProvider(); - if ( dp instanceof DisassemblyDocumentProvider ) { - return (DisassemblyEditorPresentation)((DisassemblyDocumentProvider)dp).getDocumentPresentation( o ); + DisassemblyDocumentProvider dp = CDebugUIPlugin.getDefault().getDisassemblyEditorManager().getDocumentProvider(); + if ( dp != null ) { + return (DisassemblyEditorPresentation)dp.getDocumentPresentation( o ); } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/ViewIDCounterManager.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/ViewIDCounterManager.java index 77f191329e5..cda1a8310d6 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/ViewIDCounterManager.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/ViewIDCounterManager.java @@ -194,6 +194,6 @@ public final class ViewIDCounterManager { } } - return new Integer(0); + return Integer.valueOf(0); } } 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 621fbae580a..93953156c53 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 @@ -146,7 +146,6 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr * Set the values of the component widgets based on the values in the preference store */ private void setValues() { - IPreferenceStore store = getPreferenceStore(); fVariableFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT ) ) ); fExpressionFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) ); fRegisterFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) ); @@ -299,7 +298,6 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr * Store the preference values based on the state of the component widgets */ private void storeValues() { - IPreferenceStore store = getPreferenceStore(); CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, getFormatId( fVariableFormatCombo.getSelectionIndex() ) ); CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, getFormatId( fExpressionFormatCombo.getSelectionIndex() ) ); CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, getFormatId( fRegisterFormatCombo.getSelectionIndex() ) ); @@ -318,7 +316,6 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr } private void setDefaultValues() { - IPreferenceStore store = getPreferenceStore(); fVariableFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT ) ) ); fExpressionFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) ); fRegisterFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) ); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModuleProperties.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModuleProperties.java index 6d158fc18f0..8d628f745cd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModuleProperties.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModuleProperties.java @@ -72,10 +72,10 @@ public class ModuleProperties { */ private ModuleProperties( ICModule module ) { fProperties = new ArrayList( 10 ); - fProperties.add( new Property( TYPE, new Integer( module.getType() ) ) ); + fProperties.add( new Property( TYPE, Integer.valueOf(module.getType()) ) ); fProperties.add( new Property( CPU, module.getCPU() ) ); fProperties.add( new Property( BASE_ADDRESS, module.getBaseAddress() ) ); - fProperties.add( new Property( SIZE, new Long( module.getSize() ) ) ); + fProperties.add( new Property( SIZE, Long.valueOf( module.getSize() ) ) ); fProperties.add( new Property( SYMBOLS_LOADED, Boolean.valueOf( module.areSymbolsLoaded() ) ) ); fProperties.add( new Property( SYMBOLS_FILE, module.getSymbolsFileName() ) ); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/BaseViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/BaseViewer.java index 535a241e931..6ef1494705c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/BaseViewer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/BaseViewer.java @@ -83,14 +83,14 @@ abstract class BaseViewer extends TreeViewer { Tree tree = getTree(); // save the column order - String columnOrder = ""; //$NON-NLS-1$ + StringBuilder columnOrder = new StringBuilder(); //$NON-NLS-1$ for (int index : tree.getColumnOrder()) { - columnOrder += ","; //$NON-NLS-1$ - columnOrder += Integer.toString(index); + columnOrder.append(","); //$NON-NLS-1$ + columnOrder.append(Integer.toString(index)); } // trim the leading comma - columnOrder = columnOrder.substring(1); - preferences.setValue(getColumnOrderKey(), columnOrder); + columnOrder.deleteCharAt(0); + preferences.setValue(getColumnOrderKey(), columnOrder.toString()); // save which column was sorted and in which direction TreeColumn sortedColumn = tree.getSortColumn(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlockDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlockDialog.java index 7a36f57463d..3456f62f035 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlockDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlockDialog.java @@ -159,7 +159,7 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, GC gc = new GC(fAddressInput); FontMetrics fm = gc.getFontMetrics(); // Give enough room for a 64 bit hex address (25 is a guess at the combobox selector) - gridData.minimumWidth = gridData.minimumWidth = 18 * fm.getAverageCharWidth() + 25; + gridData.minimumWidth = 18 * fm.getAverageCharWidth() + 25; gc.dispose(); fAddressInput.setLayoutData(gridData); fAddressInput.addModifyListener(this); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java index f00c2446d0a..aa5942fec48 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java @@ -43,7 +43,7 @@ import org.xml.sax.helpers.DefaultHandler; public class ExternalToolAction extends AbstractBreakpointAction { - private String externalToolName = new String(""); //$NON-NLS-1$ + private String externalToolName = ""; //$NON-NLS-1$ public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) { IStatus errorStatus = null; @@ -96,7 +96,7 @@ public class ExternalToolAction extends AbstractBreakpointAction { } public String getMemento() { - String executeData = new String(""); //$NON-NLS-1$ + String executeData = ""; //$NON-NLS-1$ if (externalToolName != null) { DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = null; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolActionComposite.java index c04495d8c94..cbbcd6bb387 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolActionComposite.java @@ -197,7 +197,7 @@ public class ExternalToolActionComposite extends Composite { public ILaunchConfiguration[] getLaunchConfigurations() { ArrayList onlyExternalTools = new ArrayList(); ILaunchManager lcm = DebugPlugin.getDefault().getLaunchManager(); - ILaunchConfiguration[] launchConfigurations = new ILaunchConfiguration[0]; + ILaunchConfiguration[] launchConfigurations; try { launchConfigurations = lcm.getLaunchConfigurations(); for (int i = 0; i < launchConfigurations.length; i++) { @@ -205,11 +205,9 @@ public class ExternalToolActionComposite extends Composite { ILaunchConfiguration config = launchConfigurations[i]; ILaunchConfigurationType type = config.getType(); boolean priv = false; - if (config != null) { - try { - priv = config.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false); - } catch (CoreException e) { - } + try { + priv = config.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false); + } catch (CoreException e) { } if (type != null) { if (!priv && type.supportsMode(ILaunchManager.RUN_MODE) && equalCategories(type.getCategory(), "org.eclipse.ui.externaltools") //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java index 15e8516d70f..3dfa3f3fec8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java @@ -110,7 +110,7 @@ public class LogAction extends AbstractBreakpointAction { } public String getMemento() { - String logData = new String(""); //$NON-NLS-1$ + String logData = ""; //$NON-NLS-1$ DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = null; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java index 0a2dedfb45b..cfac0f8160d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java @@ -41,7 +41,7 @@ import org.xml.sax.helpers.DefaultHandler; public class ResumeAction extends AbstractBreakpointAction { - final int INCRIMENT_MSEC = 100; + final static int INCRIMENT_MSEC = 100; int pauseTime = 0; @@ -60,7 +60,7 @@ public class ResumeAction extends AbstractBreakpointAction { long currentTime = System.currentTimeMillis(); while (!monitor.isCanceled() && currentTime < endTime ){ - monitor.setTaskName(MessageFormat.format(Messages.getString("ResumeAction.SummaryResumeTime"), new Object[] { new Long((endTime - currentTime)/1000) })); //$NON-NLS-1$) + monitor.setTaskName(MessageFormat.format(Messages.getString("ResumeAction.SummaryResumeTime"), new Object[] { Long.valueOf((endTime - currentTime)/1000) })); //$NON-NLS-1$) monitor.worked(1); Thread.sleep(INCRIMENT_MSEC); currentTime = System.currentTimeMillis(); @@ -104,7 +104,7 @@ public class ResumeAction extends AbstractBreakpointAction { } public String getMemento() { - String resumeData = new String(""); //$NON-NLS-1$ + String resumeData = ""; //$NON-NLS-1$ DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = null; @@ -139,7 +139,7 @@ public class ResumeAction extends AbstractBreakpointAction { public String getSummary() { if (pauseTime == 0) return Messages.getString("ResumeAction.SummaryImmediately"); //$NON-NLS-1$ - return MessageFormat.format(Messages.getString("ResumeAction.SummaryResumeTime"), new Object[] { new Integer(pauseTime) }); //$NON-NLS-1$ + return MessageFormat.format(Messages.getString("ResumeAction.SummaryResumeTime"), new Object[] { Integer.valueOf(pauseTime) }); //$NON-NLS-1$ } public String getTypeName() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java index f0ff3f70b76..234ff3bec78 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java @@ -115,7 +115,7 @@ public class SoundAction extends AbstractBreakpointAction { public String getSummary() { if (soundFile == null) - return new String(""); //$NON-NLS-1$ + return ""; //$NON-NLS-1$ return soundFile.getAbsolutePath(); } @@ -124,7 +124,7 @@ public class SoundAction extends AbstractBreakpointAction { } public String getMemento() { - String soundData = new String(""); //$NON-NLS-1$ + String soundData = ""; //$NON-NLS-1$ if (soundFile != null) { DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = null; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java index 1a36db45c44..c8bab1b750d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java @@ -1,237 +1,237 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia 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: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Iterator; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.swt.widgets.Composite; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.helpers.DefaultHandler; - -public class SoundActionPage extends PlatformObject implements IBreakpointActionPage { - - private static final String SOUND_ACTION_RECENT = "SoundBehaviorDialog.recentSounds"; //$NON-NLS-1$ - - private static boolean isWindows() { - String os = System.getProperty("os.name"); //$NON-NLS-1$ - return (os != null && os.toLowerCase().startsWith("win")); //$NON-NLS-1$ - } - - private static boolean isMacOS() { - String os = System.getProperty("os.name"); //$NON-NLS-1$ - return (os != null && os.toLowerCase().startsWith("mac")); //$NON-NLS-1$ - } - - private SoundActionComposite editor = null; - private String mediaPath = ""; //$NON-NLS-1$ - - private ArrayList recentSounds = new ArrayList(); - - private SoundAction soundAction; - - public SoundActionPage() { - if (isWindows()) - mediaPath = "C:\\WINNT\\Media\\"; //$NON-NLS-1$ - if (isMacOS()) - mediaPath = "/System/Library/Sounds"; //$NON-NLS-1$ - - loadRecentSounds(); - } - - public void actionDialogCanceled() { - } - - public void actionDialogOK() { - saveRecentSounds(); - soundAction.setSoundFile(editor.getSoundFile()); - } - - public void addRecentSound(File soundFile) { - String soundFilePath = soundFile.getAbsolutePath(); - int removeIndex = -1; - int fileCount = 0; - for (Iterator iter = recentSounds.iterator(); iter.hasNext() && removeIndex < 0;) { - File element = (File) iter.next(); - if (element.getAbsolutePath().equals(soundFilePath)) - removeIndex = fileCount; - fileCount++; - } - if (removeIndex >= 0) - recentSounds.remove(removeIndex); - recentSounds.add(soundFile); - if (recentSounds.size() > 10) - recentSounds.remove(0); - - } - - public Composite createComposite(IBreakpointAction action, Composite composite, int style) { - this.soundAction = (SoundAction) action; - loadRecentSounds(); - if (soundAction.getSoundFile() == null && recentSounds.size() > 0) - soundAction.setSoundFile((File) recentSounds.get(0)); - editor = new SoundActionComposite(composite, style, this); - return editor; - } - - public String getMediaPath() { - return mediaPath; - } - - public ArrayList getRecentSounds() { - return recentSounds; - } - - public String getSummary() { - if (soundAction.getSoundFile() == null) - return new String(""); //$NON-NLS-1$ - return soundAction.getSoundFile().getAbsolutePath(); - } - - private void initializeRecentSounds() { - - if (isWindows()) { - String defaultSounds[] = { "chimes.wav", "chord.wav", "ding.wav", "notify.wav", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "tada.wav" }; //$NON-NLS-1$ - - for (int i = 0; i < defaultSounds.length; i++) { - File soundFile = new File(mediaPath + defaultSounds[i]); - if (soundFile.exists()) - recentSounds.add(soundFile); - } - } - if (isMacOS()) { - File macSounds = new File(mediaPath); - File[] soundFiles = macSounds.listFiles(); - - for (int i = 0; i < soundFiles.length; i++) { - String fileExtension = new Path(soundFiles[i].getAbsolutePath()).getFileExtension(); - if (fileExtension.equalsIgnoreCase("aiff") || fileExtension.equalsIgnoreCase("wav")) //$NON-NLS-1$ //$NON-NLS-2$ - recentSounds.add(soundFiles[i]); - - } - } - saveRecentSounds(); - - } - - private void loadRecentSounds() { - String recentSoundData = CDebugUIPlugin.getDefault().getPreferenceStore().getString(SOUND_ACTION_RECENT); - - if (recentSoundData == null || recentSoundData.length() == 0) { - initializeRecentSounds(); - return; - } - - recentSounds = new ArrayList(); - - Element root = null; - DocumentBuilder parser; - try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - parser.setErrorHandler(new DefaultHandler()); - root = parser.parse(new InputSource(new StringReader(recentSoundData))).getDocumentElement(); - - NodeList nodeList = root.getChildNodes(); - int entryCount = nodeList.getLength(); - - for (int i = 0; i < entryCount; i++) { - Node node = nodeList.item(i); - short type = node.getNodeType(); - if (type == Node.ELEMENT_NODE) { - Element subElement = (Element) node; - String nodeName = subElement.getNodeName(); - if (nodeName.equalsIgnoreCase("soundFileName")) { //$NON-NLS-1$ - String value = subElement.getAttribute("name"); //$NON-NLS-1$ - if (value == null) - throw new Exception(); - - File soundFile = new File(value); - if (soundFile.exists()) { - recentSounds.add(soundFile); - } - } - } - } - - } catch (Exception e) { - e.printStackTrace(); - } - - if (recentSounds.size() == 0) - initializeRecentSounds(); - } - - public void saveRecentSounds() { - String recentSoundData = new String(""); //$NON-NLS-1$ - - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; - try { - docBuilder = dfactory.newDocumentBuilder(); - Document doc = docBuilder.newDocument(); - - Element rootElement = doc.createElement("recentSounds"); //$NON-NLS-1$ - doc.appendChild(rootElement); - - for (Iterator iter = recentSounds.iterator(); iter.hasNext();) { - File soundFile = (File) iter.next(); - - Element element = doc.createElement("soundFileName"); //$NON-NLS-1$ - element.setAttribute("name", soundFile.getAbsolutePath()); //$NON-NLS-1$ - rootElement.appendChild(element); - - } - - ByteArrayOutputStream s = new ByteArrayOutputStream(); - - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ - - DOMSource source = new DOMSource(doc); - StreamResult outputTarget = new StreamResult(s); - transformer.transform(source, outputTarget); - - recentSoundData = s.toString("UTF8"); //$NON-NLS-1$ - - } catch (Exception e) { - e.printStackTrace(); - } - - CDebugUIPlugin.getDefault().getPreferenceStore().setValue(SOUND_ACTION_RECENT, recentSoundData); - } - - public SoundAction getSoundAction() { - return soundAction; - } - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia 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: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Iterator; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.swt.widgets.Composite; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.helpers.DefaultHandler; + +public class SoundActionPage extends PlatformObject implements IBreakpointActionPage { + + private static final String SOUND_ACTION_RECENT = "SoundBehaviorDialog.recentSounds"; //$NON-NLS-1$ + + private static boolean isWindows() { + String os = System.getProperty("os.name"); //$NON-NLS-1$ + return (os != null && os.toLowerCase().startsWith("win")); //$NON-NLS-1$ + } + + private static boolean isMacOS() { + String os = System.getProperty("os.name"); //$NON-NLS-1$ + return (os != null && os.toLowerCase().startsWith("mac")); //$NON-NLS-1$ + } + + private SoundActionComposite editor = null; + private String mediaPath = ""; //$NON-NLS-1$ + + private ArrayList recentSounds = new ArrayList(); + + private SoundAction soundAction; + + public SoundActionPage() { + if (isWindows()) + mediaPath = "C:\\WINNT\\Media\\"; //$NON-NLS-1$ + if (isMacOS()) + mediaPath = "/System/Library/Sounds"; //$NON-NLS-1$ + + loadRecentSounds(); + } + + public void actionDialogCanceled() { + } + + public void actionDialogOK() { + saveRecentSounds(); + soundAction.setSoundFile(editor.getSoundFile()); + } + + public void addRecentSound(File soundFile) { + String soundFilePath = soundFile.getAbsolutePath(); + int removeIndex = -1; + int fileCount = 0; + for (Iterator iter = recentSounds.iterator(); iter.hasNext() && removeIndex < 0;) { + File element = (File) iter.next(); + if (element.getAbsolutePath().equals(soundFilePath)) + removeIndex = fileCount; + fileCount++; + } + if (removeIndex >= 0) + recentSounds.remove(removeIndex); + recentSounds.add(soundFile); + if (recentSounds.size() > 10) + recentSounds.remove(0); + + } + + public Composite createComposite(IBreakpointAction action, Composite composite, int style) { + this.soundAction = (SoundAction) action; + loadRecentSounds(); + if (soundAction.getSoundFile() == null && recentSounds.size() > 0) + soundAction.setSoundFile((File) recentSounds.get(0)); + editor = new SoundActionComposite(composite, style, this); + return editor; + } + + public String getMediaPath() { + return mediaPath; + } + + public ArrayList getRecentSounds() { + return recentSounds; + } + + public String getSummary() { + if (soundAction.getSoundFile() == null) + return ""; //$NON-NLS-1$ + return soundAction.getSoundFile().getAbsolutePath(); + } + + private void initializeRecentSounds() { + + if (isWindows()) { + String defaultSounds[] = { "chimes.wav", "chord.wav", "ding.wav", "notify.wav", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "tada.wav" }; //$NON-NLS-1$ + + for (int i = 0; i < defaultSounds.length; i++) { + File soundFile = new File(mediaPath + defaultSounds[i]); + if (soundFile.exists()) + recentSounds.add(soundFile); + } + } + if (isMacOS()) { + File macSounds = new File(mediaPath); + File[] soundFiles = macSounds.listFiles(); + + for (int i = 0; i < soundFiles.length; i++) { + String fileExtension = new Path(soundFiles[i].getAbsolutePath()).getFileExtension(); + if (fileExtension.equalsIgnoreCase("aiff") || fileExtension.equalsIgnoreCase("wav")) //$NON-NLS-1$ //$NON-NLS-2$ + recentSounds.add(soundFiles[i]); + + } + } + saveRecentSounds(); + + } + + private void loadRecentSounds() { + String recentSoundData = CDebugUIPlugin.getDefault().getPreferenceStore().getString(SOUND_ACTION_RECENT); + + if (recentSoundData == null || recentSoundData.length() == 0) { + initializeRecentSounds(); + return; + } + + recentSounds = new ArrayList(); + + Element root = null; + DocumentBuilder parser; + try { + parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser.setErrorHandler(new DefaultHandler()); + root = parser.parse(new InputSource(new StringReader(recentSoundData))).getDocumentElement(); + + NodeList nodeList = root.getChildNodes(); + int entryCount = nodeList.getLength(); + + for (int i = 0; i < entryCount; i++) { + Node node = nodeList.item(i); + short type = node.getNodeType(); + if (type == Node.ELEMENT_NODE) { + Element subElement = (Element) node; + String nodeName = subElement.getNodeName(); + if (nodeName.equalsIgnoreCase("soundFileName")) { //$NON-NLS-1$ + String value = subElement.getAttribute("name"); //$NON-NLS-1$ + if (value == null) + throw new Exception(); + + File soundFile = new File(value); + if (soundFile.exists()) { + recentSounds.add(soundFile); + } + } + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + + if (recentSounds.size() == 0) + initializeRecentSounds(); + } + + public void saveRecentSounds() { + String recentSoundData = ""; //$NON-NLS-1$ + + DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = null; + try { + docBuilder = dfactory.newDocumentBuilder(); + Document doc = docBuilder.newDocument(); + + Element rootElement = doc.createElement("recentSounds"); //$NON-NLS-1$ + doc.appendChild(rootElement); + + for (Iterator iter = recentSounds.iterator(); iter.hasNext();) { + File soundFile = (File) iter.next(); + + Element element = doc.createElement("soundFileName"); //$NON-NLS-1$ + element.setAttribute("name", soundFile.getAbsolutePath()); //$NON-NLS-1$ + rootElement.appendChild(element); + + } + + ByteArrayOutputStream s = new ByteArrayOutputStream(); + + TransformerFactory factory = TransformerFactory.newInstance(); + Transformer transformer = factory.newTransformer(); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + + DOMSource source = new DOMSource(doc); + StreamResult outputTarget = new StreamResult(s); + transformer.transform(source, outputTarget); + + recentSoundData = s.toString("UTF8"); //$NON-NLS-1$ + + } catch (Exception e) { + e.printStackTrace(); + } + + CDebugUIPlugin.getDefault().getPreferenceStore().setValue(SOUND_ACTION_RECENT, recentSoundData); + } + + public SoundAction getSoundAction() { + return soundAction; + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/AbstractImportExecutableWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/AbstractImportExecutableWizard.java index 580404ece1b..9e90b285943 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/AbstractImportExecutableWizard.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/AbstractImportExecutableWizard.java @@ -124,7 +124,7 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I setConfigurationDefaults(wc, targetProject); final IStructuredSelection selection = new StructuredSelection(wc.doSave()); - final String identifier = new String("org.eclipse.debug.ui.launchGroup.debug"); //$NON-NLS-1$ + final String identifier = "org.eclipse.debug.ui.launchGroup.debug"; //$NON-NLS-1$ UIJob openLaunchConfigJob = new UIJob(Messages.AbstractImportExecutableWizard_CreateLaunchConfiguration) { @@ -251,12 +251,12 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I } public String getDefaultProjectName() { - String defaultName = new String(); + String defaultName = ""; //$NON-NLS-1$ String[] executables = getImportExecutablePage() .getSelectedExecutables(); if (executables.length > 0) { String fileName = new File(executables[0]).getName(); - defaultName = new String(Messages.ImportExecutablePageTwo_DefaultProjectPrefix + fileName); + defaultName = Messages.ImportExecutablePageTwo_DefaultProjectPrefix + fileName; } return defaultName; } -- cgit v1.2.3