use of org.eclipse.debug.core.ILaunchConfiguration in project egit by eclipse.
the class DiscardChangesActionHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// capture selection from active part as long as we have context
mySelection = getSelection(event);
try {
IWorkbenchPart part = getPart(event);
String question = UIText.DiscardChangesAction_confirmActionMessage;
ILaunchConfiguration launch = LaunchFinder.getRunningLaunchConfiguration(Arrays.asList(getRepositories()), null);
if (launch != null) {
question = MessageFormat.format(question, "\n\n" + // $NON-NLS-1$
MessageFormat.format(UIText.LaunchFinder_RunningLaunchMessage, launch.getName()));
} else {
// $NON-NLS-1$
question = MessageFormat.format(question, "");
}
boolean performAction = openConfirmationDialog(event, question);
if (!performAction) {
return null;
}
final DiscardChangesOperation operation = createOperation(part, event);
if (operation == null) {
return null;
}
String jobname = UIText.DiscardChangesAction_discardChanges;
Job job = new WorkspaceJob(jobname) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
operation.execute(monitor);
} catch (CoreException e) {
return Activator.createErrorStatus(e.getStatus().getMessage(), e);
}
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
if (JobFamilies.DISCARD_CHANGES.equals(family)) {
return true;
}
return super.belongsTo(family);
}
};
job.setUser(true);
job.setRule(operation.getSchedulingRule());
job.schedule();
return null;
} finally {
// cleanup mySelection to avoid side effects later after execution
mySelection = null;
}
}
use of org.eclipse.debug.core.ILaunchConfiguration in project statecharts by Yakindu.
the class StatechartLaunchShortcut method launch.
protected void launch(IFile file, String mode) {
showConsole();
final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
final ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType(getConfigType());
ILaunchConfiguration launchConfig = findLaunchConfiguration(configType, file);
if (launchConfig != null) {
DebugUITools.launch(launchConfig, mode);
} else {
ILaunchConfiguration launchConfiguration = createNewLaunchConfiguration(file);
DebugUITools.launch(launchConfiguration, mode);
}
}
use of org.eclipse.debug.core.ILaunchConfiguration in project titan.EclipsePlug-ins by eclipse.
the class AstRunnerJava method run.
public void run(IAction action) {
boolean projectfound = false;
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject p : projects) {
if (p.getName().equals("org.eclipse.titan.codegenerator.output"))
projectfound = true;
}
if (projectfound) {
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = manager.getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
try {
ILaunchConfiguration[] lcs = manager.getLaunchConfigurations(type);
for (ILaunchConfiguration l : lcs) {
if (l.getName().equals("org.eclipse.titan.codegenerator.output.MC"))
l.delete();
if (l.getName().equals("org.eclipse.titan.codegenerator.output.HC"))
l.delete();
}
ILaunchConfigurationWorkingCopy mcrc = type.newInstance(null, "org.eclipse.titan.codegenerator.output.MC");
List<String> mcrespaths = new ArrayList<String>();
mcrespaths.add("/org.eclipse.titan.codegenerator.output/src/org/eclipse/titan/codegenerator/TTCN3JavaAPI/MC.java");
mcrc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_PATHS", mcrespaths);
List<String> mcrestypes = new ArrayList<String>();
mcrestypes.add("1");
mcrc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES", mcrestypes);
mcrc.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE", "org.eclipse.titan.codegenerator.TTCN3JavaAPI.MC");
mcrc.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", "org.eclipse.titan.codegenerator.output");
DebugUITools.launch(mcrc, ILaunchManager.RUN_MODE);
ILaunchConfigurationWorkingCopy hcrc = type.newInstance(null, "org.eclipse.titan.codegenerator.output.HC");
List<String> hcrespaths = new ArrayList<String>();
hcrespaths.add("/org.eclipse.titan.codegenerator.output/src/org/eclipse/titan/codegenerator/javagen/HC.java");
hcrc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_PATHS", hcrespaths);
List<String> hcrestypes = new ArrayList<String>();
hcrestypes.add("1");
hcrc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES", hcrestypes);
hcrc.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE", "org.eclipse.titan.codegenerator.javagen.HC");
hcrc.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", "org.eclipse.titan.codegenerator.output");
DebugUITools.launch(hcrc, ILaunchManager.RUN_MODE);
} catch (Exception e) {
}
}
}
use of org.eclipse.debug.core.ILaunchConfiguration in project titan.EclipsePlug-ins by eclipse.
the class LaunchShortcut method launch.
@Override
public final void launch(final ISelection selection, final String mode) {
if (!(selection instanceof IStructuredSelection)) {
return;
}
final Object[] selections = ((IStructuredSelection) selection).toArray();
if (1 != selections.length) {
return;
}
IFile cfgFile = null;
IProject project = null;
if ((selections[0] instanceof IProject)) {
// try to find the cfg file:
project = (IProject) selections[0];
List<IFile> cfgFiles = ProjectFileHandler.getCfgFiles(project);
if (cfgFiles.size() == 1) {
cfgFile = cfgFiles.get(0);
} else if (cfgFiles.size() > 1) {
final ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation();
final ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, labelProvider);
dialog.setTitle("Config File Selection");
dialog.setMessage("Select existing cfg file:");
dialog.setElements(cfgFiles.toArray(new IFile[cfgFiles.size()]));
if (dialog.open() == Window.OK) {
cfgFile = (IFile) dialog.getFirstResult();
}
} else {
ErrorReporter.logError("Config file not found");
ErrorReporter.parallelErrorDisplayInMessageDialog("An error was found while creating the default launch configuration for project " + project.getName(), "Config file not found in project " + project.getName());
return;
}
} else {
return;
}
if (project == null || cfgFile == null) {
return;
}
final ILaunchConfigurationWorkingCopy wc = getWorkingCopy(project, cfgFile, mode);
if (wc == null) {
// successful launch happened
return;
}
boolean result = initLaunchConfiguration(wc, project, cfgFile.getLocation().toOSString());
if (result) {
result = HostControllersTab.initLaunchConfiguration(wc);
}
try {
if (result) {
ILaunchConfiguration conf = wc.doSave();
conf.launch(mode, null);
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
use of org.eclipse.debug.core.ILaunchConfiguration in project titan.EclipsePlug-ins by eclipse.
the class LaunchShortcutConfig method launch.
@Override
public final void launch(final ISelection selection, final String mode) {
if (!(selection instanceof IStructuredSelection)) {
return;
}
final Object[] selections = ((IStructuredSelection) selection).toArray();
if (1 != selections.length) {
return;
}
if (!(selections[0] instanceof IFile)) {
// Is it necessary???
ErrorReporter.logError("Config file not found");
return;
}
final IFile file = (IFile) selections[0];
final IProject project = file.getProject();
if (project == null) {
ErrorReporter.logError("Project file not found");
return;
}
try {
final ILaunchConfigurationWorkingCopy wc = getWorkingCopy(project, file, mode);
if (wc == null) {
// successful launch
return;
}
boolean result = initLaunchConfiguration(wc, project, file.getLocation().toOSString());
if (result) {
result = HostControllersTab.initLaunchConfiguration(wc);
}
if (result) {
wc.setMappedResources(new IResource[] { project, file });
wc.setAttribute(EXECUTECONFIGFILEONLAUNCH, true);
final ILaunchConfiguration conf = wc.doSave();
conf.launch(mode, null);
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
Aggregations