Search in sources :

Example 41 with Path

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;
}
Also used : Path(org.eclipse.che.ide.resource.Path) JsonArray(elemental.json.JsonArray) Node(org.eclipse.che.ide.api.data.tree.Node) ResourceNode(org.eclipse.che.ide.resources.tree.ResourceNode) ArrayList(java.util.ArrayList) JsonObject(elemental.json.JsonObject) ArrayList(java.util.ArrayList) List(java.util.List) ResourceNode(org.eclipse.che.ide.resources.tree.ResourceNode)

Example 42 with Path

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);
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) 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) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 43 with Path

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();
}
Also used : Path(org.eclipse.che.ide.resource.Path) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) 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) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 44 with Path

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;
            }
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) ExternalResourceDelta(org.eclipse.che.ide.api.resources.ExternalResourceDelta) FileContentUpdateEvent(org.eclipse.che.ide.api.event.FileContentUpdateEvent) FileWatcherEventType(org.eclipse.che.api.project.shared.dto.event.FileWatcherEventType)

Example 45 with Path

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());
        });
    });
}
Also used : AsyncPromiseHelper.createFromAsyncRequest(org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest) AsyncRequestFactory(org.eclipse.che.ide.rest.AsyncRequestFactory) NewProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.NewProjectConfigDto) Inject(com.google.inject.Inject) RequestCallback(org.eclipse.che.ide.websocket.rest.RequestCallback) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) DELETE(com.google.gwt.http.client.RequestBuilder.DELETE) Promise(org.eclipse.che.api.promises.client.Promise) AppContext(org.eclipse.che.ide.api.app.AppContext) Map(java.util.Map) URL(com.google.gwt.http.client.URL) Message(org.eclipse.che.ide.websocket.Message) MessageBuilder(org.eclipse.che.ide.websocket.MessageBuilder) CONTENT_TYPE(org.eclipse.che.ide.rest.HTTPHeader.CONTENT_TYPE) DtoUnmarshallerFactory(org.eclipse.che.ide.rest.DtoUnmarshallerFactory) DtoFactory(org.eclipse.che.ide.dto.DtoFactory) LoaderFactory(org.eclipse.che.ide.ui.loaders.request.LoaderFactory) CONTENTTYPE(org.eclipse.che.ide.rest.HTTPHeader.CONTENTTYPE) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) APPLICATION_JSON(org.eclipse.che.ide.MimeType.APPLICATION_JSON) WsAgentStateController(org.eclipse.che.ide.api.machine.WsAgentStateController) StringUnmarshaller(org.eclipse.che.ide.rest.StringUnmarshaller) SourceStorageDto(org.eclipse.che.api.workspace.shared.dto.SourceStorageDto) TreeElement(org.eclipse.che.api.project.shared.dto.TreeElement) MoveOptions(org.eclipse.che.api.project.shared.dto.MoveOptions) PUT(com.google.gwt.http.client.RequestBuilder.PUT) ItemReference(org.eclipse.che.api.project.shared.dto.ItemReference) POST(com.google.gwt.http.client.RequestBuilder.POST) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException) List(java.util.List) CopyOptions(org.eclipse.che.api.project.shared.dto.CopyOptions) MimeType(org.eclipse.che.ide.MimeType) ACCEPT(org.eclipse.che.ide.rest.HTTPHeader.ACCEPT) SourceEstimation(org.eclipse.che.api.project.shared.dto.SourceEstimation) Path(org.eclipse.che.ide.resource.Path) UrlBuilder(org.eclipse.che.ide.rest.UrlBuilder) Message(org.eclipse.che.ide.websocket.Message) MessageBuilder(org.eclipse.che.ide.websocket.MessageBuilder) RequestCallback(org.eclipse.che.ide.websocket.rest.RequestCallback) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException)

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