Пример #1
0
  private IJavaProject chooseJavaProject() {
    IJavaProject[] projects;
    try {
      projects = JavaCore.create(getWorkspaceRoot()).getJavaProjects();
    } catch (JavaModelException e) {
      EasybLaunchActivator.getDefault().getLog().log(e.getStatus());
      projects = new IJavaProject[0];
    }

    ILabelProvider labelProvider =
        new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
    ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
    dialog.setTitle("Projects");
    dialog.setMessage("Please choose a project");
    dialog.setElements(projects);

    IJavaProject javaProject = getJavaProject();
    if (javaProject != null) {
      dialog.setInitialSelections(new Object[] {javaProject});
    }
    if (dialog.open() == Window.OK) {
      return (IJavaProject) dialog.getFirstResult();
    }
    return null;
  }
Пример #2
0
  @Override
  public void performApply(ILaunchConfigurationWorkingCopy config) {
    config.setAttribute(
        IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
        StringUtils.trimToEmpty(txtProject.getText()));

    try {
      List<String> stories = getStoriesFullPaths();
      config.setAttribute(ILaunchConstants.LAUNCH_ATTR_STORIES_FULL_PATH, stories);
    } catch (CoreException cex) {
      EasybLaunchActivator.Log(
          "Unable apply configuration due to exception while retrieving story locations", cex);
      setErrorMessage(
          "Unable apply configuration due to exception while retrieving story locations");
    }

    if (container != null) {
      config.setAttribute(
          ILaunchConstants.LAUNCH_ATTR_CONTAINER_HANDLE, container.getHandleIdentifier());
    }

    if (storyFile != null) {
      config.setAttribute(
          ILaunchConstants.LAUNCH_ATTR_STORY_PATH,
          storyFile.getProjectRelativePath().toPortableString());
    }

    config.setAttribute(
        ILaunchConstants.LAUNCH_ATTR_IS_SINGLE_STORY, btnRadioSingleStory.getSelection());
  }
Пример #3
0
  @Override
  public void setDefaults(ILaunchConfigurationWorkingCopy config) {

    IProject proj = EasybLaunchActivator.getDefault().getSelectedProject();

    if (proj != null) {
      config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, proj.getName());
    }
  }
Пример #4
0
  @Override
  public void initializeFrom(ILaunchConfiguration config) {

    try {
      txtProject.setText(
          config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""));
    } catch (CoreException ce) {
      EasybLaunchActivator.Log("Unable to set project name for launch", ce);
      setErrorMessage("Unable to set project from configuration");
    }

    initialiseStoriesfromConfiguration(config);
  }
Пример #5
0
  private IFile chooseStory() {
    try {
      IJavaProject javaProject = getJavaProject();
      IFile[] files = BehaviourSearch.findStoryFiles(javaProject.getResource());

      BehaviourElementSelectorDialog dialog = new BehaviourElementSelectorDialog(getShell(), files);

      dialog.setTitle("Stories");
      dialog.setMessage("Choose a story");

      if (dialog.open() == Window.OK) {
        Object element = dialog.getFirstResult();
        return (IFile) element;
      }
    } catch (CoreException cex) {
      EasybLaunchActivator.Log("Unable to locate storys for story browse", cex);
      setErrorMessage("Unable to locate storys for story browse");
    }

    return null;
  }
Пример #6
0
  protected void initialiseStoriesfromConfiguration(ILaunchConfiguration config) {

    try {
      String containerHandle =
          config.getAttribute(ILaunchConstants.LAUNCH_ATTR_CONTAINER_HANDLE, "");

      if (!StringUtils.isBlank(containerHandle)) {
        container = JavaCore.create(containerHandle);
        txtMultiStories.setText(container.getElementName());
      }

    } catch (CoreException ce) {
      EasybLaunchActivator.Log("Unable to set project,resource or package name for launch", ce);
      setErrorMessage("Unable to set project,folder or package for stories from configuration");
    }

    try {
      String storyProjectPath = config.getAttribute(ILaunchConstants.LAUNCH_ATTR_STORY_PATH, "");

      IPath path = null;
      if (!StringUtils.isBlank(storyProjectPath)) {
        path = Path.fromPortableString(storyProjectPath);
      }

      IJavaProject javaProject = getJavaProject();

      if (javaProject != null) {
        IProject project = javaProject.getProject();
        if (project.findMember(path) instanceof IFile) {
          storyFile = (IFile) project.findMember(path);
        } else {
          setErrorMessage("Unable to locate " + storyProjectPath + " in project");
        }
      } else {
        setErrorMessage("No project has been set for story");
      }

      if (storyFile != null) {
        txtStory.setText(storyFile.getName());
      } else if (!StringUtils.isBlank(storyProjectPath)) {
        txtStory.setText(storyProjectPath);
      }

    } catch (CoreException ce) {
      EasybLaunchActivator.Log("Unable to set story for launch", ce);
      setErrorMessage("Unable to set story for launch");
    }

    try {
      boolean isSingleStory =
          config.getAttribute(ILaunchConstants.LAUNCH_ATTR_IS_SINGLE_STORY, true);
      setEnableSingleStory(isSingleStory);
      setEnableProject(isSingleStory);
      setEnableMultiStory(!isSingleStory);

      btnRadioSingleStory.setSelection(isSingleStory);
      btnRadioMultiStory.setSelection(!isSingleStory);

    } catch (CoreException ce) {
      EasybLaunchActivator.Log("Unable to set single or multi story radio buttons", ce);
      setErrorMessage("Unable to set single or multi story radio buttons");
    }
  }