Java Code Examples for org.eclipse.debug.core.ILaunchConfigurationType#newInstance()

The following examples show how to use org.eclipse.debug.core.ILaunchConfigurationType#newInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OtherUtil.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static ILaunch startDiagnostics(String connectionName, String conid, boolean includeEclipseWorkspace, boolean includeProjectInfo, IProgressMonitor monitor) throws IOException, CoreException {
	List<String> options = new ArrayList<String>();
	options.add(CLIUtil.CON_ID_OPTION);
	options.add(conid);
	if (includeEclipseWorkspace) {
		options.add(ECLIPSE_WORKSPACE_OPTION);
		options.add(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
	}
	if (includeProjectInfo) {
		options.add(PROJECTS_OPTION);
	}
	List<String> command = CLIUtil.getCWCTLCommandList(null, DIAGNOSTICS_COLLECT_CMD, options.toArray(new String[options.size()]), null);
	
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(UtilityLaunchConfigDelegate.LAUNCH_CONFIG_ID);
	ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance((IContainer) null, connectionName);
	workingCopy.setAttribute(UtilityLaunchConfigDelegate.TITLE_ATTR, Messages.UtilGenDiagnosticsTitle);
	workingCopy.setAttribute(UtilityLaunchConfigDelegate.COMMAND_ATTR, command);
	ILaunchConfiguration launchConfig = workingCopy.doSave();
	return launchConfig.launch(ILaunchManager.RUN_MODE, monitor);
}
 
Example 2
Source File: Model.java    From tlaplus with MIT License 6 votes vote down vote up
public Model copyIntoForeignSpec(final Spec foreignSpec, final String newModelName) {
	final IProject foreignProject = foreignSpec.getProject();
	final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	final ILaunchConfigurationType launchConfigurationType
			= launchManager.getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE);
	final String sanitizedNewName = sanitizeName(newModelName);
	final String wholeName = fullyQualifiedNameFromSpecNameAndModelName(foreignSpec.getName(), sanitizedNewName);
	
	try {
		final ILaunchConfigurationWorkingCopy copy = launchConfigurationType.newInstance(foreignProject, wholeName);
		copyAttributesFromForeignModelToWorkingCopy(this, copy);
        copy.setAttribute(IConfigurationConstants.SPEC_NAME, foreignSpec.getName());
           copy.setAttribute(IConfigurationConstants.MODEL_NAME, sanitizedNewName);
           return copy.doSave().getAdapter(Model.class);
	} catch (CoreException e) {
		TLCActivator.logError("Error cloning foreign model.", e);
		return null;
	}
}
 
Example 3
Source File: LaunchShortcut.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private ILaunchConfiguration createConfiguration(IProject iProject) {
	ILaunchConfiguration config = null;
	try {
	    XdsProjectConfiguration xdsProjectSettings = new XdsProjectConfiguration(iProject);
		
		ILaunchConfigurationType configType = getConfigurationType(LAUNCH_CONFIG_TYPE_ID);		
		ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, 
				DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(iProject.getName())); 
		wc.setAttribute(ILaunchConfigConst.ATTR_PROJECT_NAME, iProject.getName());
		wc.setAttribute(ILaunchConfigConst.ATTR_EXECUTABLE_PATH, xdsProjectSettings.getExePath());
           wc.setAttribute(ILaunchConfigConst.ATTR_PROGRAM_ARGUMENTS, StringUtils.EMPTY);
           wc.setAttribute(ILaunchConfigConst.ATTR_DEBUGGER_ARGUMENTS, StringUtils.EMPTY);
           wc.setAttribute(ILaunchConfigConst.ATTR_SIMULATOR_ARGUMENTS, StringUtils.EMPTY);
		if (TextEncoding.isCodepageSupported(EncodingUtils.DOS_ENCODING)) {
   			wc.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, EncodingUtils.DOS_ENCODING);
		} 
        
		wc.setMappedResources(new IResource[] {iProject});
		config = wc.doSave();		
	} catch (CoreException e) {
		MessageDialog.openError(getShell(), Messages.Common_Error, Messages.LaunchShortcut_CantCreateLaunchCfg + ": " + e); //$NON-NLS-1$
	}
	return config;
}
 
Example 4
Source File: FlexMavenPackagedProjectStagingDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static ILaunchConfiguration createMavenPackagingLaunchConfiguration(IProject project)
    throws CoreException {
  ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType launchConfigurationType = launchManager
      .getLaunchConfigurationType(MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);

  String launchConfigName = "CT4E App Engine flexible Maven deploy artifact packaging "
      + project.getLocation().toString().replaceAll("[^a-zA-Z0-9]", "_");

  ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(
      null /*container*/, launchConfigName);
  workingCopy.setAttribute(ILaunchManager.ATTR_PRIVATE, true);
  // IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND;
  workingCopy.setAttribute("org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", true);
  workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, project.getLocation().toString());
  workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, "package");
  workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, "${project}");
  workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_RECURSIVE, true);

  IPath jreContainerPath = getJreContainerPath(project);
  workingCopy.setAttribute(
      IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jreContainerPath.toString());

  return workingCopy;
}
 
Example 5
Source File: CompilerLaunchShortcut.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private ILaunchConfigurationWorkingCopy createLaunchConfigWorkingCopy(String launchConfigName, IProject project)
    throws CoreException {
  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType type = manager.getLaunchConfigurationType(CompilerLaunchConfiguration.TYPE_ID);

  final ILaunchConfigurationWorkingCopy config = type.newInstance(null, launchConfigName);

  // Main type
  GWTLaunchConfigurationWorkingCopy.setMainType(config, GwtLaunchConfigurationProcessorUtilities.GWT_COMPILER);

  // project name
  LaunchConfigurationUtilities.setProjectName(config, project.getName());

  // classpath
  config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
      ModuleClasspathProvider.computeProviderId(project));

  // Link the launch configuration to the project.
  // This will cause the launch config to be deleted automatically if the project is deleted.
  config.setMappedResources(new IResource[] { project });

  // Modules
  LaunchConfigurationProcessorUtilities.updateViaProcessor(new ModuleArgumentProcessor(), config);

  return config;
}
 
Example 6
Source File: GwtSuperDevModeCodeServerLaunchUtil.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create a new GWT SDM Code Server Configuration. This will occur when running the debug
 * configuration from shortcut.
 */
public static ILaunchConfiguration createLaunchConfig(String launchConfigName, final IProject project)
    throws CoreException, OperationCanceledException {
  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType type = manager.getLaunchConfigurationType(GwtSuperDevModeLaunchConfiguration.TYPE_ID);
  ILaunchConfigurationWorkingCopy launchConfig = type.newInstance(null, launchConfigName);

  // Project name
  LaunchConfigurationUtilities.setProjectName(launchConfig, project.getName());

  launchConfig.setMappedResources(new IResource[] {project});

  setDefaults(launchConfig, project);

  // Save the new launch configuration
  ILaunchConfiguration ilaunchConfig = launchConfig.doSave();

  return ilaunchConfig;
}
 
Example 7
Source File: DotnetTestDelegate.java    From aCute with Eclipse Public License 2.0 5 votes vote down vote up
private ILaunchConfiguration getLaunchConfiguration(String mode, IResource resource) {
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType configType = launchManager
			.getLaunchConfigurationType("org.eclipse.acute.dotnettest.DotnetTestDelegate"); //$NON-NLS-1$
	try {
		ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(configType);

		String configName;
		if (resource.getLocation().toFile().isFile()) {
			configName = NLS.bind(Messages.DotnetTestDelegate_configuration, resource.getParent().getName() + "." + resource.getName()); //$NON-NLS-1$
		} else {
			configName = NLS.bind(Messages.DotnetTestDelegate_configuration, resource.getName());
		}

		for (ILaunchConfiguration iLaunchConfiguration : launchConfigurations) {
			if (iLaunchConfiguration.getName().equals(configName)
					&& iLaunchConfiguration.getModes().contains(mode)) {
				return iLaunchConfiguration;
			}
		}
		configName = launchManager.generateLaunchConfigurationName(configName);
		ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, configName);
		if (resource.getLocation().toFile().isFile()) {
			if (resource.getFileExtension().equals("cs")) { //$NON-NLS-1$
				wc.setAttribute(TEST_SELECTION_TYPE, SELECTED_TEST);
				wc.setAttribute(TEST_CLASS, resource.getName().replaceFirst("\\.cs$", "")); //$NON-NLS-1$ //$NON-NLS-2$
			}
			resource = resource.getParent();
		}
		wc.setAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, resource.getLocation().toString());

		return wc;
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 8
Source File: ScriptLaunchShortcut.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param fileName
 * @return
 */
protected static ILaunchConfiguration createConfiguration( String fileName )
{
	// String fileName = input.getPath( ).toOSString( );
	// int index = fileName.indexOf( File.separator );
	String name = "New_configuration";//$NON-NLS-1$

	name = DebugPlugin.getDefault( )
			.getLaunchManager( )
			.generateUniqueLaunchConfigurationNameFrom( name );
	ILaunchConfiguration config = null;
	ILaunchConfigurationWorkingCopy wc = null;
	try
	{
		ILaunchConfigurationType configType = getConfigurationType( );
		wc = configType.newInstance( null,
				getLaunchManager( ).generateUniqueLaunchConfigurationNameFrom( name ) );
		wc.setAttribute( IReportLaunchConstants.ATTR_REPORT_FILE_NAME,
				fileName );

		config = wc.doSave( );
	}
	catch ( CoreException exception )
	{
		logger.warning( exception.getMessage( ) );
	}
	return config;
}
 
Example 9
Source File: DotnetRunDelegate.java    From aCute with Eclipse Public License 2.0 5 votes vote down vote up
private ILaunchConfiguration getLaunchConfiguration(String mode, IResource resource) {
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType configType = launchManager
			.getLaunchConfigurationType("org.eclipse.acute.dotnetrun.DotnetRunDelegate"); //$NON-NLS-1$
	try {
		ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(configType);

		String configName;
		if (resource.getLocation().toFile().isFile()) {
			configName = NLS.bind(Messages.DotnetRunDelegate_configuration, resource.getParent().getName() + "." + resource.getName()); //$NON-NLS-1$
		} else {
			configName = NLS.bind(Messages.DotnetRunDelegate_configuration, resource.getName());
		}

		for (ILaunchConfiguration iLaunchConfiguration : launchConfigurations) {
			if (iLaunchConfiguration.getName().equals(configName)
					&& iLaunchConfiguration.getModes().contains(mode)) {
				return iLaunchConfiguration;
			}
		}
		configName = launchManager.generateLaunchConfigurationName(configName);
		ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, configName);
		if (resource.getLocation().toFile().isFile()) {
			resource = resource.getParent();
		}
		wc.setAttribute(PROJECT_FOLDER, resource.getLocation().toString());
		return wc;
	} catch (CoreException e) {
		AcutePlugin.logError(e);
	}
	return null;
}
 
Example 10
Source File: TestConfigurationConverter.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Converts a {@link TestConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in
 * case of error.
 *
 * @param failed
 *            may be null, only used in test view to execute failed tests
 * @see TestConfiguration#readPersistentValues()
 */
public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, TestConfiguration testConfig,
		List<TestCase> failed) {
	try {
		final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager()
				.getLaunchConfigurations(type);

		for (ILaunchConfiguration config : configs) {
			if (equals(testConfig, config))
				return config;
		}

		final IContainer container = null;
		final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, testConfig.getName());

		workingCopy.setAttributes(testConfig.readPersistentValues());
		if (failed != null && !failed.isEmpty()) {
			workingCopy.setAttribute(TestConfiguration.TESTCASE_SELECTION,
					failed.stream().map(tc -> {
						String s = tc.getURI().toString();
						return s;
					}).collect(Collectors.toList()));
		}

		return workingCopy.doSave();
	} catch (Exception e) {
		throw new WrappedException("could not convert N4JS TestConfiguration to Eclipse ILaunchConfiguration", e);
	}
}
 
Example 11
Source File: DataRepositoryServerManager.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void start(IProgressMonitor monitor) {
    if (launch == null
            || Stream.of(launch.getProcesses())
                    .findFirst()
                    .map(IProcess::isTerminated)
                    .orElse(false)) {
        monitor.beginTask(Messages.startingDataRepositoryService, IProgressMonitor.UNKNOWN);
        BonitaStudioLog.info(Messages.startingDataRepositoryService, UIDesignerPlugin.PLUGIN_ID);
        final ILaunchManager manager = getLaunchManager();
        final ILaunchConfigurationType ltype = manager
                .getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);

        try {
            final ILaunchConfigurationWorkingCopy workingCopy = ltype.newInstance(null, "Data Repository Service");
            workingCopy.setAttribute(IExternalToolConstants.ATTR_LOCATION, dataRepositoryBinaryLocation());
            workingCopy.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS,
                    Joiner.on(" ").join(buildCommand()));
            launch = workingCopy.launch(ILaunchManager.RUN_MODE, Repository.NULL_PROGRESS_MONITOR);
            if (launch != null && launch.getProcesses().length > 0) {
                BonitaStudioLog.info(
                        String.format("Data Repository Service has been started on http://localhost:%s/", port),
                        UIDesignerPlugin.PLUGIN_ID);
            } else {
                BonitaStudioLog.error(
                        String.format("Data Repository Service failed to start on http://localhost:%s/", port),
                        UIDesignerPlugin.PLUGIN_ID);
            }
        } catch (final CoreException | IOException e) {
            BonitaStudioLog.error("Failed to run data repository service", e);
        } finally {
            monitor.done();
        }
    }
}
 
Example 12
Source File: LaunchShortcut.java    From dartboard with Eclipse Public License 2.0 5 votes vote down vote up
private void launchProject(IProject project, String mode) {
	if (project == null) {
		return;
	}

	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();

	ILaunchConfigurationType type = manager.getLaunchConfigurationType("org.eclipse.dartboard.flutter.launch");

	try {
		// Find last launch configuration for selected project.
		ILaunchConfiguration launchConfiguration = null;
		for (ILaunchConfiguration conf : manager.getLaunchConfigurations(type)) {
			if (conf.getAttribute("selected_project", "").equalsIgnoreCase(project.getName())) { //$NON-NLS-1$
				launchConfiguration = conf;
			}
		}

		if (launchConfiguration != null) {
			DebugUITools.launch(launchConfiguration, mode);
		} else {
			ILaunchConfigurationWorkingCopy copy = type.newInstance(null, manager.generateLaunchConfigurationName(
					LaunchConfigurationsMessages.CreateLaunchConfigurationAction_New_configuration_2));

			copy.setAttribute("selected_project", project.getName());

			int result = DebugUITools.openLaunchConfigurationDialog(PlatformUIUtil.getActiveShell(), copy,
					"org.eclipse.dartboard.launchGroup", null);

			if (result == Window.OK) {
				copy.doSave();
			}
		}
	} catch (CoreException e) {
		LOG.log(DartLog.createError("Could not save new launch configuration", e)); //$NON-NLS-1$
	}
}
 
Example 13
Source File: LaunchPipelineShortcut.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private void launchNew(LaunchableResource resource, String mode) {
  try {
    ILaunchManager launchManager = getLaunchManager();

    String launchConfigurationName =
        launchManager.generateLaunchConfigurationName(resource.getLaunchName());
    ILaunchConfigurationType configurationType =
        getDataflowLaunchConfigurationType(launchManager);
    ILaunchConfigurationWorkingCopy configuration =
        configurationType.newInstance(null, launchConfigurationName);

    configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
        resource.getProjectName());
    IMethod mainMethod = resource.getMainMethod();
    if (mainMethod != null && mainMethod.exists()) {
      configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
          mainMethod.getDeclaringType().getFullyQualifiedName());
    }

    String groupIdentifier =
        mode.equals(ILaunchManager.RUN_MODE) ? IDebugUIConstants.ID_RUN_LAUNCH_GROUP
            : IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP;
    int returnStatus =
        DebugUITools.openLaunchConfigurationDialog(DataflowUiPlugin.getActiveWindowShell(),
            configuration, groupIdentifier, null);
    if (returnStatus == Window.OK) {
      configuration.doSave();
    }
  } catch (CoreException e) {
    // TODO: Handle
    DataflowUiPlugin.logError(e, "Error while launching new Launch Configuration for project %s",
        resource.getProjectName());
  }
}
 
Example 14
Source File: ProjectLaunchSettings.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public ILaunchConfiguration createNewConfiguration(ILaunchConfigurationType launchCfgType) 
		throws CoreException, CommonException {
	String suggestedName = getSuggestedConfigName();
	
	String launchName = getLaunchManager().generateLaunchConfigurationName(suggestedName);
	ILaunchConfigurationWorkingCopy wc = launchCfgType.newInstance(null, launchName);
	
	saveToConfig(wc);
	return wc.doSave();
}
 
Example 15
Source File: PydevIProcessFactory.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private static ILaunchConfiguration createLaunchConfig() {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType = manager
            .getLaunchConfigurationType("org.python.pydev.debug.interactiveConsoleConfigurationType");
    ILaunchConfigurationWorkingCopy newInstance;
    try {
        newInstance = launchConfigurationType.newInstance(null,
                manager.generateLaunchConfigurationName("PyDev Interactive Launch"));
    } catch (CoreException e) {
        return null;
    }
    newInstance.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
    return newInstance;
}
 
Example 16
Source File: DsfGdbAdaptor.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Builds a launcher and launches a Post-mortem GDB session, based on a
 * previously-gathered GDB Tracepoint file.  The information used to
 * create the launcher is provided to the constructor of this class,
 * at instantiation time.
 * <p>
 * Note: Requires GDB 7.2 or later
 */
private void launchDGBPostMortemTrace() throws CoreException {
    fIsTimeoutEnabled = Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID, IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, false, null);
    if (fIsTimeoutEnabled) {
        fTimeout = Platform.getPreferencesService().getInt(GdbPlugin.PLUGIN_ID, IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT, null);
    }

    ILaunchConfigurationType configType = DebugPlugin
            .getDefault()
            .getLaunchManager()
            .getLaunchConfigurationType("org.eclipse.cdt.launch.postmortemLaunchType"); //$NON-NLS-1$
    ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, fTraceFile);

    wc.setAttribute("org.eclipse.cdt.dsf.gdb.DEBUG_NAME", gdb72Executable); //$NON-NLS-1$
    wc.setAttribute("org.eclipse.cdt.dsf.gdb.POST_MORTEM_TYPE", "TRACE_FILE"); //$NON-NLS-1$ //$NON-NLS-2$
    wc.setAttribute("org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR", 0); //$NON-NLS-1$
    wc.setAttribute("org.eclipse.cdt.launch.COREFILE_PATH", fTraceFilePath); //$NON-NLS-1$
    wc.setAttribute("org.eclipse.cdt.launch.DEBUGGER_START_MODE", "core"); //$NON-NLS-1$ //$NON-NLS-2$
    wc.setAttribute("org.eclipse.cdt.launch.PROGRAM_NAME", tracedExecutable); //$NON-NLS-1$
    // So that the GDB launch is synchronous
    wc.setAttribute("org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", false); //$NON-NLS-1$

    if (!sourceLocator.isEmpty()) {
        wc.setAttribute("org.eclipse.debug.core.source_locator_memento", sourceLocator); //$NON-NLS-1$
    }

    // Launch GDB session
    fLaunch = wc.doSave().launch("debug", null); //$NON-NLS-1$
    isTerminating = false;

    if (fLaunch instanceof GdbLaunch) {
        fSessionId = ((GdbLaunch) fLaunch).getSession().getId();
    }

    fDsfSession = ((GdbLaunch) fLaunch).getSession();
    fDsfSession.addServiceEventListener(this, null);

    // Find the number of frames contained in the tracepoint file
    fNumberOfFrames = findNumFrames();
}
 
Example 17
Source File: LaunchConfigurationCreator.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @param resource only used if captureOutput is true!
 * @param location only used if captureOutput is false!
 * @param captureOutput determines if the output should be captured or not (if captured a console will be
 * shown to it by default)
 */
private static ILaunchConfigurationWorkingCopy createDefaultLaunchConfiguration(FileOrResource[] resource,
        String launchConfigurationType, String location, IInterpreterManager pythonInterpreterManager,
        String projName, String vmargs, String programArguments, boolean captureOutput) throws CoreException {

    ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigurationType);
    if (type == null) {
        throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, "Python launch configuration not found",
                null));
    }

    IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();

    String name;
    String baseDirectory;
    String moduleFile;
    int resourceType;

    if (captureOutput) {
        StringBuffer buffer = new StringBuffer(projName);
        buffer.append(" ");
        StringBuffer resourceNames = new StringBuffer();
        for (FileOrResource r : resource) {
            if (resourceNames.length() > 0) {
                resourceNames.append(" - ");
            }
            if (r.resource != null) {
                resourceNames.append(r.resource.getName());
            } else {
                resourceNames.append(r.file.getName());
            }
        }
        buffer.append(resourceNames);
        name = buffer.toString().trim();

        if (resource[0].resource != null) {
            // Build the working directory to a path relative to the workspace_loc
            baseDirectory = resource[0].resource.getFullPath().removeLastSegments(1).makeRelative().toString();
            baseDirectory = varManager.generateVariableExpression("workspace_loc", baseDirectory);

            // Build the location to a path relative to the workspace_loc
            moduleFile = makeFileRelativeToWorkspace(resource, varManager);
            resourceType = resource[0].resource.getType();
        } else {
            baseDirectory = FileUtils.getFileAbsolutePath(resource[0].file.getParentFile());

            // Build the location to a path relative to the workspace_loc
            moduleFile = FileUtils.getFileAbsolutePath(resource[0].file);
            resourceType = IResource.FILE;
        }
    } else {
        captureOutput = true;
        name = location;
        baseDirectory = new File(location).getParent();
        moduleFile = location;
        resourceType = IResource.FILE;
    }

    name = manager.generateLaunchConfigurationName(name);

    ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, name);
    // Python Main Tab Arguments

    workingCopy.setAttribute(Constants.ATTR_PROJECT, projName);
    workingCopy.setAttribute(Constants.ATTR_RESOURCE_TYPE, resourceType);
    workingCopy.setAttribute(Constants.ATTR_INTERPRETER, Constants.ATTR_INTERPRETER_DEFAULT);

    workingCopy.setAttribute(Constants.ATTR_LOCATION, moduleFile);
    workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY, baseDirectory);
    workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, programArguments);
    workingCopy.setAttribute(Constants.ATTR_VM_ARGUMENTS, vmargs);

    workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, captureOutput);
    workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, captureOutput);

    if (resource[0].resource != null) {
        workingCopy.setMappedResources(FileOrResource.createIResourceArray(resource));
    }
    return workingCopy;
}
 
Example 18
Source File: WebAppLaunchUtil.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create a launch new configuration working copy.
 *
 * @param isGwtSuperDevModeEnabled will turn on GWT super dev mode.
 * @return ILaunchConfigurationWorkingCopy
 * @throws CoreException
 * @throws OperationCanceledException
 */
public static ILaunchConfigurationWorkingCopy createLaunchConfigWorkingCopy(
    String launchConfigName, final IProject project, String url, boolean isExternal,
    boolean isGwtSuperDevModeEnabled) throws CoreException, OperationCanceledException {

  assert (url != null);

  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType type =
      manager.getLaunchConfigurationType(WebAppLaunchConfiguration.TYPE_ID);

  final ILaunchConfigurationWorkingCopy wc = type.newInstance(null, launchConfigName);

  setDefaults(wc, project);
  LaunchConfigurationUtilities.setProjectName(wc, project.getName());
  if (isExternal) {
    WebAppLaunchConfigurationWorkingCopy.setRunServer(wc, false);
  }
  GWTLaunchConfigurationWorkingCopy.setStartupUrl(wc, url);

  IPath warDir = null;
  if (WebAppUtilities.hasManagedWarOut(project)) {
    warDir = WebAppUtilities.getManagedWarOut(project).getLocation();
  }

  if (warDir != null) {
    // The processor will update to the proper argument style for the current
    // project nature(s)
    WarArgumentProcessor warArgProcessor = new WarArgumentProcessor();
    warArgProcessor.setWarDirFromLaunchConfigCreation(warDir.toOSString());
    LaunchConfigurationProcessorUtilities.updateViaProcessor(warArgProcessor, wc);
  }
  // Link the launch configuration to the project. This will cause the
  // launch config to be deleted automatically if the project is deleted.
  wc.setMappedResources(new IResource[] {project});

  // GWT SDM
  GWTLaunchConfigurationWorkingCopy.setSuperDevModeEnabled(wc, isGwtSuperDevModeEnabled);
  SuperDevModeArgumentProcessor sdmArgsProcessor = new SuperDevModeArgumentProcessor();
  LaunchConfigurationProcessorUtilities.updateViaProcessor(sdmArgsProcessor, wc);

  return wc;
}
 
Example 19
Source File: ScanWorkspaceOperation.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    monitor.beginTask(Messages.scanningWorkspace, IProgressMonitor.UNKNOWN);
    final ILaunchManager manager = getLaunchManager();
    final ILaunchConfigurationType ltype = manager
            .getLaunchConfigurationType(IPDELauncherConstants.ECLIPSE_APPLICATION_LAUNCH_CONFIGURATION_TYPE);
    try {
        final ILaunchConfigurationWorkingCopy workingCopy = ltype.newInstance(null, "Scan workspace");
        workingCopy.setAttribute(IPDELauncherConstants.APPLICATION,
                applicationId());
        workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "-scan");
        if (Objects.equals(Platform.getOS(), Platform.OS_MACOSX)) {
            workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_USE_START_ON_FIRST_THREAD, true);
        }
        workingCopy.setAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false);
        workingCopy.setAttribute(IPDELauncherConstants.RUN_IN_UI_THREAD, true);
        workingCopy.setAttribute(IPDELauncherConstants.DOCLEAR, false);
        workingCopy.setAttribute(IPDELauncherConstants.LOCATION, tmpWorskpaceFolder());
        workingCopy.setAttribute(IPDELauncherConstants.USE_PRODUCT, false);
        final ILaunch launch = workingCopy.launch("run", Repository.NULL_PROGRESS_MONITOR);
        launch.getProcesses()[0].getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() {

            @Override
            public void streamAppended(String text, IStreamMonitor streamMonitor) {
                if (text.startsWith("$SCAN_PROGRESS_")) {
                    scanStatus(text);
                }
            }
        });
        while (!launch.isTerminated()) {
            Thread.sleep(1000);
        }
        if (workspaceModel.isEmpty()) {
            workspaceModel.setStatus(ValidationStatus.error(Messages.noRepositoryFoundAtLocation));
        }
        if (launch.isTerminated()) {
            monitor.done();
        }
    } catch (final CoreException | IOException e) {
        throw new InvocationTargetException(e);
    }
}
 
Example 20
Source File: LaunchConfigRule.java    From eclipse-extras with Eclipse Public License 1.0 4 votes vote down vote up
private ILaunchConfigurationWorkingCopy newPrivateLaunchConfig() throws CoreException {
  ILaunchConfigurationType type = getPrivateTestLaunchConfigType();
  return type.newInstance( null, getUniqueLaunchConfigName() );
}