-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…9650) Added a listener for CLASSPATH change events that updates External Libraries nodes accordingly Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
- Loading branch information
Showing
10 changed files
with
316 additions
and
3 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...-ide-app/src/main/java/org/eclipse/che/ide/project/node/ProjectClasspathChangedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.ide.project.node; | ||
|
||
import com.google.gwt.event.shared.EventHandler; | ||
import com.google.gwt.event.shared.GwtEvent; | ||
|
||
/** @author V. Rubezhny */ | ||
public class ProjectClasspathChangedEvent | ||
extends GwtEvent<ProjectClasspathChangedEvent.ProjectClasspathChangedHandler> { | ||
|
||
private String projectPath; | ||
|
||
public interface ProjectClasspathChangedHandler extends EventHandler { | ||
void onProjectClasspathChanged(ProjectClasspathChangedEvent event); | ||
} | ||
|
||
private static Type<ProjectClasspathChangedHandler> TYPE; | ||
|
||
public static Type<ProjectClasspathChangedHandler> getType() { | ||
if (TYPE == null) { | ||
TYPE = new Type<>(); | ||
} | ||
return TYPE; | ||
} | ||
|
||
public ProjectClasspathChangedEvent(String projectPath) { | ||
this.projectPath = projectPath; | ||
} | ||
|
||
public String getProject() { | ||
return projectPath; | ||
} | ||
|
||
@Override | ||
public Type<ProjectClasspathChangedHandler> getAssociatedType() { | ||
return TYPE; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
protected void dispatch(ProjectClasspathChangedHandler handler) { | ||
handler.onProjectClasspathChanged(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...va/org/eclipse/che/plugin/java/languageserver/ExecuteClientCommandJsonRpcTransmitter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.plugin.java.languageserver; | ||
|
||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXECUTE_CLIENT_COMMAND; | ||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXECUTE_CLIENT_COMMAND_SUBSCRIBE; | ||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXECUTE_CLIENT_COMMAND_UNSUBSCRIBE; | ||
|
||
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CopyOnWriteArraySet; | ||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
import org.eclipse.che.api.core.jsonrpc.commons.RequestHandlerConfigurator; | ||
import org.eclipse.che.api.core.jsonrpc.commons.RequestTransmitter; | ||
import org.eclipse.che.api.core.notification.EventService; | ||
import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls; | ||
import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.ExecuteCommandParamsDto; | ||
import org.eclipse.lsp4j.ExecuteCommandParams; | ||
|
||
/** Transmits 'workspace/executeClientCommand' over the JSON-RPC */ | ||
@Singleton | ||
public class ExecuteClientCommandJsonRpcTransmitter { | ||
private final Set<String> endpointIds = new CopyOnWriteArraySet<>(); | ||
|
||
private final RequestTransmitter requestTransmitter; | ||
|
||
@Inject | ||
public ExecuteClientCommandJsonRpcTransmitter(RequestTransmitter requestTransmitter) { | ||
this.requestTransmitter = requestTransmitter; | ||
} | ||
|
||
@Inject | ||
private void subscribe(EventService eventService, RequestTransmitter requestTransmitter) { | ||
eventService.subscribe( | ||
event -> | ||
endpointIds.forEach( | ||
endpointId -> | ||
requestTransmitter | ||
.newRequest() | ||
.endpointId(endpointId) | ||
.methodName(EXECUTE_CLIENT_COMMAND) | ||
.paramsAsDto(new ExecuteCommandParamsDto(event)) | ||
.sendAndSkipResult()), | ||
ExecuteCommandParams.class); | ||
} | ||
|
||
@Inject | ||
private void configureSubscribeHandler(RequestHandlerConfigurator requestHandler) { | ||
requestHandler | ||
.newConfiguration() | ||
.methodName(EXECUTE_CLIENT_COMMAND_SUBSCRIBE) | ||
.noParams() | ||
.noResult() | ||
.withConsumer(endpointIds::add); | ||
} | ||
|
||
@Inject | ||
private void configureUnSubscribeHandler(RequestHandlerConfigurator requestHandler) { | ||
requestHandler | ||
.newConfiguration() | ||
.methodName(EXECUTE_CLIENT_COMMAND_UNSUBSCRIBE) | ||
.noParams() | ||
.noResult() | ||
.withConsumer(endpointIds::remove); | ||
} | ||
|
||
public CompletableFuture<Object> executeClientCommand(ExecuteCommandParams requestParams) { | ||
ExecuteCommandParamsDto paramsDto = | ||
(ExecuteCommandParamsDto) DtoServerImpls.makeDto(requestParams); | ||
|
||
CompletableFuture<Object> result = new CompletableFuture<>(); | ||
for (String endpointId : endpointIds) { | ||
requestTransmitter | ||
.newRequest() | ||
.endpointId(endpointId) | ||
.methodName(EXECUTE_CLIENT_COMMAND) | ||
.paramsAsDto(paramsDto) | ||
.sendAndSkipResult(); | ||
} | ||
result.complete(null); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...java/org/eclipse/che/plugin/languageserver/ide/service/ExecuteClientCommandProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.plugin.languageserver.ide.service; | ||
|
||
import com.google.gwt.json.client.JSONString; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Singleton; | ||
import com.google.web.bindery.event.shared.EventBus; | ||
import org.eclipse.che.ide.project.node.ProjectClasspathChangedEvent; | ||
import org.eclipse.lsp4j.ExecuteCommandParams; | ||
|
||
/** | ||
* A processor for incoming <code>workspace/ClasspathChanged</code> notifications sent by a language | ||
* server. | ||
* | ||
* @author V. Rubezhny | ||
*/ | ||
@Singleton | ||
public class ExecuteClientCommandProcessor { | ||
private static final String CLIENT_UPDATE_PROJECTS_CLASSPATH = | ||
"che.jdt.ls.extension.workspace.clientUpdateProjectsClasspath"; | ||
|
||
private EventBus eventBus; | ||
|
||
@Inject | ||
public ExecuteClientCommandProcessor(EventBus eventBus) { | ||
this.eventBus = eventBus; | ||
} | ||
|
||
public void execute(ExecuteCommandParams params) { | ||
if (CLIENT_UPDATE_PROJECTS_CLASSPATH.equals(params.getCommand())) { | ||
for (Object project : params.getArguments()) { | ||
eventBus.fireEvent(new ProjectClasspathChangedEvent(stringValue(project))); | ||
} | ||
} | ||
} | ||
|
||
private String stringValue(Object value) { | ||
return value instanceof JSONString ? ((JSONString) value).stringValue() : String.valueOf(value); | ||
} | ||
} |
Oops, something went wrong.