Esempio n. 1
0
  /**
   * Launches the generation.
   *
   * @param monitor This will be used to display progress information to the user.
   * @throws IOException Thrown when the output cannot be saved.
   * @generated
   */
  public void doGenerate(IProgressMonitor monitor) throws IOException {
    if (!targetFolder.getLocation().toFile().exists()) {
      targetFolder.getLocation().toFile().mkdirs();
    }

    // final URI template0 = getTemplateURI("org.earthsystemcurator.cupid.esmf2fortran", new
    // Path("/esmf2fortran/main/generate.emtl"));
    // esmf2fortran.main.Generate gen0 = new esmf2fortran.main.Generate(modelURI,
    // targetFolder.getLocation().toFile(), arguments) {
    //	protected URI createTemplateURI(String entry) {
    //		return template0;
    //	}
    // };
    // gen0.doGenerate(BasicMonitor.toMonitor(monitor));
    monitor.subTask("Loading...");
    esmf2fortran.main.Generate gen0 =
        new esmf2fortran.main.Generate(modelURI, targetFolder.getLocation().toFile(), arguments);
    monitor.worked(1);
    String generationID =
        org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID(
            "org.earthsystemcurator.cupid.esmf2fortran",
            "esmf2fortran.main.Generate",
            modelURI.toString(),
            targetFolder.getFullPath().toString(),
            new ArrayList<String>());
    gen0.setGenerationID(generationID);
    gen0.doGenerate(BasicMonitor.toMonitor(monitor));
  }
  /**
   * Launches the generation.
   *
   * @param monitor This will be used to display progress information to the user.
   * @throws IOException Thrown when the output cannot be saved.
   * @generated
   */
  public void doGenerate(IProgressMonitor monitor) throws IOException {
    if (!targetFolder.getLocation().toFile().exists()) {
      targetFolder.getLocation().toFile().mkdirs();
    }

    // final URI template0 =
    // getTemplateURI("org.eclipse.papyrus.robotml.generators.intempora.rtmaps", new
    // Path("/org/eclipse/robotml/generators/acceleo/rtmaps/main/generate_rtmaps.emtl"));
    // org.eclipse.papyrus.robotml.generators.intempora.rtmaps.main.Generate_rtmaps gen0 = new
    // org.eclipse.papyrus.robotml.generators.intempora.rtmaps.main.Generate_rtmaps(modelURI,
    // targetFolder.getLocation().toFile(), arguments) {
    //	protected URI createTemplateURI(String entry) {
    //		return template0;
    //	}
    // };
    // gen0.doGenerate(BasicMonitor.toMonitor(monitor));
    monitor.subTask("Loading...");
    Generate_rtmaps gen0 =
        new Generate_rtmaps(modelURI, targetFolder.getLocation().toFile(), arguments);
    monitor.worked(1);
    String generationID =
        org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID(
            "org.eclipse.papyrus.robotml.generators.intempora.rtmaps",
            "org.eclipse.papyrus.robotml.generators.intempora.rtmaps.main.Generate_rtmaps",
            modelURI.toString(),
            targetFolder.getFullPath().toString(),
            new ArrayList<String>());
    gen0.setGenerationID(generationID);
    gen0.doGenerate(BasicMonitor.toMonitor(monitor));
  }
Esempio n. 3
0
  protected void runPub(
      IContainer container, final MessageConsole console, List<String> args, boolean wait) {

    stringBuilder = new StringBuilder();
    ProcessBuilder builder = new ProcessBuilder();
    builder.directory(container.getLocation().toFile());
    builder.redirectErrorStream(true);
    builder.command(args);

    final Process process;
    try {
      process = builder.start();
      final Thread stdoutThread =
          new Thread(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    copy(process.getInputStream(), console);
                  } catch (IOException e) {
                    // do nothing
                  }
                }
              });
      stdoutThread.start();
      if (wait) {
        process.waitFor();
      }
    } catch (IOException e) {
      String message = NLS.bind(PubMessages.RunPubJob_failed, command, e.toString());
      console.println(message);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
  private boolean runPubServe(DartLaunchConfigWrapper wrapper) {

    stdOut = new StringBuilder();
    stdError = new StringBuilder();
    IResource resource = wrapper.getApplicationResource();
    console.printSeparator("Starting pub serve : " + resource.getProject().getName());

    workingDir = DartCore.getApplicationDirectory(resource);

    List<String> args = buildPubServeCommand();
    String dirName = getPubserveRootDir(workingDir, resource);
    if (dirName != null) {
      args.add(getPubserveRootDir(workingDir, resource));
    }
    ProcessBuilder builder = new ProcessBuilder();
    builder.command(args);

    builder.directory(workingDir.getLocation().toFile());

    try {
      process = builder.start();
    } catch (IOException e) {
      DartCore.logError(e);
      return false;
    }

    Thread stdoutThread =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                copyStream(process.getInputStream(), stdOut, true);
              }
            });
    stdoutThread.start();

    Thread stderrThread =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                copyStream(process.getErrorStream(), stdError, true);
              }
            });
    stderrThread.start();

    while (!isTerminated() && !stdOut.toString().contains(LOCAL_HOST_ADDR)) {
      try {
        Thread.sleep(200);
      } catch (Exception exception) {

      }
    }

    if (isTerminated()) {
      return false;
    }
    currentLaunch = wrapper;
    return true;
  }
 public void copyImportFile(IContainer importLocation, boolean isNewAritfact, String groupId)
     throws IOException {
   File importFile = getModel().getImportFile();
   File destFile = null;
   List<OMElement> selectedSeqList = ((TemplateModel) getModel()).getSelectedTempSequenceList();
   if (selectedSeqList != null && selectedSeqList.size() > 0) {
     for (OMElement element : selectedSeqList) {
       String name = element.getAttributeValue(new QName("name"));
       destFile = new File(importLocation.getLocation().toFile(), name + ".xml");
       FileUtils.createFile(destFile, element.toString());
       fileLst.add(destFile);
       if (isNewAritfact) {
         ESBArtifact artifact = new ESBArtifact();
         artifact.setName(name);
         artifact.setVersion(version);
         artifact.setType("synapse/template");
         artifact.setServerRole("EnterpriseServiceBus");
         artifact.setGroupId(groupId);
         artifact.setFile(
             FileUtils.getRelativePath(
                     importLocation.getProject().getLocation().toFile(),
                     new File(importLocation.getLocation().toFile(), name + ".xml"))
                 .replaceAll(Pattern.quote(File.separator), "/"));
         esbProjectArtifact.addESBArtifact(artifact);
       }
     }
   } else {
     destFile = new File(importLocation.getLocation().toFile(), importFile.getName());
     FileUtils.copy(importFile, destFile);
     fileLst.add(destFile);
     String name = importFile.getName().replaceAll(".xml$", "");
     if (isNewAritfact) {
       ESBArtifact artifact = new ESBArtifact();
       artifact.setName(name);
       artifact.setVersion(version);
       artifact.setType("synapse/template");
       artifact.setServerRole("EnterpriseServiceBus");
       artifact.setGroupId(groupId);
       artifact.setFile(
           FileUtils.getRelativePath(
                   importLocation.getProject().getLocation().toFile(),
                   new File(importLocation.getLocation().toFile(), name + ".xml"))
               .replaceAll(Pattern.quote(File.separator), "/"));
       esbProjectArtifact.addESBArtifact(artifact);
     }
   }
 }
  private ILaunchConfiguration createLaunchConfiguration(IContainer basedir, String goal) {
    try {
      ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
      ILaunchConfigurationType launchConfigurationType =
          launchManager.getLaunchConfigurationType(
              MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);

      String launchSafeGoalName = goal.replace(':', '-');

      ILaunchConfigurationWorkingCopy workingCopy =
          launchConfigurationType.newInstance(
              null, //
              NLS.bind(
                  Messages.ExecutePomAction_executing,
                  launchSafeGoalName,
                  basedir.getLocation().toString().replace('/', '-')));
      workingCopy.setAttribute(
          MavenLaunchConstants.ATTR_POM_DIR, basedir.getLocation().toOSString());
      workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, goal);
      workingCopy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
      workingCopy.setAttribute(RefreshTab.ATTR_REFRESH_SCOPE, "${project}"); // $NON-NLS-1$
      workingCopy.setAttribute(RefreshTab.ATTR_REFRESH_RECURSIVE, true);

      setProjectConfiguration(workingCopy, basedir);

      IPath path = getJREContainerPath(basedir);
      if (path != null) {
        workingCopy.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, path.toPortableString());
      }

      // TODO when launching Maven with debugger consider to add the following property
      // -Dmaven.surefire.debug="-Xdebug
      // -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent
      // -Djava.compiler=NONE"

      return workingCopy;
    } catch (CoreException ex) {
      log.error(ex.getMessage(), ex);
    }
    return null;
  }
 private File getFile() throws IOException {
   File targetFolder = targetContainer.getLocation().toFile();
   StringBuilder filename = new StringBuilder();
   filename.append(targetFolder.getCanonicalPath());
   filename.append("\\Version");
   filename.append("\\versions");
   if (fileCount > 0) {
     filename.append(fileCount);
   }
   fileCount++;
   filename.append(".xls");
   return new File(filename.toString());
 }
 /**
  * Utility method for refreshing the current view on all relevant input and output folders. This
  * makes sure, that methods determining and moving files get the current workspace contents.
  *
  * @param monitor progress monitor
  * @throws CoreException if an error occurs
  */
 private void refreshView(IProgressMonitor monitor) throws CoreException {
   sourceDir.refreshLocal(IProject.DEPTH_INFINITE, monitor);
   if (outputDir != null
       && !sourceDir.getProjectRelativePath().isPrefixOf(outputDir.getProjectRelativePath())) {
     outputDir.refreshLocal(IProject.DEPTH_ONE, monitor);
   }
   if (tempDir != null
       && !sourceDir.getProjectRelativePath().isPrefixOf(tempDir.getProjectRelativePath())) {
     tempDir.refreshLocal(IProject.DEPTH_INFINITE, monitor);
   }
   if (!sourceDir.getLocation().equals(project.getLocation())) {
     project.refreshLocal(IProject.DEPTH_ONE, monitor);
   }
 }
Esempio n. 9
0
  /**
   * Gets the list of changed files that are underneath the given container.
   *
   * @param container
   * @return
   */
  protected List<ChangedFile> getChangedFilesForContainer(IContainer container) {
    if (container == null || container.getLocationURI() == null) {
      return Collections.emptyList();
    }

    List<ChangedFile> changedFiles = changedFiles();
    if (CollectionsUtil.isEmpty(changedFiles)) {
      return Collections.emptyList();
    }

    IPath resourcePath = container.getLocation();
    List<ChangedFile> filtered = new ArrayList<ChangedFile>();
    IPath workingDirectory = repository.workingDirectory();
    for (ChangedFile changedFile : changedFiles) {
      IPath fullPath = workingDirectory.append(changedFile.getPath()).makeAbsolute();
      if (resourcePath.isPrefixOf(fullPath)) {
        filtered.add(changedFile);
      }
    }

    return filtered;
  }
Esempio n. 10
0
  /**
   * Runs the pub command.
   *
   * @return the result of running the pub command
   */
  public IStatus runSilent(IProgressMonitor monitor) {
    try {
      // Build the process description to run pub
      DartSdk sdk = DartSdkManager.getManager().getSdk();
      File pubFile = sdk.getPubExecutable();

      ProcessBuilder builder = new ProcessBuilder();
      builder.directory(container.getLocation().toFile());
      builder.redirectErrorStream(true);

      List<String> args = new ArrayList<String>();
      if (DartCore.isMac()) {
        args.add("/bin/bash");
        args.add("--login");
        args.add("-c");
        args.add("\"" + pubFile.getAbsolutePath() + "\"" + " " + command);
      } else {
        args.add(pubFile.getAbsolutePath());
        args.add(command);
      }
      builder.command(args);

      // Run the pub command as an external process.
      ProcessRunner runner = newProcessRunner(builder);

      try {
        runner.runSync(monitor);
      } catch (IOException e) {
        String message = NLS.bind(PubMessages.RunPubJob_failed, command, e.toString());
        return new Status(IStatus.CANCEL, DartCore.PLUGIN_ID, message, e);
      }

      StringBuilder stringBuilder = new StringBuilder();

      if (!runner.getStdOut().isEmpty()) {
        stringBuilder.append(runner.getStdOut().trim() + "\n"); // $NON-NLS-1$
      }

      int exitCode = runner.getExitCode();

      if (exitCode != 0) {
        String output = "[" + exitCode + "] " + stringBuilder.toString();
        String message = NLS.bind(PubMessages.RunPubJob_failed, command, output);
        return new Status(IStatus.ERROR, DartCore.PLUGIN_ID, message);
      }

      try {
        // Refresh the Eclipse resources
        container.refreshLocal(IResource.DEPTH_INFINITE, monitor);
      } catch (CoreException e) {
        // Log the exception and move on
        DartCore.logError("Exception refreshing " + container, e);
      }

      return new Status(IStatus.OK, DartCore.PLUGIN_ID, stringBuilder.toString());
    } catch (OperationCanceledException exception) {
      String message = NLS.bind(PubMessages.RunPubJob_canceled, command);
      return new Status(IStatus.CANCEL, DartCore.PLUGIN_ID, message, exception);
    } finally {
      monitor.done();
    }
  }
  protected ILaunchConfiguration createLaunchConfiguration(IContainer basedir, String goal) {
    try {
      ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
      ILaunchConfigurationType launchConfigurationType =
          launchManager.getLaunchConfigurationType(
              MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);

      String launchSafeGoalName = goal.replace(':', '-');

      ILaunchConfigurationWorkingCopy workingCopy =
          launchConfigurationType.newInstance(
              null, //
              NLS.bind(
                  org.eclipse.m2e.internal.launch.Messages.ExecutePomAction_executing,
                  launchSafeGoalName,
                  basedir.getLocation().toString().replace('/', '-')));
      workingCopy.setAttribute(
          MavenLaunchConstants.ATTR_POM_DIR, basedir.getLocation().toOSString());
      workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, goal);
      workingCopy.setAttribute(ILaunchManager.ATTR_PRIVATE, true);
      workingCopy.setAttribute(
          RefreshUtil.ATTR_REFRESH_SCOPE, RefreshUtil.MEMENTO_SELECTED_PROJECT);
      workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_RECURSIVE, true);

      // seems no need refresh project, so won't set it.
      // workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
      // basedir.getProject().getName());

      // --------------Special settings for Talend----------
      if (isCaptureOutputInConsoleView()) {
        // by default will catch the output in console. so set null
        workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, (String) null);
      } else {
        workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, Boolean.FALSE.toString());
      }

      // not same, set it. Else use the preference directly.
      if (debugOutput != MavenPlugin.getMavenConfiguration().isDebugOutput()) {
        workingCopy.setAttribute(MavenLaunchConstants.ATTR_DEBUG_OUTPUT, this.debugOutput); // -X -e
      }

      // -Dmaven.test.skip=true -DskipTests
      workingCopy.setAttribute(MavenLaunchConstants.ATTR_SKIP_TESTS, this.skipTests);

      // ------------------------

      setProjectConfiguration(workingCopy, basedir);

      IPath path = getJREContainerPath(basedir);
      if (path != null) {
        workingCopy.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, path.toPortableString());
      }

      String programArgs = getArgumentValue(TalendProcessArgumentConstant.ARG_PROGRAM_ARGUMENTS);
      if (StringUtils.isNotEmpty(programArgs)) {
        workingCopy.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArgs);
      }

      // TODO when launching Maven with debugger consider to add the following property
      // -Dmaven.surefire.debug="-Xdebug
      // -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent
      // -Djava.compiler=NONE"

      return workingCopy;
    } catch (CoreException ex) {
      ExceptionHandler.process(ex);
    }
    return null;
  }
  private boolean createSequenceArtifact(TemplateModel sequenceModel) throws Exception {
    boolean isNewArtifact = true;
    IContainer location =
        project.getFolder(
            "src"
                + File.separator
                + "main"
                + File.separator
                + "synapse-config"
                + File.separator
                + "templates");
    esbProjectArtifact = new ESBProjectArtifact();
    esbProjectArtifact.fromFile(project.getFile("artifact.xml").getLocation().toFile());
    File pomfile = project.getFile("pom.xml").getLocation().toFile();
    getModel().getMavenInfo().setPackageName("synapse/template");
    if (!pomfile.exists()) {
      createPOM(pomfile);
    }

    updatePom();
    project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    String groupId = getMavenGroupId(pomfile);
    groupId += ".template";

    if (getModel().getSelectedOption().equals("import.template")) {
      IFile sequence = location.getFile(new Path(getModel().getImportFile().getName()));
      if (sequence.exists()) {
        if (!MessageDialog.openQuestion(
            getShell(), "WARNING", "Do you like to override exsiting project in the workspace")) {
          return false;
        }
        isNewArtifact = false;
      }
      copyImportFile(location, isNewArtifact, groupId);
    } else {
      String templateContent = "";
      String template = "";
      ArtifactTemplate selectedTemplate = templateModel.getSelectedTemplate();
      templateContent = FileUtils.getContentAsString(selectedTemplate.getTemplateDataStream());

      if (selectedTemplate.getName().equals("Address Endpoint Template")) {
        template = createEPTemplate(templateContent, "Address Endpoint Template");
      } else if (selectedTemplate.getName().equals("WSDL Endpoint Template")) {
        template = createEPTemplate(templateContent, "WSDL Endpoint Template");
      } else if (selectedTemplate.getName().equals("Default Endpoint Template")) {
        template = createEPTemplate(templateContent, "Default Endpoint Template");
      } else if (selectedTemplate.getName().equals("Sequence Template")) {
        template = createEPTemplate(templateContent, "Sequence Template");
      } else if (selectedTemplate.getName().equals("HTTP Endpoint Template")) {
        template = createEPTemplate(templateContent, "HTTP Endpoint Template");
      } else {
        template = createEPTemplate(templateContent, "");
      }

      File destFile =
          new File(location.getLocation().toFile(), sequenceModel.getTemplateName() + ".xml");
      FileUtils.createFile(destFile, template);
      fileLst.add(destFile);
      ESBArtifact artifact = new ESBArtifact();
      artifact.setName(sequenceModel.getTemplateName());
      artifact.setVersion(version);
      if ("Sequence Template".equals(selectedTemplate.getName())) {
        artifact.setType("synapse/sequenceTemplate");
      } else {
        artifact.setType("synapse/endpointTemplate");
      }
      artifact.setServerRole("EnterpriseServiceBus");
      artifact.setGroupId(groupId);
      artifact.setFile(
          FileUtils.getRelativePath(
                  project.getLocation().toFile(),
                  new File(
                      location.getLocation().toFile(), sequenceModel.getTemplateName() + ".xml"))
              .replaceAll(Pattern.quote(File.separator), "/"));
      esbProjectArtifact.addESBArtifact(artifact);
    }
    esbProjectArtifact.toFile();
    project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    return true;
  }
  private ILaunchConfiguration getLaunchConfiguration(IContainer basedir, String mode) {
    if (goalName != null) {
      return createLaunchConfiguration(basedir, goalName);
    }

    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType =
        launchManager.getLaunchConfigurationType(MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);

    // scan existing launch configurations
    IPath basedirLocation = basedir.getLocation();
    if (!showDialog) {
      try {
        //        ILaunch[] launches = launchManager.getLaunches();
        //        ILaunchConfiguration[] launchConfigurations = null;
        //        if(launches.length > 0) {
        //          for(int i = 0; i < launches.length; i++ ) {
        //            ILaunchConfiguration config = launches[i].getLaunchConfiguration();
        //            if(config != null && launchConfigurationType.equals(config.getType())) {
        //              launchConfigurations = new ILaunchConfiguration[] {config};
        //            }
        //          }
        //        }
        //        if(launchConfigurations == null) {
        //          launchConfigurations =
        // launchManager.getLaunchConfigurations(launchConfigurationType);
        //        }

        ILaunchConfiguration[] launchConfigurations =
            launchManager.getLaunchConfigurations(launchConfigurationType);
        ArrayList<ILaunchConfiguration> matchingConfigs = new ArrayList<ILaunchConfiguration>();
        for (ILaunchConfiguration configuration : launchConfigurations) {
          // substitute variables
          String workDir =
              LaunchingUtils.substituteVar(
                  configuration.getAttribute(MavenLaunchConstants.ATTR_POM_DIR, (String) null));
          if (workDir == null) {
            continue;
          }
          IPath workPath = new Path(workDir);
          if (basedirLocation.equals(workPath)) {
            matchingConfigs.add(configuration);
          }
        }

        if (matchingConfigs.size() == 1) {
          log.info("Using existing launch configuration");
          return matchingConfigs.get(0);
        } else if (matchingConfigs.size() > 1) {
          final IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
          ElementListSelectionDialog dialog =
              new ElementListSelectionDialog(
                  getShell(), //
                  new ILabelProvider() {
                    public Image getImage(Object element) {
                      return labelProvider.getImage(element);
                    }

                    public String getText(Object element) {
                      if (element instanceof ILaunchConfiguration) {
                        ILaunchConfiguration configuration = (ILaunchConfiguration) element;
                        try {
                          return labelProvider.getText(element)
                              + " : "
                              + configuration.getAttribute(MavenLaunchConstants.ATTR_GOALS, "");
                        } catch (CoreException ex) {
                          // ignore
                        }
                      }
                      return labelProvider.getText(element);
                    }

                    public boolean isLabelProperty(Object element, String property) {
                      return labelProvider.isLabelProperty(element, property);
                    }

                    public void addListener(ILabelProviderListener listener) {
                      labelProvider.addListener(listener);
                    }

                    public void removeListener(ILabelProviderListener listener) {
                      labelProvider.removeListener(listener);
                    }

                    public void dispose() {
                      labelProvider.dispose();
                    }
                  });
          dialog.setElements(
              matchingConfigs.toArray(new ILaunchConfiguration[matchingConfigs.size()]));
          dialog.setTitle(Messages.ExecutePomAction_dialog_title);
          if (mode.equals(ILaunchManager.DEBUG_MODE)) {
            dialog.setMessage(Messages.ExecutePomAction_dialog_debug_message);
          } else {
            dialog.setMessage(Messages.ExecutePomAction_dialog_run_message);
          }
          dialog.setMultipleSelection(false);
          int result = dialog.open();
          labelProvider.dispose();
          return result == Window.OK ? (ILaunchConfiguration) dialog.getFirstResult() : null;
        }

      } catch (CoreException ex) {
        log.error(ex.getMessage(), ex);
      }
    }

    log.info("Creating new launch configuration");

    String newName =
        launchManager.generateUniqueLaunchConfigurationNameFrom(basedirLocation.lastSegment());
    try {
      ILaunchConfigurationWorkingCopy workingCopy =
          launchConfigurationType.newInstance(null, newName);
      workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, basedirLocation.toString());

      setProjectConfiguration(workingCopy, basedir);

      // set other defaults if needed
      // MavenLaunchMainTab maintab = new MavenLaunchMainTab();
      // maintab.setDefaults(workingCopy);
      // maintab.dispose();

      return workingCopy.doSave();
    } catch (Exception ex) {
      log.error("Error creating new launch configuration", ex);
    }
    return null;
  }
 public SimpleResourceMapImpl(IContainer container, AnalysisContext context) {
   this.container = container;
   this.containerLocation = container.getLocation();
   this.context = context;
   this.contentCache = context.getSourceFactory().getContentCache();
 }