diff options
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui/src/org')
16 files changed, 268 insertions, 273 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 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; } |