Java Code Examples for org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#getAttribute()

The following examples show how to use org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#getAttribute() . 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: DataflowPipelineLaunchDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private void setCredentialEnvironmentVariable(
    ILaunchConfigurationWorkingCopy workingCopy, String value) throws CoreException {
  // Dataflow SDK doesn't yet support reading credentials from an arbitrary JSON, so we use the
  // workaround of setting the "GOOGLE_APPLICATION_CREDENTIALS" environment variable.
  Map<String, String> variableMap = workingCopy.getAttribute(
      ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap<String, String>());
  if (variableMap.containsKey(GOOGLE_APPLICATION_CREDENTIALS_ENVIRONMENT_VARIABLE)) {
    String message = "You cannot define the environment variable GOOGLE_APPLICATION_CREDENTIALS"
        + " when launching Dataflow pipelines from Cloud Tools for Eclipse.";
    throw new CoreException(new Status(Status.ERROR, DataflowCorePlugin.PLUGIN_ID, message));
  }

  Map<String, String> variableMapCopy = new HashMap<>(variableMap);
  variableMapCopy.put(GOOGLE_APPLICATION_CREDENTIALS_ENVIRONMENT_VARIABLE, value);
  workingCopy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, variableMapCopy);
}
 
Example 2
Source File: TexLaunchConfigurationTab.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Initializes the given launch configuration with
 * default values for this tab. This method
 * is called when a new launch configuration is created
 * such that the configuration can be initialized with
 * meaningful values. This method may be called before this
 * tab's control is created.
 * 
 * If the configuration parameter contains an attribute named
 * 'viewerCurrent', the tab is initialized with the default values
 * for the given viewer. The given viewer is expected to exist.
 * 
 * @param configuration launch configuration
 */
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
    try {
        String viewer = configuration.getAttribute("viewerCurrent", registry.getActiveViewer());
        registry.setActiveViewer(viewer);
        
        configuration.setAttribute(ViewerAttributeRegistry.VIEWER_CURRENT, viewer);
        configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_COMMAND, registry.getCommand());
        configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_ARGUMENTS, registry.getArguments());
        configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_VIEW_COMMAND, registry.getDDEViewCommand());
        configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_VIEW_SERVER, registry.getDDEViewServer());
        configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_VIEW_TOPIC, registry.getDDEViewTopic());
        configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_CLOSE_COMMAND, registry.getDDECloseCommand());
        configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_CLOSE_SERVER, registry.getDDECloseServer());
        configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_CLOSE_TOPIC, registry.getDDECloseTopic());  
    } catch (CoreException e) {
        TexlipsePlugin.log("Initializing launch configuration", e);
    }
}
 
Example 3
Source File: XStartOnFirstThreadArgumentProcessor.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private void updateEclipse43(ILaunchConfigurationWorkingCopy launchConfig,
    IJavaProject javaProject, List<String> programArgs, List<String> vmArgs)
    throws CoreException {

  boolean startOnFirstThread = launchConfig.getAttribute(ATTR_XSTART_ON_FIRST_THREAD, false);

  if (needsStartOnFirstThreadHack(javaProject, launchConfig)) {
    /*
     * If we're on a mac, we might need the -XstartOnFirstThread attribute set to true in order to work
     * around a UI threading issue with the Mac platform.
     */
    if (!startOnFirstThread) {
      launchConfig.setAttribute(ATTR_XSTART_ON_FIRST_THREAD, true);
      launchConfig.doSave();
    }
  } else if (startOnFirstThread) {
    launchConfig.removeAttribute(ATTR_XSTART_ON_FIRST_THREAD);
    launchConfig.doSave();
  }
}
 
Example 4
Source File: AppEngineLaunchShortcut.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * The only thing different is that we have to override the creation of the default launch configuration.
 */
@Override
public ILaunchConfiguration createDefaultLaunchConfiguration(FileOrResource[] resources) {

    try {
        ILaunchConfigurationWorkingCopy workingCopy = super
                .createDefaultLaunchConfigurationWithoutSaving(resources);

        String mainDir = workingCopy.getAttribute(Constants.ATTR_LOCATION, "");

        //dev_appserver.py [options] <application root>
        workingCopy.setAttribute(Constants.ATTR_LOCATION, "${GOOGLE_APP_ENGINE}/dev_appserver.py");
        workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, "\"" + mainDir + "\"");

        return workingCopy.doSave();
    } catch (CoreException e) {
        reportError(null, e);
        return null;
    }
}
 
Example 5
Source File: BOSWebServerManager.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createLaunchConfiguration(final IServer server, final IProgressMonitor monitor)
        throws CoreException {
    ILaunchConfiguration conf = server.getLaunchConfiguration(false, Repository.NULL_PROGRESS_MONITOR);
    if (conf == null) {
        conf = server.getLaunchConfiguration(true,
                Repository.NULL_PROGRESS_MONITOR);
    }
    ILaunchConfigurationWorkingCopy workingCopy = conf.getWorkingCopy();
    final String args = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "");
    if (!args.contains(tomcatInstanceLocation)) {
        conf = server.getLaunchConfiguration(true,
                Repository.NULL_PROGRESS_MONITOR);
        workingCopy = conf.getWorkingCopy();
    }
    configureLaunchConfiguration(workingCopy);
}
 
Example 6
Source File: DjangoLaunchShortcut.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * The only thing different is that we have to override the creation of the default launch configuration.
 */
@Override
public ILaunchConfiguration createDefaultLaunchConfiguration(FileOrResource[] resources) {

    try {
        ILaunchConfigurationWorkingCopy workingCopy = super
                .createDefaultLaunchConfigurationWithoutSaving(resources);

        //manage.py [options] runserver
        String mainDir = workingCopy.getAttribute(Constants.ATTR_LOCATION, "");
        //the attr location is something as ${workspace_loc:django2}
        workingCopy.setAttribute(Constants.ATTR_LOCATION, mainDir + "/${" + DjangoConstants.DJANGO_MANAGE_VARIABLE
                + "}");
        if (DebugPrefsPage.getDebugMultiprocessingEnabled()
                && RunPreferencesPage.getKillSubprocessesWhenTerminatingProcess()) {
            workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, "runserver");

        } else {
            //if either we're not debugging with multiprocessing or not killing subprocesses we have to add the --noreload.
            workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, "runserver --noreload");
        }

        return workingCopy.doSave();
    } catch (CoreException e) {
        reportError(null, e);
        return null;
    }
}