use of org.eclipse.debug.core.ILaunchConfigurationType 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.ILaunchConfigurationType 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.ILaunchConfigurationType in project webtools.servertools by eclipse.
the class AntPublisher method runAnt.
private void runAnt(String buildFile, String targets, Map properties, IProgressMonitor monitor) throws CoreException {
long time = System.currentTimeMillis();
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(IAntLaunchConfigurationConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
if (type == null) {
IStatus s = new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, GenericServerCoreMessages.antLauncherMissing, null);
throw new CoreException(s);
}
// $NON-NLS-1$
ILaunchConfigurationWorkingCopy wc = type.newInstance(null, properties.get(PROP_MODULE_NAME) + " module publisher");
wc.setContainer(null);
wc.setAttribute(ATTR_LOCATION, buildFile);
// $NON-NLS-1$
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider");
wc.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, targets);
wc.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, properties);
wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true);
wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
// $NON-NLS-1$
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider");
IVMInstall vmInstall = getServerRuntime().getVMInstall();
if (// fallback to default VM if null.
vmInstall == null)
vmInstall = JavaRuntime.getDefaultVMInstall();
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, // $NON-NLS-1$
"org.eclipse.ant.internal.ui.antsupport.InternalAntRunner");
wc.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, REMOTE_ANT_PROCESS_FACTORY_ID);
setupAntLaunchConfiguration(wc);
if (!monitor.isCanceled()) {
ILaunchConfiguration launchConfig = wc.doSave();
launchConfig.launch(ILaunchManager.RUN_MODE, monitor, false, true);
// $NON-NLS-1$ //$NON-NLS-2$
Trace.trace(Trace.PERFORMANCE, "AntPublisher.runAnt():<" + (System.currentTimeMillis() - time) + "ms> module: " + getModule()[0]);
}
}
use of org.eclipse.debug.core.ILaunchConfigurationType in project webtools.servertools by eclipse.
the class GenericServerBehaviour method shutdown.
/**
* Shuts down the server via the launch configuration.
*/
protected void shutdown(int state) {
GenericServerRuntime runtime = getRuntimeDelegate();
try {
// $NON-NLS-1$
Trace.trace(Trace.FINEST, "Stopping Server");
if (state != IServer.STATE_STOPPED)
setServerState(IServer.STATE_STOPPING);
String configTypeID = getConfigTypeID();
ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = mgr.getLaunchConfigurationType(configTypeID);
String launchName = getStopLaunchName();
String uniqueLaunchName = mgr.generateUniqueLaunchConfigurationNameFrom(launchName);
ILaunchConfiguration conf = null;
ILaunchConfiguration[] lch = mgr.getLaunchConfigurations(type);
for (int i = 0; i < lch.length; i++) {
if (launchName.equals(lch[i].getName())) {
conf = lch[i];
break;
}
}
ILaunchConfigurationWorkingCopy wc = null;
if (conf != null) {
wc = conf.getWorkingCopy();
} else {
wc = type.newInstance(null, uniqueLaunchName);
}
// To stop from appearing in history lists
wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
// Set the stop attribute so that we know we are stopping
// $NON-NLS-1$
wc.setAttribute(ATTR_STOP, "true");
// Set the server ID so that we can distinguish stops
wc.setAttribute(ATTR_SERVER_ID, this.getServer().getId());
// Setup the launch config for stopping the server
setupStopLaunchConfiguration(runtime, wc);
// Launch the stop launch config
wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
} catch (Exception e) {
// $NON-NLS-1$
Trace.trace(Trace.SEVERE, "Error stopping Server", e);
}
}
use of org.eclipse.debug.core.ILaunchConfigurationType in project webtools.servertools by eclipse.
the class OverviewEditorPart method createGeneralSection.
protected void createGeneralSection(Composite leftColumnComp, FormToolkit toolkit) {
Section section = toolkit.createSection(leftColumnComp, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
section.setText(Messages.serverEditorOverviewGeneralSection);
section.setDescription(Messages.serverEditorOverviewGeneralDescription);
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
Composite composite = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
layout.horizontalSpacing = 5;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
whs.setHelp(composite, ContextIds.EDITOR_OVERVIEW_PAGE);
toolkit.paintBordersFor(composite);
section.setClient(composite);
int decorationWidth = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
// server name
if (server != null) {
createLabel(toolkit, composite, Messages.serverEditorOverviewServerName);
serverName = toolkit.createText(composite, server.getName());
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
data.horizontalIndent = decorationWidth;
serverName.setLayoutData(data);
serverName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (updating)
return;
updating = true;
execute(new SetServerNameCommand(getServer(), serverName.getText(), new SetServerNameCommand.Validator() {
public void validate() {
OverviewEditorPart.this.validate();
}
}));
updating = false;
}
});
whs.setHelp(serverName, ContextIds.EDITOR_SERVER);
// hostname
hostnameLabel = createLabel(toolkit, composite, Messages.serverEditorOverviewServerHostname);
hostname = toolkit.createText(composite, server.getHost());
hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
data.horizontalIndent = decorationWidth;
hostname.setLayoutData(data);
hostname.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (updating)
return;
updating = true;
execute(new SetServerHostnameCommand(getServer(), hostname.getText()));
updating = false;
}
});
whs.setHelp(hostname, ContextIds.EDITOR_HOSTNAME);
FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
FieldDecoration fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
hostnameDecoration.setImage(fd.getImage());
hostnameDecoration.setDescriptionText(fd.getDescription());
hostnameDecoration.hide();
hostname.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
hostnameDecoration.show();
}
public void focusLost(FocusEvent e) {
hostnameDecoration.hide();
}
});
// updateDecoration(hostnameDecoration, new Status(IStatus.INFO, ServerUIPlugin.PLUGIN_ID, "Press Ctrl-Space"));
List<String> hosts = ServerUIPlugin.getPreferences().getHostnames();
String[] hosts2 = hosts.toArray(new String[hosts.size()]);
new AutoCompleteField(hostname, new TextContentAdapter(), hosts2);
}
// runtime
if (server != null && server.getServerType() != null && server.getServerType().hasRuntime()) {
final Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewRuntime, SWT.NONE);
final IServerWorkingCopy server2 = server;
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
IRuntime runtime = server2.getRuntime();
if (runtime != null && ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId()))
editRuntime(runtime);
}
});
final IRuntime runtime = server.getRuntime();
if (runtime == null || !ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId()))
link.setEnabled(false);
IRuntimeType runtimeType = server.getServerType().getRuntimeType();
runtimes = ServerUIPlugin.getRuntimes(runtimeType);
runtimeCombo = new Combo(composite, SWT.READ_ONLY);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = decorationWidth;
data.horizontalSpan = 2;
runtimeCombo.setLayoutData(data);
updateRuntimeCombo();
int size = runtimes.length;
for (int i = 0; i < size; i++) {
if (runtimes[i].equals(runtime))
runtimeCombo.select(i);
}
runtimeCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
try {
if (updating)
return;
updating = true;
IRuntime newRuntime = runtimes[runtimeCombo.getSelectionIndex()];
execute(new SetServerRuntimeCommand(getServer(), newRuntime));
link.setEnabled(newRuntime != null && ServerUIPlugin.hasWizardFragment(newRuntime.getRuntimeType().getId()));
updating = false;
} catch (Exception ex) {
// ignore
}
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
whs.setHelp(runtimeCombo, ContextIds.EDITOR_RUNTIME);
// add runtime listener
runtimeListener = new IRuntimeLifecycleListener() {
public void runtimeChanged(final IRuntime runtime2) {
// may be name change of current runtime
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (runtime2.equals(getServer().getRuntime())) {
try {
if (updating)
return;
updating = true;
execute(new SetServerRuntimeCommand(getServer(), runtime2));
updating = false;
} catch (Exception ex) {
// ignore
}
}
if (runtimeCombo != null && !runtimeCombo.isDisposed()) {
updateRuntimeCombo();
int size2 = runtimes.length;
for (int i = 0; i < size2; i++) {
if (runtimes[i].equals(runtime))
runtimeCombo.select(i);
}
}
}
});
}
public void runtimeAdded(final IRuntime runtime2) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (runtimeCombo != null && !runtimeCombo.isDisposed()) {
updateRuntimeCombo();
int size2 = runtimes.length;
for (int i = 0; i < size2; i++) {
if (runtimes[i].equals(runtime))
runtimeCombo.select(i);
}
}
}
});
}
public void runtimeRemoved(IRuntime runtime2) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (runtimeCombo != null && !runtimeCombo.isDisposed()) {
updateRuntimeCombo();
int size2 = runtimes.length;
for (int i = 0; i < size2; i++) {
if (runtimes[i].equals(runtime))
runtimeCombo.select(i);
}
}
}
});
}
};
ServerCore.addRuntimeLifecycleListener(runtimeListener);
}
// server configuration path
if (server != null && server.getServerType() != null && server.getServerType().hasServerConfiguration()) {
createLabel(toolkit, composite, Messages.serverEditorOverviewServerConfigurationPath);
IFolder folder = server.getServerConfiguration();
if (folder == null)
serverConfiguration = toolkit.createText(composite, Messages.elementUnknownName);
else
serverConfiguration = toolkit.createText(composite, "" + server.getServerConfiguration().getFullPath());
serverConfiguration.setEditable(false);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = decorationWidth;
data.widthHint = 75;
serverConfiguration.setLayoutData(data);
whs.setHelp(serverConfiguration, ContextIds.EDITOR_CONFIGURATION);
final IFolder currentFolder = server.getServerConfiguration();
browse = toolkit.createButton(composite, Messages.serverEditorOverviewServerConfigurationBrowse, SWT.PUSH);
browse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ContainerSelectionDialog dialog = new ContainerSelectionDialog(serverConfiguration.getShell(), currentFolder, true, Messages.serverEditorOverviewServerConfigurationBrowseMessage);
dialog.showClosedProjects(false);
if (dialog.open() != Window.CANCEL) {
Object[] result = dialog.getResult();
if (result != null && result.length == 1) {
IPath path = (IPath) result[0];
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(path);
if (resource != null && resource instanceof IFolder) {
IFolder folder2 = (IFolder) resource;
if (updating)
return;
updating = true;
execute(new SetServerConfigurationFolderCommand(getServer(), folder2));
serverConfiguration.setText(folder2.getFullPath().toString());
updating = false;
}
}
}
}
});
browse.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
}
IServerType serverType = null;
if (server != null && server.getServerType() != null) {
serverType = server.getServerType();
if (serverType.supportsLaunchMode(ILaunchManager.RUN_MODE) || serverType.supportsLaunchMode(ILaunchManager.DEBUG_MODE) || serverType.supportsLaunchMode(ILaunchManager.PROFILE_MODE)) {
ILaunchConfigurationType launchType = ((ServerType) serverType).getLaunchConfigurationType();
if (launchType != null && launchType.isPublic()) {
final Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewOpenLaunchConfiguration, SWT.NONE);
GridData data = new GridData();
data.horizontalSpan = 3;
link.setLayoutData(data);
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
IEditorPart part = ((MultiPageEditorSite) getSite()).getMultiPageEditor();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.saveEditor(part, true);
try {
ILaunchConfiguration launchConfig = ((Server) getServer()).getLaunchConfiguration(true, null);
// TODO: use correct launch group
DebugUITools.openLaunchConfigurationPropertiesDialog(link.getShell(), launchConfig, "org.eclipse.debug.ui.launchGroup.run");
} catch (CoreException ce) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Could not create launch configuration", ce);
}
}
}
});
}
}
}
// Insertion of extension widgets. If the page modifier createControl is not implemented still
// add the modifier to the listeners list.
List<ServerEditorOverviewPageModifier> pageModifiersLst = getPageModifiers(serverType == null ? null : serverType.getId());
for (ServerEditorOverviewPageModifier curPageModifier : pageModifiersLst) {
if (server != null && server.getServerType() != null) {
curPageModifier.setServerWorkingCopy(server);
curPageModifier.setServerEditorPart(this);
curPageModifier.setFormToolkit(toolkit);
curPageModifier.createControl(ServerEditorOverviewPageModifier.UI_LOCATION.OVERVIEW, composite);
curPageModifier.setUIControlListener(this);
}
}
}
Aggregations