mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
fixed lack of error msg when nothing selected
This commit is contained in:
parent
84ec3f33f6
commit
322271b44b
1 changed files with 42 additions and 41 deletions
|
@ -48,7 +48,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(IEditorPart, String)
|
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(IEditorPart, String)
|
||||||
*/
|
*/
|
||||||
public void launch(IEditorPart editor, String mode) {
|
public void launch(IEditorPart editor, String mode) {
|
||||||
searchAndLaunch(new Object[] {editor.getEditorInput()}, mode);
|
searchAndLaunch(new Object[] { editor.getEditorInput()}, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +117,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
debugList.add(debugConfigs[i]);
|
debugList.add(debugConfigs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debugConfigs = (ICDebugConfiguration[])debugList.toArray(new ICDebugConfiguration[0]);
|
debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
|
||||||
if (debugConfigs.length == 1) {
|
if (debugConfigs.length == 1) {
|
||||||
debugConfig = debugConfigs[0];
|
debugConfig = debugConfigs[0];
|
||||||
} else if (debugConfigs.length > 1) {
|
} else if (debugConfigs.length > 1) {
|
||||||
|
@ -147,31 +147,33 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
try {
|
try {
|
||||||
String projectName = bin.getResource().getProjectRelativePath().toString();
|
String projectName = bin.getResource().getProjectRelativePath().toString();
|
||||||
ILaunchConfigurationType configType = getCLaunchConfigType();
|
ILaunchConfigurationType configType = getCLaunchConfigType();
|
||||||
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName()));
|
ILaunchConfigurationWorkingCopy wc =
|
||||||
|
configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName()));
|
||||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
|
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
|
||||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
|
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
|
||||||
wc.setAttribute(IDebugUIConstants.ATTR_TARGET_DEBUG_PERSPECTIVE, IDebugUIConstants.PERSPECTIVE_DEFAULT);
|
wc.setAttribute(IDebugUIConstants.ATTR_TARGET_DEBUG_PERSPECTIVE, IDebugUIConstants.PERSPECTIVE_DEFAULT);
|
||||||
wc.setAttribute(IDebugUIConstants.ATTR_TARGET_RUN_PERSPECTIVE, IDebugUIConstants.PERSPECTIVE_DEFAULT);
|
wc.setAttribute(IDebugUIConstants.ATTR_TARGET_RUN_PERSPECTIVE, IDebugUIConstants.PERSPECTIVE_DEFAULT);
|
||||||
wc.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
|
wc.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
|
||||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
|
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
|
||||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
wc.setAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
|
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
|
||||||
config = wc.doSave();
|
config = wc.doSave();
|
||||||
} catch (CoreException ce) {
|
} catch (CoreException ce) {
|
||||||
CDebugUIPlugin.log(ce);
|
CDebugUIPlugin.log(ce);
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method getCLaunchConfigType.
|
* Method getCLaunchConfigType.
|
||||||
* @return ILaunchConfigurationType
|
* @return ILaunchConfigurationType
|
||||||
*/
|
*/
|
||||||
private ILaunchConfigurationType getCLaunchConfigType() {
|
private ILaunchConfigurationType getCLaunchConfigType() {
|
||||||
return getLaunchManager().getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP);
|
return getLaunchManager().getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ILaunchManager getLaunchManager() {
|
protected ILaunchManager getLaunchManager() {
|
||||||
return DebugPlugin.getDefault().getLaunchManager();
|
return DebugPlugin.getDefault().getLaunchManager();
|
||||||
}
|
}
|
||||||
|
@ -200,7 +202,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
return "";
|
return "";
|
||||||
} else if (element instanceof ICDebugConfiguration) {
|
} else if (element instanceof ICDebugConfiguration) {
|
||||||
return ((ICDebugConfiguration)element).getName();
|
return ((ICDebugConfiguration) element).getName();
|
||||||
}
|
}
|
||||||
return element.toString();
|
return element.toString();
|
||||||
}
|
}
|
||||||
|
@ -219,7 +221,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
if (result == dialog.OK) {
|
if (result == dialog.OK) {
|
||||||
return (ICDebugConfiguration) dialog.getFirstResult();
|
return (ICDebugConfiguration) dialog.getFirstResult();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,57 +276,56 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
*/
|
*/
|
||||||
private void searchAndLaunch(final Object[] elements, String mode) {
|
private void searchAndLaunch(final Object[] elements, String mode) {
|
||||||
final List results = new ArrayList();
|
final List results = new ArrayList();
|
||||||
if (elements != null) {
|
if (elements != null && elements.length > 0) {
|
||||||
try {
|
try {
|
||||||
ProgressMonitorDialog dialog =
|
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
|
||||||
new ProgressMonitorDialog(getShell());
|
IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
||||||
if (elements.length > 0) {
|
public void run(IProgressMonitor pm) throws InterruptedException {
|
||||||
IRunnableWithProgress runnable =
|
int nElements = elements.length;
|
||||||
new IRunnableWithProgress() {
|
pm.beginTask("Looking for executables", nElements); //$NON-NLS-1$
|
||||||
public void run(IProgressMonitor pm)
|
try {
|
||||||
throws InterruptedException {
|
IProgressMonitor sub = new SubProgressMonitor(pm, 1);
|
||||||
int nElements = elements.length;
|
for (int i = 0; i < nElements; i++) {
|
||||||
pm.beginTask("Looking for executables", nElements); //$NON-NLS-1$
|
if (elements[i] instanceof IAdaptable) {
|
||||||
try {
|
IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
|
||||||
IProgressMonitor sub = new SubProgressMonitor(pm, 1);
|
ICProject cproject = CoreModel.getDefault().create(r.getProject());
|
||||||
for (int i = 0; i < nElements; i++) {
|
if (cproject != null) {
|
||||||
if (elements[i] instanceof IAdaptable) {
|
IBinary[] bins = cproject.getBinaryContainer().getBinaries();
|
||||||
IResource r = (IResource)((IAdaptable) elements[i]).getAdapter(IResource.class);
|
|
||||||
ICProject cproject =CoreModel.getDefault().create(r.getProject());
|
|
||||||
IBinary[] bins =cproject.getBinaryContainer().getBinaries();
|
|
||||||
|
|
||||||
for (int j = 0; j < bins.length; j++) {
|
for (int j = 0; j < bins.length; j++) {
|
||||||
if (bins[j].isExecutable()) {
|
if (bins[j].isExecutable()) {
|
||||||
results.add(bins[j]);
|
results.add(bins[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pm.isCanceled()) {
|
|
||||||
throw new InterruptedException();
|
|
||||||
}
|
|
||||||
sub.done();
|
|
||||||
}
|
}
|
||||||
} finally {
|
if (pm.isCanceled()) {
|
||||||
pm.done();
|
throw new InterruptedException();
|
||||||
|
}
|
||||||
|
sub.done();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
pm.done();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
dialog.run(true, true, runnable);
|
};
|
||||||
}
|
dialog.run(true, true, runnable);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
return;
|
return;
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
MessageDialog.openError(getShell(), "C Application Launcher", e.getMessage()); //$NON-NLS-1$
|
MessageDialog.openError(getShell(), "C Application Launcher", e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (results.size() == 0) {
|
if (results.size() == 0) {
|
||||||
MessageDialog.openError(getShell(), "C Application Launcher", "Launch failed no binaries"); //$NON-NLS-1$ //$NON-NLS-2$
|
MessageDialog.openError(getShell(), "C Application Launcher", "Launch failed no binaries");
|
||||||
} else {
|
} else {
|
||||||
IBinary bin = chooseBinary(results, mode);
|
IBinary bin = chooseBinary(results, mode);
|
||||||
if (bin != null) {
|
if (bin != null) {
|
||||||
launch(bin, mode);
|
launch(bin, mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
MessageDialog.openError(getShell(), "C Application Launcher", "Launch failed no project selected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue