title: create programmatically a junit launch configuration
body: <p>I wrote an eclipse(Juno) plugin to automatically create a junit launch configuration, when a project is created. I listen the changes in the workspace and when a new java project is created, I start a process to create the corresponding launch configuration:</p>
  
  <pre><code>public static void create(IProject project) {
      ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
      ILaunchConfigurationType launchType = manager
              .getLaunchConfigurationType(JUNIT_LAUNCH_IDENTIFIER);
      try {
          ILaunchConfigurationWorkingCopy workingCopy = launchType.newInstance(null, project.getName());
          List&lt;IResource&gt; resources = new ArrayList&lt;IResource&gt;();
          resources.add(project);
          IResource[] resourcesArray = toArray(resources);
          workingCopy.setMappedResources(resources.toArray(resourcesArray) );
          workingCopy.setAttribute("org.eclipse.jdt.junit.CONTAINER", project.getName().replace("#", "\\#"));
          workingCopy.setAttribute("org.eclipse.jdt.junit.KEEPRUNNING_ATTR", false);
          workingCopy.setAttribute("org.eclipse.jdt.junit.TESTNAME", "");
          workingCopy.setAttribute("org.eclipse.jdt.junit.TEST_KIND", "org.eclipse.jdt.junit.loader.junit4");
          workingCopy.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE", "");
          workingCopy.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", "");
          workingCopy.setAttribute("org.eclipse.jdt.launching.VM_ARGUMENTS", "-Xms128m -Xmx512m -DSYS_DRIVE=${env_var:SYS_DRIVE} " +
                  "-DAPPL_DRIVE=${env_var:APPL_DRIVE} -DDATA1_DRIVE=${env_var:DATA1_DRIVE} -DSYS_DIR=${env_var:SYS_DIR} " +
                  "-DEXT1_DRIVE=F: -DTESTDATA_ROOT=${workspace_loc:trunk#IS+LVIS/testdata}");
          workingCopy.doSave();
      } catch (CoreException e) {
          log.log(Level.WARNING,
                  "Unable to create a new launch configuration.", e);
      }
  }
  </code></pre>
  
  <p>By the method workingCopy.setMappedResources(), I give as parameter the corresponding IProject. I try the plugin, I create a project with the name 'testProject', my plugin receives the event and create the junit launch configuration file. I check the file, I open it in an editor and the attribute above are setted. Now I opened the eclipse debug configuration dialog, I get a problem </p>
  
  <p><img src="https://i.stack.imgur.com/p2ZQ3.png" alt="enter image description here"></p>
  
  <p>It look the dialog opening overwrote the launch configuration and I get no project selected in the dialog.</p>
  
  <p>Another thing is that, when I make a right click on my project in the package explorer view to debug the project as Junit, it creates another launch configuration with the same name and the suffix (1). So "testProject(1)".</p>