mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 15:35:24 +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
|
@ -147,14 +147,17 @@ 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) {
|
||||||
|
@ -163,7 +166,6 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method getCLaunchConfigType.
|
* Method getCLaunchConfigType.
|
||||||
* @return ILaunchConfigurationType
|
* @return ILaunchConfigurationType
|
||||||
|
@ -274,15 +276,11 @@ 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 =
|
|
||||||
new IRunnableWithProgress() {
|
|
||||||
public void run(IProgressMonitor pm)
|
|
||||||
throws InterruptedException {
|
|
||||||
int nElements = elements.length;
|
int nElements = elements.length;
|
||||||
pm.beginTask("Looking for executables", nElements); //$NON-NLS-1$
|
pm.beginTask("Looking for executables", nElements); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
|
@ -291,6 +289,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
if (elements[i] instanceof IAdaptable) {
|
if (elements[i] instanceof IAdaptable) {
|
||||||
IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
|
IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
|
||||||
ICProject cproject = CoreModel.getDefault().create(r.getProject());
|
ICProject cproject = CoreModel.getDefault().create(r.getProject());
|
||||||
|
if (cproject != null) {
|
||||||
IBinary[] bins = cproject.getBinaryContainer().getBinaries();
|
IBinary[] bins = cproject.getBinaryContainer().getBinaries();
|
||||||
|
|
||||||
for (int j = 0; j < bins.length; j++) {
|
for (int j = 0; j < bins.length; j++) {
|
||||||
|
@ -299,6 +298,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (pm.isCanceled()) {
|
if (pm.isCanceled()) {
|
||||||
throw new InterruptedException();
|
throw new InterruptedException();
|
||||||
}
|
}
|
||||||
|
@ -310,21 +310,22 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
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