Search in sources :

Example 46 with Path

use of org.eclipse.che.ide.resource.Path in project che by eclipse.

the class GitServiceClientImpl method commit.

@Override
public Promise<Revision> commit(DevMachine devMachine, Path project, String message, boolean all, Path[] files, boolean amend) {
    List<String> paths = new ArrayList<>(files.length);
    for (Path file : files) {
        if (!file.isEmpty()) {
            paths.add(file.toString());
        }
    }
    CommitRequest commitRequest = dtoFactory.createDto(CommitRequest.class).withMessage(message).withAmend(amend).withAll(all).withFiles(paths);
    String url = devMachine.getWsAgentBaseUrl() + COMMIT + "?projectPath=" + project;
    return asyncRequestFactory.createPostRequest(url, commitRequest).loader(loader).send(dtoUnmarshallerFactory.newUnmarshaller(Revision.class));
}
Also used : Path(org.eclipse.che.ide.resource.Path) CommitRequest(org.eclipse.che.api.git.shared.CommitRequest) Revision(org.eclipse.che.api.git.shared.Revision) ArrayList(java.util.ArrayList)

Example 47 with Path

use of org.eclipse.che.ide.resource.Path in project che by eclipse.

the class RenameItemAction method actionPerformed.

/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
    final Resource resource = appContext.getResource();
    checkState(resource != null, "Null resource occurred");
    final String resourceName = resource.getName();
    final int selectionLength = resourceName.indexOf('.') >= 0 ? resourceName.lastIndexOf('.') : resourceName.length();
    final InputValidator validator;
    final String dialogTitle;
    if (resource.getResourceType() == FILE) {
        validator = new FileNameValidator(resourceName);
        dialogTitle = localization.renameFileDialogTitle(resourceName);
    } else if (resource.getResourceType() == FOLDER) {
        validator = new FolderNameValidator(resourceName);
        dialogTitle = localization.renameFolderDialogTitle(resourceName);
    } else if (resource.getResourceType() == PROJECT) {
        validator = new ProjectNameValidator(resourceName);
        dialogTitle = localization.renameProjectDialogTitle(resourceName);
    } else {
        throw new IllegalStateException("Not a resource");
    }
    final InputCallback inputCallback = new InputCallback() {

        @Override
        public void accepted(final String value) {
            //we shouldn't perform renaming file with the same name
            if (!value.trim().equals(resourceName)) {
                closeRelatedEditors(resource);
                final Path destination = resource.getLocation().parent().append(value);
                resource.move(destination).catchError(new Operation<PromiseError>() {

                    @Override
                    public void apply(PromiseError arg) throws OperationException {
                        notificationManager.notify("", arg.getMessage(), FAIL, EMERGE_MODE);
                    }
                });
            }
        }
    };
    InputDialog inputDialog = dialogFactory.createInputDialog(dialogTitle, localization.renameDialogNewNameLabel(), resource.getName(), 0, selectionLength, inputCallback, null);
    inputDialog.withValidator(validator);
    inputDialog.show();
}
Also used : Path(org.eclipse.che.ide.resource.Path) InputDialog(org.eclipse.che.ide.api.dialogs.InputDialog) InputCallback(org.eclipse.che.ide.api.dialogs.InputCallback) Resource(org.eclipse.che.ide.api.resources.Resource) InputValidator(org.eclipse.che.ide.api.dialogs.InputValidator) PromiseError(org.eclipse.che.api.promises.client.PromiseError) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 48 with Path

use of org.eclipse.che.ide.resource.Path in project che by eclipse.

the class GitServiceClientImpl method reset.

@Override
public Promise<Void> reset(DevMachine devMachine, Path project, String commit, ResetRequest.ResetType resetType, Path[] files) {
    ResetRequest resetRequest = dtoFactory.createDto(ResetRequest.class).withCommit(commit);
    if (resetType != null) {
        resetRequest.setType(resetType);
    }
    if (files != null) {
        List<String> fileList = new ArrayList<>(files.length);
        for (Path file : files) {
            fileList.add(file.isEmpty() ? "." : file.toString());
        }
        resetRequest.setFilePattern(fileList);
    }
    String url = devMachine.getWsAgentBaseUrl() + RESET + "?projectPath=" + project;
    return asyncRequestFactory.createPostRequest(url, resetRequest).loader(loader).send();
}
Also used : Path(org.eclipse.che.ide.resource.Path) ArrayList(java.util.ArrayList) ResetRequest(org.eclipse.che.api.git.shared.ResetRequest)

Example 49 with Path

use of org.eclipse.che.ide.resource.Path in project che by eclipse.

the class GitServiceClientImpl method log.

@Override
public Promise<LogResponse> log(DevMachine devMachine, Path project, Path[] fileFilter, int skip, int maxCount, boolean plainText) {
    StringBuilder params = new StringBuilder().append("?projectPath=").append(project.toString());
    if (fileFilter != null) {
        for (Path file : fileFilter) {
            params.append("&fileFilter=").append(file.toString());
        }
    }
    params.append("&skip=").append(skip);
    params.append("&maxCount=").append(maxCount);
    String url = appContext.getDevMachine().getWsAgentBaseUrl() + LOG + params;
    if (plainText) {
        return asyncRequestFactory.createGetRequest(url).send(dtoUnmarshallerFactory.newUnmarshaller(LogResponse.class));
    } else {
        return asyncRequestFactory.createGetRequest(url).header(ACCEPT, APPLICATION_JSON).send(dtoUnmarshallerFactory.newUnmarshaller(LogResponse.class));
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) LogResponse(org.eclipse.che.api.git.shared.LogResponse)

Example 50 with Path

use of org.eclipse.che.ide.resource.Path in project che by eclipse.

the class RemoveFromIndexPresenter method toRelativePaths.

protected Path[] toRelativePaths(Resource[] resources) {
    final Path[] paths = new Path[resources.length];
    for (int i = 0; i < resources.length; i++) {
        checkState(project.getLocation().isPrefixOf(resources[i].getLocation()));
        final Path tmpPath = resources[i].getLocation().removeFirstSegments(project.getLocation().segmentCount());
        paths[i] = tmpPath.isEmpty() ? tmpPath.append(".") : tmpPath;
    }
    return paths;
}
Also used : Path(org.eclipse.che.ide.resource.Path)

Aggregations

Path (org.eclipse.che.ide.resource.Path)72 Resource (org.eclipse.che.ide.api.resources.Resource)27 Operation (org.eclipse.che.api.promises.client.Operation)15 OperationException (org.eclipse.che.api.promises.client.OperationException)15 PromiseError (org.eclipse.che.api.promises.client.PromiseError)13 ArrayList (java.util.ArrayList)11 Project (org.eclipse.che.ide.api.resources.Project)11 Promise (org.eclipse.che.api.promises.client.Promise)10 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)10 List (java.util.List)8 Test (org.junit.Test)7 ResourceDelta (org.eclipse.che.ide.api.resources.ResourceDelta)6 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)6 Optional (com.google.common.base.Optional)5 Function (org.eclipse.che.api.promises.client.Function)5 FunctionException (org.eclipse.che.api.promises.client.FunctionException)5 Container (org.eclipse.che.ide.api.resources.Container)5 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)5 HashMap (java.util.HashMap)4 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)4