Search in sources :

Example 6 with WebSocketException

use of org.eclipse.che.ide.websocket.WebSocketException in project che by eclipse.

the class NavigateToFilePresenter method onFileNameChanged.

@Override
public void onFileNameChanged(String fileName) {
    if (fileName.isEmpty()) {
        view.showItems(new ArrayList<ItemReference>());
        return;
    }
    // add '*' to allow search files by first letters
    final String url = SEARCH_URL + "/?name=" + URL.encodePathSegment(fileName + "*");
    final Message message = new MessageBuilder(GET, url).header(ACCEPT, APPLICATION_JSON).build();
    final Unmarshallable<List<ItemReference>> unmarshaller = dtoUnmarshallerFactory.newWSListUnmarshaller(ItemReference.class);
    try {
        wsMessageBus.send(message, new RequestCallback<List<ItemReference>>(unmarshaller) {

            @Override
            protected void onSuccess(List<ItemReference> result) {
                view.showItems(result);
            }

            @Override
            protected void onFailure(Throwable exception) {
                Log.error(getClass(), exception);
            }
        });
    } catch (WebSocketException e) {
        Log.error(getClass(), e);
    }
}
Also used : ItemReference(org.eclipse.che.api.project.shared.dto.ItemReference) Message(org.eclipse.che.ide.websocket.Message) MessageBuilder(org.eclipse.che.ide.websocket.MessageBuilder) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with WebSocketException

use of org.eclipse.che.ide.websocket.WebSocketException in project che by eclipse.

the class ResolvingMavenProjectStateHolder method onWsAgentStarted.

@Override
public void onWsAgentStarted(WsAgentStateEvent event) {
    wsAgentStateController.getMessageBus().then(new Operation<MessageBus>() {

        @Override
        public void apply(MessageBus messageBus) throws OperationException {
            try {
                messageBus.subscribe(MAVEN_CHANEL_NAME, new MessageHandler() {

                    @Override
                    public void onMessage(String message) {
                        Jso jso = Jso.deserialize(message);
                        int type = jso.getFieldCastedToInteger("$type");
                        MessageType messageType = MessageType.valueOf(type);
                        if (messageType == START_STOP) {
                            handleStartStop(factory.createDtoFromJson(message, StartStopNotification.class));
                        }
                    }
                });
            } catch (WebSocketException e) {
                Log.error(getClass(), e);
            }
        }
    });
}
Also used : MessageBus(org.eclipse.che.ide.websocket.MessageBus) MessageHandler(org.eclipse.che.ide.websocket.events.MessageHandler) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException) Jso(org.eclipse.che.ide.collections.Jso) StartStopNotification(org.eclipse.che.plugin.maven.shared.dto.StartStopNotification) OperationException(org.eclipse.che.api.promises.client.OperationException) MessageType(org.eclipse.che.plugin.maven.shared.MessageType)

Aggregations

WebSocketException (org.eclipse.che.ide.websocket.WebSocketException)7 MessageBuilder (org.eclipse.che.ide.websocket.MessageBuilder)3 MessageBus (org.eclipse.che.ide.websocket.MessageBus)3 List (java.util.List)2 ItemReference (org.eclipse.che.api.project.shared.dto.ItemReference)2 Operation (org.eclipse.che.api.promises.client.Operation)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 Promise (org.eclipse.che.api.promises.client.Promise)2 WsAgentStateEvent (org.eclipse.che.ide.api.machine.events.WsAgentStateEvent)2 WsAgentStateHandler (org.eclipse.che.ide.api.machine.events.WsAgentStateHandler)2 Message (org.eclipse.che.ide.websocket.Message)2 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 DELETE (com.google.gwt.http.client.RequestBuilder.DELETE)1 POST (com.google.gwt.http.client.RequestBuilder.POST)1 PUT (com.google.gwt.http.client.RequestBuilder.PUT)1 URL (com.google.gwt.http.client.URL)1 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Link (org.eclipse.che.api.core.rest.shared.dto.Link)1