diff options
6 files changed, 118 insertions, 94 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java index b8a020ea6..f017d5700 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java @@ -734,51 +734,58 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig try { // bug 28245 - force the delegate to load in case it is interested in launch notifications Set<String> modes = getModes(); - modes.add(mode); - ILaunchDelegate[] delegates = getType().getDelegates(modes); - ILaunchConfigurationDelegate delegate = null; - if (delegates.length == 1) { - delegate = delegates[0].getDelegate(); - } else if (delegates.length == 0) { - IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus); - if (handler != null) { - handler.handleStatus(delegateNotAvailable, new Object[] {this, mode}); - } - IStatus status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_11, null); - throw new CoreException(status); - } else { - ILaunchDelegate del = getPreferredDelegate(modes); - if(del == null) { - del = getType().getPreferredDelegate(modes); - } - if(del == null) { - IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus); - IStatus status = null; - if (handler != null) { - status = (IStatus) handler.handleStatus(duplicateDelegates, new Object[] {this, mode}); - } - if(status != null && status.isOK()) { - del = getPreferredDelegate(modes); - if(del == null) { - del = getType().getPreferredDelegate(modes); + modes.add(mode); + ILaunchDelegate[] delegates = getType().getDelegates(modes); + ILaunchConfigurationDelegate delegate = null; + switch (delegates.length) { + case 1: + delegate = delegates[0].getDelegate(); + break; + case 0: + { + IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus); + if (handler != null) { + handler.handleStatus(delegateNotAvailable, new Object[] {this, mode}); + } + IStatus status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_11, null); + throw new CoreException(status); + } + default: + { + ILaunchDelegate del = getPreferredDelegate(modes); + if(del == null) { + del = getType().getPreferredDelegate(modes); + } + if(del == null) { + IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus); + IStatus status = null; + if (handler != null) { + status = (IStatus) handler.handleStatus(duplicateDelegates, new Object[] {this, mode}); } - if(del != null) { - delegate = del.getDelegate(); + if(status != null && status.isOK()) { + del = getPreferredDelegate(modes); + if(del == null) { + del = getType().getPreferredDelegate(modes); + } + if(del != null) { + delegate = del.getDelegate(); + } + else { + status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); + throw new CoreException(status); + } } else { status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); - throw new CoreException(status); + throw new CoreException(status); } } else { - status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); - throw new CoreException(status); + delegate = del.getDelegate(); } - } - else { - delegate = del.getDelegate(); - } - } + break; + } + } ILaunchConfigurationDelegate2 delegate2 = null; if (delegate instanceof ILaunchConfigurationDelegate2) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java index 227b2fb5a..9b136deaf 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java @@ -320,14 +320,15 @@ public class StringVariablePreferencePage extends PreferencePage implements IWor IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int overWrite= dialog.open(); - if (overWrite == 0) { + switch (overWrite) { + case 0: currentVariable.setValue(value); currentVariable.setDescription(description); variableTable.update(currentVariable, null); return true; - } else if(overWrite == 1){ + case 1: return false; - } else { + default: return true; // Cancel was pressed, return true so operation is ended } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java index ac62f4d55..4412f3ec8 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java @@ -172,13 +172,16 @@ public class ExpressionDropAdapter extends ViewerDropAdapter { @Override public boolean validateDrop(Object target, int operation, TransferData transferType) { if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) { - if (fDropType == DROP_TYPE_EXPRESSION){ + switch (fDropType) { + case DROP_TYPE_EXPRESSION: return validateExpressionDrop(target); - } else if (fDropType == DROP_TYPE_VARIABLE){ + case DROP_TYPE_VARIABLE: return validateVariableDrop(target); - } else if (fDropType == DROP_TYPE_WATCH_ADAPTABLE_ELEMENT){ - return validateWatchAdaptableDrop(target); - } + case DROP_TYPE_WATCH_ADAPTABLE_ELEMENT: + return validateWatchAdaptableDrop(target); + default: + break; + } } else if (TextTransfer.getInstance().isSupportedType(transferType)) { return validateTextDrop(target); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SignedIntegerRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SignedIntegerRendering.java index 8416dbbb9..ba0fcad7f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SignedIntegerRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SignedIntegerRendering.java @@ -42,32 +42,30 @@ public class SignedIntegerRendering extends AbstractIntegerRendering { String ret; long result = 0; - if (columnSize == 1) - { + switch (columnSize) { + case 1: result = byteArray[0]; - } - else if (columnSize == 2) - { + break; + case 2: result = RenderingsUtil.convertByteArrayToShort(byteArray, endianess); - } - else if (columnSize == 4) - { + break; + case 4: result = RenderingsUtil.convertByteArrayToInt(byteArray, endianess); - } - else if (columnSize == 8) - { + break; + case 8: result = RenderingsUtil.convertByteArrayToLong(byteArray, endianess); - } - else if (columnSize == 16) + break; + case 16: { BigInteger bigRet = RenderingsUtil.convertByteArrayToSignedBigInt(byteArray, endianess); return bigRet.toString(); } - else + default: { BigInteger bigRet = RenderingsUtil.convertByteArrayToSignedBigInt(byteArray, endianess, columnSize); return bigRet.toString(); } + } ret = Long.valueOf(result).toString(); @@ -78,28 +76,31 @@ public class SignedIntegerRendering extends AbstractIntegerRendering { { try { byte[] bytes; - if (colSize == 1) - { + switch (colSize) { + case 1: byte x = Byte.parseByte(newValue); bytes = new byte[1]; bytes[0] = x; - } - else if (colSize == 2) + break; + case 2: { short i = Short.parseShort(newValue); bytes = RenderingsUtil.convertShortToByteArray(i, endianess); + break; } - else if (colSize == 4) + case 4: { int i = Integer.parseInt(newValue); bytes = RenderingsUtil.convertIntToByteArray(i, endianess); + break; } - else if (colSize == 8) + case 8: { long i = Long.parseLong(newValue); bytes = RenderingsUtil.convertLongToByteArray(i, endianess); + break; } - else if (colSize == 16) + case 16: { // special case for colSize == 16 // need to represent number in Big Integer @@ -108,7 +109,7 @@ public class SignedIntegerRendering extends AbstractIntegerRendering { return bytes; } - else + default: { BigInteger i = new BigInteger(newValue); @@ -130,6 +131,7 @@ public class SignedIntegerRendering extends AbstractIntegerRendering { bytes = RenderingsUtil.convertSignedBigIntToByteArray(i, endianess, colSize); return bytes; } + } return bytes; } catch (NumberFormatException e) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPropertiesPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPropertiesPage.java index 3cb01fe2e..50dcc4eb5 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPropertiesPage.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPropertiesPage.java @@ -122,12 +122,17 @@ public class TableRenderingPropertiesPage extends PropertyPage implements String dataEndian = DebugUIMessages.TableRenderingPropertiesPage_12; if (endianessKnown) { - if (endianess == RenderingsUtil.BIG_ENDIAN) + switch (endianess) { + case RenderingsUtil.BIG_ENDIAN: dataEndian = DebugUIMessages.TableRenderingPropertiesPage_13; - else if (endianess == RenderingsUtil.LITTLE_ENDIAN) + break; + case RenderingsUtil.LITTLE_ENDIAN: dataEndian = DebugUIMessages.TableRenderingPropertiesPage_14; - else + break; + default: dataEndian = DebugUIMessages.TableRenderingPropertiesPage_15; + break; + } } addProperty(composite, DebugUIMessages.TableRenderingPropertiesPage_16, dataEndian); @@ -139,16 +144,19 @@ public class TableRenderingPropertiesPage extends PropertyPage implements String displayEndian = DebugUIMessages.TableRenderingPropertiesPage_17; endianess = intRendering.getDisplayEndianess(); - if (endianess == RenderingsUtil.BIG_ENDIAN) + switch (endianess) { + case RenderingsUtil.BIG_ENDIAN: displayEndian = DebugUIMessages.TableRenderingPropertiesPage_18; - else if (endianess == RenderingsUtil.LITTLE_ENDIAN) + break; + case RenderingsUtil.LITTLE_ENDIAN: displayEndian = DebugUIMessages.TableRenderingPropertiesPage_19; - else - { + break; + default: if (endianessKnown) displayEndian = dataEndian; else displayEndian = DebugUIMessages.TableRenderingPropertiesPage_20; + break; } addProperty(composite, DebugUIMessages.TableRenderingPropertiesPage_21, displayEndian); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/UnsignedIntegerRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/UnsignedIntegerRendering.java index 0888836f3..15626c562 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/UnsignedIntegerRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/UnsignedIntegerRendering.java @@ -37,34 +37,31 @@ public class UnsignedIntegerRendering extends AbstractIntegerRendering { String ret; long result = 0; - if (columnSize == 1) - { + switch (columnSize) { + case 1: result = byteArray[0]; result &= 0xff; - } - else if (columnSize == 2) - { + break; + case 2: result = RenderingsUtil.convertByteArrayToInt(byteArray, endianess); - } - else if (columnSize == 4) - { + break; + case 4: result = RenderingsUtil.convertByteArrayToLong(byteArray, endianess); - } - else if (columnSize == 8) - { + break; + case 8: BigInteger value = RenderingsUtil.convertByteArrayToUnsignedLong(byteArray, endianess); return value.toString(); - } - else if (columnSize == 16) + case 16: { BigInteger bigRet = RenderingsUtil.convertByteArrayToUnsignedBigInt(byteArray, endianess); return bigRet.toString(); } - else + default: { BigInteger bigRet = RenderingsUtil.convertByteArrayToUnsignedBigInt(byteArray, endianess, columnSize); return bigRet.toString(); } + } ret = Long.valueOf(result).toString(); @@ -75,32 +72,37 @@ public class UnsignedIntegerRendering extends AbstractIntegerRendering { { try { byte[] bytes; - if (colSize == 1) + switch (colSize) { + case 1: { short i = Short.parseShort(newValue); bytes = RenderingsUtil.convertShortToByteArray(i, endianess); bytes = extractBytes(bytes, endianess, colSize); + break; } // unsigned integer - else if (colSize == 2) + case 2: { int i = Integer.parseInt(newValue); bytes = RenderingsUtil.convertIntToByteArray(i, endianess); bytes = extractBytes(bytes, endianess, colSize); + break; } - else if (colSize == 4) + case 4: { long i = Long.parseLong(newValue); bytes = RenderingsUtil.convertLongToByteArray(i, endianess); bytes = extractBytes(bytes, endianess, colSize); + break; } - else if (colSize == 8) + case 8: { BigInteger i = new BigInteger(newValue); bytes = RenderingsUtil.convertBigIntegerToByteArray(i, endianess); bytes = extractBytes(bytes, endianess, colSize); + break; } - else if (colSize == 16) + case 16: { BigInteger i = new BigInteger(newValue); bytes = RenderingsUtil.convertUnsignedBigIntegerToByteArray(i, endianess); @@ -108,13 +110,14 @@ public class UnsignedIntegerRendering extends AbstractIntegerRendering { return bytes; } - else + default: { BigInteger i = new BigInteger(newValue); bytes = RenderingsUtil.convertUnsignedBigIntToByteArray(i, endianess, colSize); bytes = extractBytes(bytes, endianess, colSize); return bytes; } + } return bytes; } catch (NumberFormatException e) { |