Ejemplo n.º 1
0
  @Override
  public void actionPerformed(ActionEvent e) {
    final Resource resource = appContext.getResource();

    checkState(resource instanceof Container, "Parent should be a container");

    final Optional<Project> project = resource.getRelatedProject();

    checkState(project.isPresent());

    classpathService
        .getClasspath(project.get().getLocation().toString())
        .then(
            new Operation<List<ClasspathEntryDto>>() {
              @Override
              public void apply(List<ClasspathEntryDto> arg) throws OperationException {
                classpathResolver.resolveClasspathEntries(arg);
                classpathResolver.getSources().add(resource.getLocation().toString());
                classpathResolver.updateClasspath();
              }
            })
        .catchError(
            new Operation<PromiseError>() {
              @Override
              public void apply(PromiseError arg) throws OperationException {
                notificationManager.notify(
                    "Can't get classpath", arg.getMessage(), FAIL, EMERGE_MODE);
              }
            });
  }
Ejemplo n.º 2
0
  /**
   * Shows dialog which contains information about file fqn and path calculated from passed element.
   *
   * @param resource element for which fqn and path will be calculated
   */
  public void show(Resource resource) {
    final Optional<Project> project = resource.getRelatedProject();

    if (project.isPresent()) {
      final FqnProvider provider = providers.get(project.get().getType());

      try {
        view.show(provider.getFqn(resource), resource.getLocation());
      } catch (RuntimeException e) {
        view.show("", resource.getLocation());
      }
    }
  }
  private void loadBuildConfig() {
    final Resource resource = appContext.getResource();
    if (resource == null) {
      return;
    }
    final Optional<Project> project = resource.getRelatedProject();

    if (project.isPresent()) {
      String namespace = project.get().getAttribute(OPENSHIFT_NAMESPACE_VARIABLE_NAME);
      String application = project.get().getAttribute(OPENSHIFT_APPLICATION_VARIABLE_NAME);

      service.getBuildConfigs(namespace, application).then(showBuildConfigs()).catchError(onFail());
    }
  }
Ejemplo n.º 4
0
  @Override
  public void updateInPerspective(ActionEvent e) {
    final Resource[] resources = appContext.getResources();

    if (resources == null || resources.length != 1) {
      e.getPresentation().setEnabledAndVisible(false);
      return;
    }

    Resource resource = resources[0];
    final boolean inJavaProject = isJavaProject(resource.getRelatedProject().get());

    e.getPresentation()
        .setEnabledAndVisible(
            inJavaProject
                && resource.isFolder()
                && !resource.getMarker(SourceFolderMarker.ID).isPresent());
  }