Search in sources :

Example 11 with Project

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

the class SubversionAction method updateInPerspective.

@Override
public void updateInPerspective(@NotNull ActionEvent event) {
    event.getPresentation().setVisible(true);
    final Project project = appContext.getRootProject();
    event.getPresentation().setEnabled(project != null && SvnUtil.isUnderSvn(project));
}
Also used : Project(org.eclipse.che.ide.api.resources.Project)

Example 12 with Project

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

the class CleanupPresenter method cleanup.

public void cleanup() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    service.cleanup(project.getLocation(), toRelative(project, resources)).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse result) throws OperationException {
            printResponse(result.getCommand(), result.getOutput(), result.getErrOutput(), constants.commandCleanup());
            notificationManager.notify(constants.cleanupSuccessful());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(constants.cleanupFailed() + ": " + error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 13 with Project

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

the class CommitPresenter method loadAllChanges.

private void loadAllChanges() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    service.status(project.getLocation(), new Path[0], null, false, false, false, true, false, null).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            List<StatusItem> statusItems = parseChangesList(response);
            view.setChangesList(statusItems);
            view.onShow();
            cache.put(Changes.ALL, statusItems);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            Log.error(CommitPresenter.class, error.getMessage());
        }
    });
}
Also used : StatusItem(org.eclipse.che.plugin.svn.shared.StatusItem) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 14 with Project

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

the class CommitPresenter method showDiff.

/** {@inheritDoc} */
@Override
public void showDiff(final String path) {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {

        @Override
        public Promise<CLIOutputResponse> perform(Credentials credentials) {
            return service.showDiff(project.getLocation(), new Path[] { valueOf(path) }, "HEAD", credentials);
        }
    }, null).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            String content = Joiner.on('\n').join(response.getOutput());
            diffViewerPresenter.showDiff(content);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Operation(org.eclipse.che.api.promises.client.Operation) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 15 with Project

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

the class ResourceManager method importProject.

protected Promise<Project> importProject(final Project.ProjectRequest importRequest) {
    checkArgument(checkProjectName(importRequest.getBody().getName()), "Invalid project name");
    checkNotNull(importRequest.getBody().getSource(), "Null source configuration occurred");
    final Path path = Path.valueOf(importRequest.getBody().getPath());
    return findResource(path, true).thenPromise(new Function<Optional<Resource>, Promise<Project>>() {

        @Override
        public Promise<Project> apply(final Optional<Resource> resource) throws FunctionException {
            final SourceStorage sourceStorage = importRequest.getBody().getSource();
            final SourceStorageDto sourceStorageDto = dtoFactory.createDto(SourceStorageDto.class).withType(sourceStorage.getType()).withLocation(sourceStorage.getLocation()).withParameters(sourceStorage.getParameters());
            return ps.importProject(path, sourceStorageDto).thenPromise(new Function<Void, Promise<Project>>() {

                @Override
                public Promise<Project> apply(Void ignored) throws FunctionException {
                    return ps.getProject(path).then(new Function<ProjectConfigDto, Project>() {

                        @Override
                        public Project apply(ProjectConfigDto config) throws FunctionException {
                            cachedConfigs = add(cachedConfigs, config);
                            Resource project = resourceFactory.newProjectImpl(config, ResourceManager.this);
                            checkState(project != null, "Failed to locate imported project's configuration");
                            store.register(project);
                            eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, (resource.isPresent() ? UPDATED : ADDED) | DERIVED)));
                            return (Project) project;
                        }
                    });
                }
            });
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) Optional(com.google.common.base.Optional) NewProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.NewProjectConfigDto) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) Resource(org.eclipse.che.ide.api.resources.Resource) FunctionException(org.eclipse.che.api.promises.client.FunctionException) Promise(org.eclipse.che.api.promises.client.Promise) Function(org.eclipse.che.api.promises.client.Function) Project(org.eclipse.che.ide.api.resources.Project) SourceStorage(org.eclipse.che.api.core.model.project.SourceStorage) SourceStorageDto(org.eclipse.che.api.workspace.shared.dto.SourceStorageDto) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent)

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