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));
}
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();
}
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();
}
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));
}
}
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;
}
Aggregations