Search in sources :

Example 86 with Project

use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.

the class ResetToCommitAction method actionPerformed.

/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
    final Project project = appContext.getRootProject();
    checkState(project != null, "Null project occurred");
    presenter.showDialog(project);
}
Also used : Project(org.eclipse.che.ide.api.resources.Project)

Example 87 with Project

use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.

the class ShowBranchesAction method actionPerformed.

/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
    final Project project = appContext.getRootProject();
    checkState(project != null, "Null project occurred");
    presenter.showBranches(project);
}
Also used : Project(org.eclipse.che.ide.api.resources.Project)

Example 88 with Project

use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.

the class PomInterceptor method intercept.

/** {@inheritDoc} */
@Override
public void intercept(Resource resource) {
    if (resource.isFile() && POM_XML.equals(resource.getName())) {
        final Optional<Project> project = resource.getRelatedProject();
        if (!project.isPresent() || !project.get().isTypeOf(MAVEN_ID)) {
            return;
        }
        final String artifact = project.get().getAttribute(ARTIFACT_ID);
        if (!isNullOrEmpty(artifact)) {
            resource.addMarker(new PresentableTextMarker(artifact));
        }
    }
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PresentableTextMarker(org.eclipse.che.ide.api.resources.marker.PresentableTextMarker)

Example 89 with Project

use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.

the class OrganizeImportsPresenter method onFinishButtonClicked.

/** {@inheritDoc} */
@Override
public void onFinishButtonClicked() {
    selected.put(page, view.getSelectedImport());
    ConflictImportDTO result = dtoFactory.createDto(ConflictImportDTO.class).withTypeMatches(new ArrayList<>(selected.values()));
    if (file instanceof Resource) {
        final Optional<Project> project = ((Resource) file).getRelatedProject();
        javaCodeAssistClient.applyChosenImports(project.get().getLocation().toString(), JavaUtil.resolveFQN(file), result).then(new Operation<List<Change>>() {

            @Override
            public void apply(List<Change> result) throws OperationException {
                applyChanges(((TextEditor) editor).getDocument(), result);
                view.hide();
                ((TextEditor) editor).setFocus();
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                String title = locale.failedToProcessOrganizeImports();
                String message = arg.getMessage();
                notificationManager.notify(title, message, FAIL, FLOAT_MODE);
            }
        });
    }
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Change(org.eclipse.che.ide.ext.java.shared.dto.Change) Project(org.eclipse.che.ide.api.resources.Project) ConflictImportDTO(org.eclipse.che.ide.ext.java.shared.dto.ConflictImportDTO) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) List(java.util.List) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 90 with Project

use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.

the class ClasspathResolver method updateClasspath.

/** Concatenates classpath entries and update classpath file. */
public Promise<Void> updateClasspath() {
    final Resource resource = appContext.getResource();
    checkState(resource != null);
    final Optional<Project> optProject = resource.getRelatedProject();
    checkState(optProject.isPresent());
    final List<ClasspathEntryDto> entries = new ArrayList<>();
    for (String path : libs) {
        entries.add(dtoFactory.createDto(ClasspathEntryDto.class).withPath(path).withEntryKind(LIBRARY));
    }
    for (ClasspathEntryDto container : containers) {
        entries.add(container);
    }
    for (String path : sources) {
        entries.add(dtoFactory.createDto(ClasspathEntryDto.class).withPath(path).withEntryKind(SOURCE));
    }
    for (String path : projects) {
        entries.add(dtoFactory.createDto(ClasspathEntryDto.class).withPath(path).withEntryKind(PROJECT));
    }
    final Project project = optProject.get();
    Promise<Void> promise = classpathUpdater.setRawClasspath(project.getLocation().toString(), entries);
    promise.then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            project.synchronize().then(new Operation<Resource[]>() {

                @Override
                public void apply(Resource[] arg) throws OperationException {
                    eventBus.fireEvent(new ClasspathChangedEvent(project.getLocation().toString(), entries));
                }
            });
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            notificationManager.notify("Problems with updating classpath", arg.getMessage(), FAIL, EMERGE_MODE);
        }
    });
    return promise;
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) ArrayList(java.util.ArrayList) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

Project (org.eclipse.che.ide.api.resources.Project)127 Resource (org.eclipse.che.ide.api.resources.Resource)74 OperationException (org.eclipse.che.api.promises.client.OperationException)53 Operation (org.eclipse.che.api.promises.client.Operation)51 PromiseError (org.eclipse.che.api.promises.client.PromiseError)48 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)24 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)18 Promise (org.eclipse.che.api.promises.client.Promise)16 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)14 Container (org.eclipse.che.ide.api.resources.Container)14 List (java.util.List)12 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)12 Path (org.eclipse.che.ide.resource.Path)12 Optional (com.google.common.base.Optional)11 ArrayList (java.util.ArrayList)10 File (org.eclipse.che.ide.api.resources.File)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10 FunctionException (org.eclipse.che.api.promises.client.FunctionException)9 JavaUtil.isJavaProject (org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject)9 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)8