use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ProjectExplorerStateComponent method getState.
@Override
public JsonObject getState() {
final List<Path> paths = new ArrayList<>();
outer: for (Node node : projectExplorer.getTree().getNodeStorage().getAll()) {
if (projectExplorer.getTree().isExpanded(node) && node instanceof ResourceNode) {
final List<Node> childrenToStore = projectExplorer.getTree().getNodeStorage().getChildren(node);
for (Node children : childrenToStore) {
if (children instanceof ResourceNode) {
paths.add(((ResourceNode) children).getData().getLocation());
continue outer;
}
}
}
}
JsonObject state = Json.createObject();
JsonArray array = Json.createArray();
state.put(PATH_PARAM_ID, array);
int i = 0;
for (Path path : paths) {
array.set(i++, path.toString());
}
state.put(SHOW_HIDDEN_FILES, projectExplorer.isShowHiddenFiles());
return state;
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class CopyPresenter method onCopyClicked.
/** {@inheritDoc} */
@Override
public void onCopyClicked() {
final Project project = appContext.getRootProject();
Preconditions.checkState(project != null);
final Path src = view.isSourceCheckBoxSelected() ? Path.valueOf(view.getSourcePath()) : toRelative(project, sourceNode);
final Path target = view.isTargetCheckBoxSelected() ? Path.valueOf(view.getTargetUrl()) : toRelative(project, this.target);
final String comment = view.isTargetCheckBoxSelected() ? view.getComment() : null;
final StatusNotification notification = new StatusNotification(constants.copyNotificationStarted(src.toString()), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
view.hide();
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {
@Override
public Promise<CLIOutputResponse> perform(Credentials credentials) {
notification.setStatus(PROGRESS);
notification.setTitle(constants.copyNotificationStarted(src.toString()));
return service.copy(project.getLocation(), src, target, comment, credentials);
}
}, notification).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandCopy());
notification.setTitle(constants.copyNotificationSuccessful());
notification.setStatus(SUCCESS);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notification.setTitle(constants.copyNotificationFailed());
notification.setStatus(FAIL);
}
});
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class MovePresenter method onMoveClicked.
/** {@inheritDoc} */
@Override
public void onMoveClicked() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Path source = getSource();
final String comment = view.isURLSelected() ? view.getComment() : null;
final StatusNotification notification = new StatusNotification(locale.moveNotificationStarted(source.toString()), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {
@Override
public Promise<CLIOutputResponse> perform(Credentials credentials) {
notification.setStatus(PROGRESS);
notification.setTitle(locale.moveNotificationStarted(source.toString()));
return service.move(project.getLocation(), source, getTarget(), comment, credentials);
}
}, notification).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
notification.setTitle(locale.moveNotificationSuccessful());
notification.setStatus(SUCCESS);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notification.setTitle(locale.moveNotificationFailed());
notification.setStatus(FAIL);
}
});
view.onClose();
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class EditorFileStatusNotificationOperation method apply.
public void apply(String endpointId, FileStateUpdateDto params) {
final FileWatcherEventType status = params.getType();
final String stringPath = params.getPath();
final String name = stringPath.substring(stringPath.lastIndexOf("/") + 1);
switch(status) {
case MODIFIED:
{
Log.debug(getClass(), "Received updated file event status: " + stringPath);
eventBus.fireEvent(new FileContentUpdateEvent(stringPath, params.getHashCode()));
break;
}
case DELETED:
{
Log.debug(getClass(), "Received removed file event status: " + stringPath);
final Path path = Path.valueOf(stringPath);
appContext.getWorkspaceRoot().synchronize(new ExternalResourceDelta(path, path, REMOVED));
if (notificationManager != null && !deletedFilesController.remove(stringPath)) {
notificationManager.notify("External operation", "File '" + name + "' is removed", SUCCESS, EMERGE_MODE);
}
break;
}
}
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ProjectServiceClientImpl method importProject.
/** {@inheritDoc} */
@Override
public Promise<Void> importProject(final Path path, final SourceStorageDto source) {
return createFromAsyncRequest(callback -> {
final String url = PROJECT + IMPORT + path(path.toString());
final Message message = new MessageBuilder(POST, url).data(dtoFactory.toJson(source)).header(CONTENTTYPE, APPLICATION_JSON).build();
wsAgentStateController.getMessageBus().then(messageBus -> {
try {
messageBus.send(message, new RequestCallback<Void>() {
@Override
protected void onSuccess(Void result) {
callback.onSuccess(result);
}
@Override
protected void onFailure(Throwable exception) {
callback.onFailure(exception);
}
});
} catch (WebSocketException e) {
callback.onFailure(e);
}
}).catchError(error -> {
callback.onFailure(error.getCause());
});
});
}
Aggregations