diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/pom.xml b/plugins/plugin-java/che-plugin-java-ext-lang-client/pom.xml
index 2a85ba972c..97a995285a 100644
--- a/plugins/plugin-java/che-plugin-java-ext-lang-client/pom.xml
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/pom.xml
@@ -131,6 +131,10 @@
che-plugin-languageserver-ide
gwt-lib
+
+ org.eclipse.che.plugin
+ che-plugin-maven-shared
+
org.eclipse.che.plugin
che-plugin-orion-compare
diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/JavaLocalizationConstant.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/JavaLocalizationConstant.java
index 930742e63b..5f84ed2e27 100644
--- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/JavaLocalizationConstant.java
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/JavaLocalizationConstant.java
@@ -487,4 +487,17 @@ public interface JavaLocalizationConstant extends Messages {
@Key("formatter.preferences.import.button")
String formatterPreferencesImportButton();
+
+ // Maven
+ @Key("action.effectivePom.title")
+ String actionGetEffectivePomTitle();
+
+ @Key("action.effectivePom.description")
+ String actionGetEffectivePomDescription();
+
+ @Key("action.reimportDependencies.title")
+ String actionReimportDependenciesTitle();
+
+ @Key("action.reimportDependencies.description")
+ String actionReimportDependenciesDescription();
}
diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/MavenResources.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/MavenResources.java
new file mode 100644
index 0000000000..7e77838005
--- /dev/null
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/MavenResources.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2012-2017 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.ext.java.client;
+
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.resources.client.CssResource;
+import org.vectomatic.dom.svg.ui.SVGResource;
+
+/**
+ * Client resources.
+ *
+ * @author Ann Shumilova
+ */
+public interface MavenResources extends ClientBundle {
+ @Source("svg/maven.svg")
+ SVGResource maven();
+
+ @Source("svg/maven-command-type.svg")
+ SVGResource mavenCommandType();
+
+ @Source({"maven.css", "org/eclipse/che/ide/api/ui/style.css"})
+ MavenCss css();
+
+ interface MavenCss extends CssResource {
+
+ String editorInfoPanel();
+
+ String downloadLink();
+
+ String editorMessage();
+ }
+}
diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/actions/GetEffectivePomAction.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/GetEffectivePomAction.java
similarity index 91%
rename from plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/actions/GetEffectivePomAction.java
rename to plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/GetEffectivePomAction.java
index 3454f16a2a..6f5ad07de3 100644
--- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/actions/GetEffectivePomAction.java
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/GetEffectivePomAction.java
@@ -9,14 +9,13 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
-package org.eclipse.che.plugin.maven.client.actions;
+package org.eclipse.che.ide.ext.java.client.action;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.EMERGE_MODE;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
import static org.eclipse.che.ide.part.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
-import static org.eclipse.che.plugin.maven.shared.MavenAttributes.MAVEN_ID;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -33,10 +32,10 @@ import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.api.resources.Project;
import org.eclipse.che.ide.api.resources.Resource;
import org.eclipse.che.ide.api.resources.SyntheticFile;
+import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant;
+import org.eclipse.che.ide.ext.java.client.MavenResources;
import org.eclipse.che.ide.ext.java.client.service.JavaLanguageExtensionServiceClient;
import org.eclipse.che.ide.resource.Path;
-import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant;
-import org.eclipse.che.plugin.maven.client.MavenResources;
import org.eclipse.che.plugin.maven.shared.MavenAttributes;
/**
@@ -55,7 +54,7 @@ public class GetEffectivePomAction extends AbstractPerspectiveAction {
@Inject
public GetEffectivePomAction(
- MavenLocalizationConstant constant,
+ JavaLocalizationConstant localization,
MavenResources mavenResources,
EditorAgent editorAgent,
NotificationManager notificationManager,
@@ -63,8 +62,8 @@ public class GetEffectivePomAction extends AbstractPerspectiveAction {
AppContext appContext) {
super(
Collections.singletonList(PROJECT_PERSPECTIVE_ID),
- constant.actionGetEffectivePomTitle(),
- constant.actionGetEffectivePomDescription(),
+ localization.actionGetEffectivePomTitle(),
+ localization.actionGetEffectivePomDescription(),
mavenResources.maven());
this.editorAgent = editorAgent;
this.notificationManager = notificationManager;
@@ -86,7 +85,7 @@ public class GetEffectivePomAction extends AbstractPerspectiveAction {
return;
}
- event.getPresentation().setEnabledAndVisible(project.isTypeOf(MAVEN_ID));
+ event.getPresentation().setEnabledAndVisible(project.isTypeOf(MavenAttributes.MAVEN_ID));
}
@Override
@@ -95,7 +94,7 @@ public class GetEffectivePomAction extends AbstractPerspectiveAction {
checkNotNull(resource);
final Project project = resource.getProject();
- checkState(MAVEN_ID.equals(project.getType()));
+ checkState(MavenAttributes.MAVEN_ID.equals(project.getType()));
javaLanguageExtensionServiceClient
.effectivePom(project.getLocation().toString())
diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/actions/ReimportMavenDependenciesAction.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ReimportMavenDependenciesAction.java
similarity index 54%
rename from plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/actions/ReimportMavenDependenciesAction.java
rename to plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ReimportMavenDependenciesAction.java
index eec5d9f05f..f2aa8c0b7c 100644
--- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/actions/ReimportMavenDependenciesAction.java
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ReimportMavenDependenciesAction.java
@@ -9,14 +9,12 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
-package org.eclipse.che.plugin.maven.client.actions;
+package org.eclipse.che.ide.ext.java.client.action;
import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.EMERGE_MODE;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
import static org.eclipse.che.ide.part.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
-import static org.eclipse.che.plugin.maven.shared.MavenAttributes.MAVEN_ID;
-import com.google.common.base.Optional;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.ArrayList;
@@ -25,9 +23,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.validation.constraints.NotNull;
-import org.eclipse.che.api.promises.client.Operation;
-import org.eclipse.che.api.promises.client.OperationException;
-import org.eclipse.che.api.promises.client.PromiseError;
import org.eclipse.che.ide.Resources;
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
@@ -35,36 +30,43 @@ import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.api.resources.Project;
import org.eclipse.che.ide.api.resources.Resource;
-import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant;
-import org.eclipse.che.plugin.maven.client.service.MavenServerServiceClient;
+import org.eclipse.che.ide.dto.DtoFactory;
+import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant;
+import org.eclipse.che.ide.ext.java.client.service.JavaLanguageExtensionServiceClient;
+import org.eclipse.che.jdt.ls.extension.api.dto.ReImportMavenProjectsCommandParameters;
+import org.eclipse.che.plugin.maven.shared.MavenAttributes;
/**
* Action for reimport maven dependencies.
*
* @author Roman Nikitenko
+ * @author Mykola Morhun
*/
@Singleton
public class ReimportMavenDependenciesAction extends AbstractPerspectiveAction {
private final AppContext appContext;
private final NotificationManager notificationManager;
- private final MavenServerServiceClient mavenServerServiceClient;
+ private final JavaLanguageExtensionServiceClient javaLanguageExtensionServiceClient;
+ private final DtoFactory dtoFactory;
@Inject
public ReimportMavenDependenciesAction(
- MavenLocalizationConstant constant,
AppContext appContext,
NotificationManager notificationManager,
Resources resources,
- MavenServerServiceClient mavenServerServiceClient) {
+ JavaLanguageExtensionServiceClient javaLanguageExtensionServiceClient,
+ DtoFactory dtoFactory,
+ JavaLocalizationConstant localization) {
super(
Collections.singletonList(PROJECT_PERSPECTIVE_ID),
- constant.actionReimportDependenciesTitle(),
- constant.actionReimportDependenciesDescription(),
+ localization.actionReimportDependenciesTitle(),
+ localization.actionReimportDependenciesDescription(),
resources.refresh());
this.appContext = appContext;
this.notificationManager = notificationManager;
- this.mavenServerServiceClient = mavenServerServiceClient;
+ this.javaLanguageExtensionServiceClient = javaLanguageExtensionServiceClient;
+ this.dtoFactory = dtoFactory;
}
@Override
@@ -74,18 +76,35 @@ public class ReimportMavenDependenciesAction extends AbstractPerspectiveAction {
@Override
public void actionPerformed(ActionEvent e) {
- mavenServerServiceClient
- .reImportProjects(getPathsToSelectedMavenProject())
- .catchError(
- new Operation() {
- @Override
- public void apply(PromiseError arg) throws OperationException {
- notificationManager.notify(
- "Problem with reimporting maven dependencies",
- arg.getMessage(),
- FAIL,
- EMERGE_MODE);
+ ReImportMavenProjectsCommandParameters paramsDto =
+ dtoFactory
+ .createDto(ReImportMavenProjectsCommandParameters.class)
+ .withProjectsToUpdate(getPathsToSelectedMavenProject());
+
+ javaLanguageExtensionServiceClient
+ .reImportMavenProjects(paramsDto)
+ .then(
+ updatedProjects -> {
+ for (final String path : updatedProjects) {
+ appContext
+ .getWorkspaceRoot()
+ .getContainer(path)
+ .then(
+ container -> {
+ if (container.isPresent()) {
+ container.get().synchronize();
+ }
+ });
}
+ // TODO update error markers in poms if needed
+ })
+ .catchError(
+ error -> {
+ notificationManager.notify(
+ "Problem with reimporting maven dependencies",
+ error.getMessage(),
+ FAIL,
+ EMERGE_MODE);
});
}
@@ -104,10 +123,10 @@ public class ReimportMavenDependenciesAction extends AbstractPerspectiveAction {
Set paths = new HashSet<>();
for (Resource resource : resources) {
- final Optional project = resource.getRelatedProject();
+ final Project project = resource.getProject();
- if (project.isPresent() && project.get().isTypeOf(MAVEN_ID)) {
- paths.add(project.get().getLocation().toString());
+ if (project != null && project.isTypeOf(MavenAttributes.MAVEN_ID)) {
+ paths.add(project.getLocation().toString());
}
}
diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/service/JavaLanguageExtensionServiceClient.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/service/JavaLanguageExtensionServiceClient.java
index f5a9074cf0..3cd0c19d85 100644
--- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/service/JavaLanguageExtensionServiceClient.java
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/service/JavaLanguageExtensionServiceClient.java
@@ -13,6 +13,7 @@ package org.eclipse.che.ide.ext.java.client.service;
import static org.eclipse.che.api.promises.client.js.JsPromiseError.create;
import static org.eclipse.che.ide.api.jsonrpc.Constants.WS_AGENT_JSON_RPC_ENDPOINT_ID;
import static org.eclipse.che.ide.ext.java.shared.Constants.CLASS_PATH_TREE;
+import static org.eclipse.che.ide.ext.java.shared.Constants.EFFECTIVE_POM;
import static org.eclipse.che.ide.ext.java.shared.Constants.EFFECTIVE_POM_REQUEST_TIMEOUT;
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARIES;
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARIES_CHILDREN;
@@ -20,6 +21,8 @@ import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARY_CHI
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARY_ENTRY;
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_NODE_CONTENT;
import static org.eclipse.che.ide.ext.java.shared.Constants.FILE_STRUCTURE;
+import static org.eclipse.che.ide.ext.java.shared.Constants.REIMPORT_MAVEN_PROJECTS;
+import static org.eclipse.che.ide.ext.java.shared.Constants.REIMPORT_MAVEN_PROJECTS_REQUEST_TIMEOUT;
import static org.eclipse.che.ide.ext.java.shared.Constants.REQUEST_TIMEOUT;
import com.google.gwt.jsonp.client.TimeoutException;
@@ -36,6 +39,7 @@ import org.eclipse.che.jdt.ls.extension.api.dto.ExternalLibrariesParameters;
import org.eclipse.che.jdt.ls.extension.api.dto.FileStructureCommandParameters;
import org.eclipse.che.jdt.ls.extension.api.dto.Jar;
import org.eclipse.che.jdt.ls.extension.api.dto.JarEntry;
+import org.eclipse.che.jdt.ls.extension.api.dto.ReImportMavenProjectsCommandParameters;
import org.eclipse.che.plugin.languageserver.ide.service.ServiceUtil;
@Singleton
@@ -75,7 +79,7 @@ public class JavaLanguageExtensionServiceClient {
requestTransmitter
.newRequest()
.endpointId(WS_AGENT_JSON_RPC_ENDPOINT_ID)
- .methodName("java/effective-pom")
+ .methodName(EFFECTIVE_POM)
.paramsAsString(pathToProject)
.sendAndReceiveResultAsString(EFFECTIVE_POM_REQUEST_TIMEOUT)
.onSuccess(resolve::apply)
@@ -86,6 +90,27 @@ public class JavaLanguageExtensionServiceClient {
.onFailure(error -> reject.apply(ServiceUtil.getPromiseError(error))));
}
+ /**
+ * Updates specified maven projects.
+ *
+ * @param params contains list of paths to projects which should be reimported
+ * @return list of paths to updated projects
+ */
+ public Promise> reImportMavenProjects(
+ ReImportMavenProjectsCommandParameters params) {
+ return Promises.create(
+ (resolve, reject) ->
+ requestTransmitter
+ .newRequest()
+ .endpointId(WS_AGENT_JSON_RPC_ENDPOINT_ID)
+ .methodName(REIMPORT_MAVEN_PROJECTS)
+ .paramsAsDto(params)
+ .sendAndReceiveResultAsListOfString(REIMPORT_MAVEN_PROJECTS_REQUEST_TIMEOUT)
+ .onSuccess(resolve::apply)
+ .onTimeout(() -> reject.apply(create("Failed to update maven project.")))
+ .onFailure(error -> reject.apply(ServiceUtil.getPromiseError(error))));
+ }
+
/**
* Gets external libraries of the project.
*
diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/JavaLocalizationConstant.properties b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/JavaLocalizationConstant.properties
index cc2135fdf5..d92af9011a 100644
--- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/JavaLocalizationConstant.properties
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/JavaLocalizationConstant.properties
@@ -205,3 +205,9 @@ formatter.preferences.workspace.label=Workspace
formatter.preferences.workspace.description=Import For Workspace
formatter.preferences.label=Import Code Formatter
formatter.preferences.import.button=Import
+
+################ Maven #############
+action.effectivePom.title = Generate Effective Pom
+action.effectivePom.description = Generate effective pom for current project
+action.reimportDependencies.title = Reimport
+action.reimportDependencies.description = Reimport maven dependencies
diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/maven.css b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/maven.css
new file mode 100644
index 0000000000..51b42dc5f5
--- /dev/null
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/maven.css
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2012-2017 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
+ */
+.editorInfoPanel {
+ width: 100%;
+ height: 20px;
+}
+
+.editorMessage {
+ float: left;
+ padding-left: 10px;
+ padding-right: 10px;
+}
+
+.downloadLink {
+ text-decoration: underline;
+ cursor:pointer;
+ color: primaryButtonBackground;
+}
diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/svg/maven-command-type.svg b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/svg/maven-command-type.svg
new file mode 100644
index 0000000000..b7fdadd4b1
--- /dev/null
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/svg/maven-command-type.svg
@@ -0,0 +1,20 @@
+
+
+
diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/svg/maven.svg b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/svg/maven.svg
new file mode 100644
index 0000000000..340f829285
--- /dev/null
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/resources/org/eclipse/che/ide/ext/java/client/svg/maven.svg
@@ -0,0 +1,25 @@
+
+
+
diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-shared/src/main/java/org/eclipse/che/ide/ext/java/shared/Constants.java b/plugins/plugin-java/che-plugin-java-ext-lang-shared/src/main/java/org/eclipse/che/ide/ext/java/shared/Constants.java
index b64e4cd614..01bb7d0633 100644
--- a/plugins/plugin-java/che-plugin-java-ext-lang-shared/src/main/java/org/eclipse/che/ide/ext/java/shared/Constants.java
+++ b/plugins/plugin-java/che-plugin-java-ext-lang-shared/src/main/java/org/eclipse/che/ide/ext/java/shared/Constants.java
@@ -32,6 +32,7 @@ public final class Constants {
// LS requests timeout constants
public static final int REQUEST_TIMEOUT = 10_000;
public static final int EFFECTIVE_POM_REQUEST_TIMEOUT = 30_000;
+ public static final int REIMPORT_MAVEN_PROJECTS_REQUEST_TIMEOUT = 60_000;
// JSON RPC methods
public static final String FILE_STRUCTURE = "java/filestructure";
@@ -41,6 +42,8 @@ public final class Constants {
public static final String EXTERNAL_LIBRARY_ENTRY = "java/libraryEntry";
public static final String EXTERNAL_NODE_CONTENT = "java/libraryNodeContentByPath";
public static final String CLASS_PATH_TREE = "java/classpathTree";
+ public static final String EFFECTIVE_POM = "java/effective-pom";
+ public static final String REIMPORT_MAVEN_PROJECTS = "java/reimport-maven-projects";
private Constants() {
throw new UnsupportedOperationException("Unused constructor.");
diff --git a/plugins/plugin-java/che-plugin-java-server/src/main/java/org/eclipse/che/plugin/java/languageserver/JavaLanguageServerExtensionService.java b/plugins/plugin-java/che-plugin-java-server/src/main/java/org/eclipse/che/plugin/java/languageserver/JavaLanguageServerExtensionService.java
index a0b3c82f64..815b9ca122 100644
--- a/plugins/plugin-java/che-plugin-java-server/src/main/java/org/eclipse/che/plugin/java/languageserver/JavaLanguageServerExtensionService.java
+++ b/plugins/plugin-java/che-plugin-java-server/src/main/java/org/eclipse/che/plugin/java/languageserver/JavaLanguageServerExtensionService.java
@@ -13,7 +13,9 @@ package org.eclipse.che.plugin.java.languageserver;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.eclipse.che.api.languageserver.service.LanguageServiceUtils.prefixURI;
+import static org.eclipse.che.api.languageserver.service.LanguageServiceUtils.removePrefixUri;
import static org.eclipse.che.ide.ext.java.shared.Constants.CLASS_PATH_TREE;
+import static org.eclipse.che.ide.ext.java.shared.Constants.EFFECTIVE_POM;
import static org.eclipse.che.ide.ext.java.shared.Constants.EFFECTIVE_POM_REQUEST_TIMEOUT;
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARIES;
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARIES_CHILDREN;
@@ -21,6 +23,8 @@ import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARY_CHI
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARY_ENTRY;
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_NODE_CONTENT;
import static org.eclipse.che.ide.ext.java.shared.Constants.FILE_STRUCTURE;
+import static org.eclipse.che.ide.ext.java.shared.Constants.REIMPORT_MAVEN_PROJECTS;
+import static org.eclipse.che.ide.ext.java.shared.Constants.REIMPORT_MAVEN_PROJECTS_REQUEST_TIMEOUT;
import static org.eclipse.che.jdt.ls.extension.api.Commands.FILE_STRUCTURE_COMMAND;
import static org.eclipse.che.jdt.ls.extension.api.Commands.FIND_TESTS_FROM_ENTRY_COMMAND;
import static org.eclipse.che.jdt.ls.extension.api.Commands.FIND_TESTS_FROM_FOLDER_COMMAND;
@@ -35,6 +39,7 @@ import static org.eclipse.che.jdt.ls.extension.api.Commands.GET_LIBRARY_CHILDREN
import static org.eclipse.che.jdt.ls.extension.api.Commands.GET_LIBRARY_ENTRY_COMMAND;
import static org.eclipse.che.jdt.ls.extension.api.Commands.GET_LIBRARY_NODE_CONTENT_BY_PATH_COMMAND;
import static org.eclipse.che.jdt.ls.extension.api.Commands.GET_OUTPUT_DIR_COMMAND;
+import static org.eclipse.che.jdt.ls.extension.api.Commands.REIMPORT_MAVEN_PROJECTS_COMMAND;
import static org.eclipse.che.jdt.ls.extension.api.Commands.RESOLVE_CLASSPATH_COMMAND;
import static org.eclipse.che.jdt.ls.extension.api.Commands.TEST_DETECT_COMMAND;
@@ -48,6 +53,7 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.ListIterator;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -69,6 +75,7 @@ import org.eclipse.che.jdt.ls.extension.api.dto.ExternalLibrariesParameters;
import org.eclipse.che.jdt.ls.extension.api.dto.FileStructureCommandParameters;
import org.eclipse.che.jdt.ls.extension.api.dto.Jar;
import org.eclipse.che.jdt.ls.extension.api.dto.JarEntry;
+import org.eclipse.che.jdt.ls.extension.api.dto.ReImportMavenProjectsCommandParameters;
import org.eclipse.che.jdt.ls.extension.api.dto.ResourceLocation;
import org.eclipse.che.jdt.ls.extension.api.dto.TestFindParameters;
import org.eclipse.che.jdt.ls.extension.api.dto.TestPosition;
@@ -123,11 +130,18 @@ public class JavaLanguageServerExtensionService {
requestHandler
.newConfiguration()
- .methodName("java/effective-pom")
+ .methodName(EFFECTIVE_POM)
.paramsAsString()
.resultAsString()
.withFunction(this::getEffectivePom);
+ requestHandler
+ .newConfiguration()
+ .methodName(REIMPORT_MAVEN_PROJECTS)
+ .paramsAsDto(ReImportMavenProjectsCommandParameters.class)
+ .resultAsListOfString()
+ .withFunction(this::reImportMavenProjects);
+
requestHandler
.newConfiguration()
.methodName(EXTERNAL_LIBRARIES)
@@ -361,13 +375,54 @@ public class JavaLanguageServerExtensionService {
Type targetClassType = new TypeToken() {}.getType();
try {
return gson.fromJson(
- gson.toJson(result.get(EFFECTIVE_POM_REQUEST_TIMEOUT, TimeUnit.SECONDS)),
+ gson.toJson(result.get(EFFECTIVE_POM_REQUEST_TIMEOUT, TimeUnit.MILLISECONDS)),
targetClassType);
} catch (JsonSyntaxException | InterruptedException | ExecutionException | TimeoutException e) {
throw new JsonRpcException(-27000, e.getMessage());
}
}
+ /**
+ * Updates given maven projects.
+ *
+ * @param parameters dto with list of paths to projects (relatively to projects root (e.g.
+ * /projects)) which should be re-imported.
+ * @return list of paths (relatively to projects root) to projects which were updated.
+ */
+ public List reImportMavenProjects(ReImportMavenProjectsCommandParameters parameters) {
+ final List projectsToReImport = parameters.getProjectsToUpdate();
+ if (projectsToReImport.isEmpty()) {
+ return emptyList();
+ }
+
+ ListIterator iterator = projectsToReImport.listIterator();
+ while (iterator.hasNext()) {
+ iterator.set(prefixURI(iterator.next()));
+ }
+
+ CompletableFuture