From 3993bed996e734034443bc0db0a22c71c0f1f461 Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Fri, 30 Sep 2016 10:22:08 +0300 Subject: [PATCH 01/33] CHE-2214 NodeJs Debugger (#2625) --- assembly/assembly-ide-war/pom.xml | 4 + .../resources/org/eclipse/che/ide/IDE.gwt.xml | 1 + assembly/assembly-wsagent-war/pom.xml | 4 + .../api/debug/DebuggerServiceClientImpl.java | 5 - .../che/ide/editor/EditorAgentImpl.java | 2 +- .../ide/resources/impl/ResourceManager.java | 4 +- .../che-plugin-nodejs-debugger-ide/pom.xml | 154 +++++++++ .../plugin/nodejsdbg/ide/NodeJsDebugger.java | 102 ++++++ .../ide/NodeJsDebuggerExtension.java | 32 ++ .../ide/NodeJsDebuggerFileHandler.java | 193 +++++++++++ .../ide/NodeJsDebuggerGinModule.java | 33 ++ .../NodeJsDebuggerLocalizationConstant.java | 33 ++ .../ide/NodeJsDebuggerResources.java | 25 ++ ...eJsDebuggerConfigurationPagePresenter.java | 97 ++++++ .../NodeJsDebuggerConfigurationPageView.java | 34 ++ ...deJsDebuggerConfigurationPageViewImpl.java | 70 ++++ ...JsDebuggerConfigurationPageViewImpl.ui.xml | 21 ++ .../NodeJsDebuggerConfigurationType.java | 58 ++++ .../plugin/nodejsdbg/NodeJsDebugger.gwt.xml | 27 ++ ...eJsDebuggerLocalizationConstant.properties | 16 + .../nodejs-debugger-configuration-type.svg | 20 ++ ...ebuggerConfigurationPagePresenterTest.java | 110 +++++++ .../NodeJsDebuggerConfigurationTypeTest.java | 61 ++++ .../src/test/resources/logback-test.xml | 26 ++ .../che-plugin-nodejs-debugger-server/pom.xml | 117 +++++++ .../nodejsdbg/server/NodeJsDebugProcess.java | 248 ++++++++++++++ .../nodejsdbg/server/NodeJsDebugger.java | 309 ++++++++++++++++++ .../server/NodeJsDebuggerFactory.java | 82 +++++ .../server/NodeJsDebuggerModule.java | 29 ++ .../plugin/nodejsdbg/server/NodeJsOutput.java | 45 +++ .../server/NodeJsProcessObservable.java | 27 ++ .../server/NodeJsProcessObserver.java | 26 ++ .../server/command/NodeJsDebugCommand.java | 40 +++ .../command/NodeJsDebugCommandImpl.java | 56 ++++ .../command/NodeJsDebugCommandsLibrary.java | 261 +++++++++++++++ .../exception/NodeJsDebuggerException.java | 26 ++ .../NodeJsDebuggerParseException.java | 29 ++ .../NodeJsDebuggerTerminatedException.java | 20 ++ .../server/parser/NodeJsBackTraceParser.java | 53 +++ .../parser/NodeJsBreakpointsParser.java | 96 ++++++ .../server/parser/NodeJsOutputParser.java | 80 +++++ .../server/parser/NodeJsScriptsParser.java | 68 ++++ .../server/parser/NodeJsStepParser.java | 53 +++ .../nodejsdbg/server/NodeJsDebuggerTest.java | 122 +++++++ .../parser/NodeJsBackTraceParserTest.java | 66 ++++ .../parser/NodeJsBreakpointsParserTest.java | 89 +++++ .../parser/NodeJsScriptsParserTest.java | 47 +++ .../server/parser/NodeJsStepParserTest.java | 58 ++++ .../src/test/resources/app.js | 7 + .../src/test/resources/logback-test.xml | 25 ++ plugins/plugin-nodejs-debugger/pom.xml | 42 +++ plugins/pom.xml | 1 + pom.xml | 10 + 53 files changed, 3257 insertions(+), 7 deletions(-) create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/pom.xml create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebugger.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerExtension.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerFileHandler.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerGinModule.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerResources.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenter.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageView.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.ui.xml create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationType.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/NodeJsDebugger.gwt.xml create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.properties create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/configuration/nodejs-debugger-configuration-type.svg create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationTypeTest.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/resources/logback-test.xml create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/pom.xml create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugProcess.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugger.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerFactory.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerModule.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsOutput.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObservable.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObserver.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommand.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandImpl.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandsLibrary.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerException.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerParseException.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerTerminatedException.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParser.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParser.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsOutputParser.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParser.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParser.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerTest.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParserTest.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParserTest.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParserTest.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParserTest.java create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/app.js create mode 100644 plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/logback-test.xml create mode 100644 plugins/plugin-nodejs-debugger/pom.xml diff --git a/assembly/assembly-ide-war/pom.xml b/assembly/assembly-ide-war/pom.xml index 464529a8d024..aa03387bb7a5 100644 --- a/assembly/assembly-ide-war/pom.xml +++ b/assembly/assembly-ide-war/pom.xml @@ -180,6 +180,10 @@ org.eclipse.che.plugin che-plugin-maven-shared + + org.eclipse.che.plugin + che-plugin-nodejs-debugger-ide + org.eclipse.che.plugin che-plugin-nodejs-lang-ide diff --git a/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml b/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml index 2677e9551c6e..e951b39f2a04 100644 --- a/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml +++ b/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml @@ -44,6 +44,7 @@ + diff --git a/assembly/assembly-wsagent-war/pom.xml b/assembly/assembly-wsagent-war/pom.xml index 1344208bc111..b03d28444605 100644 --- a/assembly/assembly-wsagent-war/pom.xml +++ b/assembly/assembly-wsagent-war/pom.xml @@ -160,6 +160,10 @@ org.eclipse.che.plugin che-plugin-maven-server + + org.eclipse.che.plugin + che-plugin-nodejs-debugger-server + org.eclipse.che.plugin che-plugin-nodejs-lang-server diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/debug/DebuggerServiceClientImpl.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/debug/DebuggerServiceClientImpl.java index 1db032ab6dcd..7a46ac995079 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/debug/DebuggerServiceClientImpl.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/debug/DebuggerServiceClientImpl.java @@ -96,7 +96,6 @@ public Promise start(String id, StartActionDto action) { public Promise addBreakpoint(String id, BreakpointDto breakpointDto) { final String requestUrl = getBaseUrl(id) + "/breakpoint"; return asyncRequestFactory.createPostRequest(requestUrl, breakpointDto) - .loader(loaderFactory.newLoader()) .send(); } @@ -104,7 +103,6 @@ public Promise addBreakpoint(String id, BreakpointDto breakpointDto) { public Promise> getAllBreakpoints(String id) { final String requestUrl = getBaseUrl(id) + "/breakpoint"; return asyncRequestFactory.createGetRequest(requestUrl) - .loader(loaderFactory.newLoader()) .send(dtoUnmarshallerFactory.newListUnmarshaller(BreakpointDto.class)); } @@ -148,7 +146,6 @@ public Promise getValue(String id, VariableDto variableDto) { } return asyncRequestFactory.createGetRequest(requestUrl + params) - .loader(loaderFactory.newLoader()) .send(dtoUnmarshallerFactory.newUnmarshaller(SimpleValueDto.class)); } @@ -156,7 +153,6 @@ public Promise getValue(String id, VariableDto variableDto) { public Promise setValue(String id, VariableDto variableDto) { final String requestUrl = getBaseUrl(id) + "/value"; return asyncRequestFactory.createPutRequest(requestUrl, variableDto) - .loader(loaderFactory.newLoader()) .send(); } @@ -195,7 +191,6 @@ private String getBaseUrl(String id) { protected Promise performAction(String id, ActionDto actionDto) { final String requestUrl = getBaseUrl(id); return asyncRequestFactory.createPostRequest(requestUrl, actionDto) - .loader(loaderFactory.newLoader()) .send(); } } diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java index 9c1abb6d6199..04b0bb3c49c6 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java @@ -318,7 +318,7 @@ public List getOpenedEditorsBasedOn(EditorPartPresenter edi @Override public EditorPartPresenter getOpenedEditor(Path path) { EditorPartStack editorPartStack = editorMultiPartStack.getPartStackByPart(activeEditor); - return (EditorPartPresenter)editorPartStack.getPartByPath(path); + return editorPartStack == null ? null : (EditorPartPresenter)editorPartStack.getPartByPath(path); } /** {@inheritDoc} */ diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/resources/impl/ResourceManager.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/resources/impl/ResourceManager.java index 9154b14661bf..e8cd77ae4bc8 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/resources/impl/ResourceManager.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/resources/impl/ResourceManager.java @@ -1131,7 +1131,9 @@ public Void apply(Optional resource) throws FunctionException { protected Promise search(final Container container, String fileMask, String contentMask) { QueryExpression queryExpression = new QueryExpression(); - queryExpression.setText(contentMask + '*'); + if (!isNullOrEmpty(contentMask)) { + queryExpression.setText(contentMask + '*'); + } if (!isNullOrEmpty(fileMask)) { queryExpression.setName(fileMask); } diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/pom.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/pom.xml new file mode 100644 index 000000000000..f8aa51f66500 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/pom.xml @@ -0,0 +1,154 @@ + + + + 4.0.0 + + che-plugin-nodejs-debugger-parent + org.eclipse.che.plugin + 5.0.0-M5-SNAPSHOT + + che-plugin-nodejs-debugger-ide + jar + Che Plugin :: NodeJs Debugger :: IDE + + + com.google.guava + guava + + + com.google.gwt + gwt-elemental + + + com.google.gwt.inject + gin + + + com.google.inject + guice + + + javax.validation + validation-api + + + org.eclipse.che.core + che-core-api-project + + + org.eclipse.che.core + che-core-api-workspace + + + org.eclipse.che.core + che-core-commons-annotations + + + org.eclipse.che.core + che-core-commons-gwt + + + org.eclipse.che.core + che-core-ide-api + + + org.eclipse.che.core + che-core-ide-app + + + org.eclipse.che.core + che-core-ide-ui + + + org.eclipse.che.plugin + che-plugin-debugger-ide + + + org.vectomatic + lib-gwt-svg + + + com.google.gwt + gwt-user + provided + + + com.google.gwt + gwt-dev + test + + + com.google.gwt.gwtmockito + gwtmockito + test + + + com.googlecode.gwt-test-utils + gwt-test-utils + test + + + junit + junit + test + + + org.hamcrest + hamcrest-core + test + + + org.mockito + mockito-core + test + + + + + + src/main/java + + + src/main/resources + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + analyze + + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + com.mycila + license-maven-plugin + + + **/*.png + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebugger.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebugger.java new file mode 100644 index 000000000000..77065fe4bed1 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebugger.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.inject.Inject; +import com.google.web.bindery.event.shared.EventBus; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.ide.api.debug.BreakpointManager; +import org.eclipse.che.ide.api.debug.DebuggerServiceClient; +import org.eclipse.che.ide.api.resources.VirtualFile; +import org.eclipse.che.ide.debug.DebuggerDescriptor; +import org.eclipse.che.ide.debug.DebuggerManager; +import org.eclipse.che.ide.dto.DtoFactory; +import org.eclipse.che.ide.util.storage.LocalStorageProvider; +import org.eclipse.che.ide.websocket.MessageBusProvider; +import org.eclipse.che.plugin.debugger.ide.debug.AbstractDebugger; + +import javax.validation.constraints.NotNull; +import java.util.Map; + +/** + * The NodeJs Debugger Client. + * + * @author Anatoliy Bazko + */ +public class NodeJsDebugger extends AbstractDebugger { + + public static final String ID = "nodejsdbg"; + + @Inject + public NodeJsDebugger(DebuggerServiceClient service, + DtoFactory dtoFactory, + LocalStorageProvider localStorageProvider, + MessageBusProvider messageBusProvider, + EventBus eventBus, + NodeJsDebuggerFileHandler activeFileHandler, + DebuggerManager debuggerManager, + BreakpointManager breakpointManager) { + + super(service, + dtoFactory, + localStorageProvider, + messageBusProvider, + eventBus, + activeFileHandler, + debuggerManager, + breakpointManager, + ID); + } + + @Override + protected String fqnToPath(@NotNull Location location) { + return location.getResourcePath() == null ? location.getTarget() : location.getResourcePath(); + } + + @Override + protected String pathToFqn(VirtualFile file) { + return file.getLocation().toString(); + } + + @Override + protected DebuggerDescriptor toDescriptor(Map connectionProperties) { + StringBuilder sb = new StringBuilder(); + + for (String propName : connectionProperties.keySet()) { + try { + ConnectionProperties prop = ConnectionProperties.valueOf(propName.toUpperCase()); + String connectionInfo = prop.getConnectionInfo(connectionProperties.get(propName)); + if (!connectionInfo.isEmpty()) { + if (sb.length() > 0) { + sb.append(','); + } + sb.append(connectionInfo); + } + } catch (IllegalArgumentException ignored) { + // unrecognized connection property + } + } + + return new DebuggerDescriptor("", "{ " + sb.toString() + " }"); + } + + public enum ConnectionProperties { + SCRIPT { + @Override + public String getConnectionInfo(String value) { + return value; + } + }; + + public abstract String getConnectionInfo(String value); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerExtension.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerExtension.java new file mode 100644 index 000000000000..38fb9d92e863 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerExtension.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.ide.debug.DebuggerManager; + +/** + * Extension allows to debug NodeJs applications. + * + * @author Anatoliy Bazko + */ +@Singleton +@Extension(title = "NodeJs Debugger", version = "5.0.0") +public class NodeJsDebuggerExtension { + + @Inject + public NodeJsDebuggerExtension(DebuggerManager debuggerManager, NodeJsDebugger nodeJsDebugger) { + debuggerManager.registeredDebugger(NodeJsDebugger.ID, nodeJsDebugger); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerFileHandler.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerFileHandler.java new file mode 100644 index 000000000000..c42aad489fcf --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerFileHandler.java @@ -0,0 +1,193 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.common.base.Optional; +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.inject.Inject; +import com.google.web.bindery.event.shared.EventBus; + +import org.eclipse.che.api.debug.shared.model.Location; +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.api.app.AppContext; +import org.eclipse.che.ide.api.editor.EditorAgent; +import org.eclipse.che.ide.api.editor.EditorPartPresenter; +import org.eclipse.che.ide.api.editor.document.Document; +import org.eclipse.che.ide.api.editor.text.TextPosition; +import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.event.FileEvent; +import org.eclipse.che.ide.api.resources.File; +import org.eclipse.che.ide.api.resources.Project; +import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.resources.VirtualFile; +import org.eclipse.che.plugin.debugger.ide.debug.ActiveFileHandler; + +/** + * Responsible to open files in editor when debugger stopped at breakpoint. + * + * @author Anatoliy Bazko + */ +public class NodeJsDebuggerFileHandler implements ActiveFileHandler { + + private final EditorAgent editorAgent; + private final EventBus eventBus; + private final AppContext appContext; + + @Inject + public NodeJsDebuggerFileHandler(EditorAgent editorAgent, + EventBus eventBus, + AppContext appContext) { + this.editorAgent = editorAgent; + this.eventBus = eventBus; + this.appContext = appContext; + } + + @Override + public void openFile(final Location location, final AsyncCallback callback) { + final Resource resource = appContext.getResource(); + if (resource == null) { + callback.onFailure(new IllegalStateException("Resource is undefined")); + return; + } + final Optional project = resource.getRelatedProject(); + if (!project.isPresent()) { + callback.onFailure(new IllegalStateException("Project is undefined")); + return; + } + + findFileInProject(project.get(), location, callback); + } + + private void findFileInProject(final Project project, + final Location location, + final AsyncCallback callback) { + project.getFile(location.getTarget()).then(new Operation>() { + @Override + public void apply(Optional file) throws OperationException { + if (file.isPresent()) { + openFileInEditorAndScrollToLine(file.get(), callback, location.getLineNumber()); + callback.onSuccess(file.get()); + } else { + findFileInWorkspace(location, callback); + } + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError arg) throws OperationException { + callback.onFailure(new IllegalArgumentException("File not found." + arg.getMessage())); + } + }); + } + + private void findFileInWorkspace(final Location location, + final AsyncCallback callback) { + try { + appContext.getWorkspaceRoot().getFile(location.getTarget()).then(new Operation>() { + @Override + public void apply(Optional file) throws OperationException { + if (file.isPresent()) { + openFileInEditorAndScrollToLine(file.get(), callback, location.getLineNumber()); + callback.onSuccess(file.get()); + } else { + searchSource(location, callback); + } + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError arg) throws OperationException { + callback.onFailure(new IllegalArgumentException("File not found." + arg.getMessage())); + } + }); + } catch (IllegalStateException ignored) { + searchSource(location, callback); + } + } + + private void searchSource(final Location location, final AsyncCallback callback) { + appContext.getWorkspaceRoot().search(location.getTarget(), "").then(new Operation() { + @Override + public void apply(Resource[] resources) throws OperationException { + if (resources.length == 0) { + callback.onFailure(new IllegalArgumentException("File not found.")); + return; + } + + appContext.getWorkspaceRoot().getFile(resources[0].getLocation()).then(new Operation>() { + @Override + public void apply(Optional file) throws OperationException { + if (file.isPresent()) { + openFileInEditorAndScrollToLine(file.get(), callback, location.getLineNumber()); + callback.onSuccess(file.get()); + } else { + callback.onFailure(new IllegalArgumentException("File not found.")); + } + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError arg) throws OperationException { + callback.onFailure(new IllegalArgumentException("File not found. " + arg.getMessage())); + } + }); + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError arg) throws OperationException { + callback.onFailure(new IllegalArgumentException("File not found. " + arg.getMessage())); + } + }); + } + + private void openFileInEditorAndScrollToLine(final VirtualFile virtualFile, + final AsyncCallback callback, + final int scrollToLine) { + editorAgent.openEditor(virtualFile, new EditorAgent.OpenEditorCallback() { + @Override + public void onEditorOpened(EditorPartPresenter editor) { + new Timer() { + @Override + public void run() { + scrollEditorToExecutionPoint((TextEditor)editorAgent.getActiveEditor(), scrollToLine); + callback.onSuccess(virtualFile); + } + }.schedule(300); + } + + @Override + public void onEditorActivated(EditorPartPresenter editor) { + new Timer() { + @Override + public void run() { + scrollEditorToExecutionPoint((TextEditor)editorAgent.getActiveEditor(), scrollToLine); + callback.onSuccess(virtualFile); + } + }.schedule(300); + } + + @Override + public void onInitializationFailed() { + callback.onFailure(null); + } + }); + + eventBus.fireEvent(FileEvent.createOpenFileEvent(virtualFile)); + } + + private void scrollEditorToExecutionPoint(TextEditor editor, int lineNumber) { + Document document = editor.getDocument(); + if (document != null) { + TextPosition newPosition = new TextPosition(lineNumber, 0); + document.setCursorPosition(newPosition); + } + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerGinModule.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerGinModule.java new file mode 100644 index 000000000000..aff1d4023196 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerGinModule.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.gwt.inject.client.AbstractGinModule; +import com.google.gwt.inject.client.multibindings.GinMultibinder; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.debug.DebugConfigurationType; +import org.eclipse.che.ide.api.extension.ExtensionGinModule; +import org.eclipse.che.plugin.nodejsdbg.ide.configuration.NodeJsDebuggerConfigurationPageView; +import org.eclipse.che.plugin.nodejsdbg.ide.configuration.NodeJsDebuggerConfigurationPageViewImpl; +import org.eclipse.che.plugin.nodejsdbg.ide.configuration.NodeJsDebuggerConfigurationType; + +/** + * @author Anatolii Bazko + */ +@ExtensionGinModule +public class NodeJsDebuggerGinModule extends AbstractGinModule { + @Override + protected void configure() { + GinMultibinder.newSetBinder(binder(), DebugConfigurationType.class).addBinding().to(NodeJsDebuggerConfigurationType.class); + bind(NodeJsDebuggerConfigurationPageView.class).to(NodeJsDebuggerConfigurationPageViewImpl.class).in(Singleton.class); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.java new file mode 100644 index 000000000000..2602a012a51a --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.gwt.i18n.client.Messages; + +/** + * I18n constants for the Debugger extension. + * + * @author Anatolii Bazko + */ +public interface NodeJsDebuggerLocalizationConstant extends Messages { + + @Key("view.nodeJsDebuggerConfigurationPage.hostLabel") + String nodeJsDebuggerConfigurationPageViewHostLabel(); + + @Key("view.nodeJsDebuggerConfigurationPage.portLabel") + String nodeJsDebuggerConfigurationPageViewPortLabel(); + + @Key("view.nodeJsDebuggerConfigurationPage.scriptLabel") + String nodeJsDebuggerConfigurationPageViewScriptLabel(); + + @Key("view.nodeJsDebuggerConfigurationPage.pidLabel") + String nodeJsDebuggerConfigurationPageViewPidLable(); +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerResources.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerResources.java new file mode 100644 index 000000000000..f4bb9f81a9cb --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerResources.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.gwt.resources.client.ClientBundle; + +import org.vectomatic.dom.svg.ui.SVGResource; + +/** + * @author Anatolii Bazko + */ +public interface NodeJsDebuggerResources extends ClientBundle { + + /** Returns the icon for NodeJs debugger configurations. */ + @Source("configuration/nodejs-debugger-configuration-type.svg") + SVGResource nodeJsDebugConfigurationType(); +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenter.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenter.java new file mode 100644 index 000000000000..20e2a02c3a65 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenter.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.gwt.user.client.ui.AcceptsOneWidget; +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.debug.DebugConfiguration; +import org.eclipse.che.ide.api.debug.DebugConfigurationPage; +import org.eclipse.che.ide.extension.machine.client.command.valueproviders.CurrentProjectPathProvider; + +import java.util.Map; + +import static org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebugger.ConnectionProperties.SCRIPT; + +/** + * Page allows to edit NodeJs debug configuration. + * + * @author Anatolii Bazko + */ +@Singleton +public class NodeJsDebuggerConfigurationPagePresenter implements NodeJsDebuggerConfigurationPageView.ActionDelegate, + DebugConfigurationPage { + + private static final String DEFAULT_SCRIPT_NAME = "app.js"; + + private final NodeJsDebuggerConfigurationPageView view; + private final CurrentProjectPathProvider currentProjectPathProvider; + + private DebugConfiguration editedConfiguration; + private String originScriptPath; + private DirtyStateListener listener; + + @Inject + public NodeJsDebuggerConfigurationPagePresenter(NodeJsDebuggerConfigurationPageView view, + CurrentProjectPathProvider currentProjectPathProvider) { + this.view = view; + this.currentProjectPathProvider = currentProjectPathProvider; + + view.setDelegate(this); + } + + @Override + public void resetFrom(DebugConfiguration configuration) { + editedConfiguration = configuration; + originScriptPath = getScriptPath(configuration); + + if (originScriptPath == null) { + String defaultBinaryPath = getDefaultBinaryPath(); + editedConfiguration.getConnectionProperties().put(SCRIPT.toString(), defaultBinaryPath); + originScriptPath = defaultBinaryPath; + } + } + + private String getScriptPath(DebugConfiguration debugConfiguration) { + Map connectionProperties = debugConfiguration.getConnectionProperties(); + return connectionProperties.get(SCRIPT.toString()); + } + + private String getDefaultBinaryPath() { + return currentProjectPathProvider.getKey() + "/" + DEFAULT_SCRIPT_NAME; + } + + @Override + public void go(AcceptsOneWidget container) { + container.setWidget(view); + view.setScriptPath(getScriptPath(editedConfiguration)); + } + + @Override + public boolean isDirty() { + return !originScriptPath.equals(getScriptPath(editedConfiguration)); + } + + @Override + public void setDirtyStateListener(DirtyStateListener listener) { + this.listener = listener; + } + + @Override + public void onScriptPathChanged() { + final Map connectionProperties = editedConfiguration.getConnectionProperties(); + connectionProperties.put(SCRIPT.toString(), view.getScriptPath()); + + editedConfiguration.setConnectionProperties(connectionProperties); + listener.onDirtyStateChanged(); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageView.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageView.java new file mode 100644 index 000000000000..4cd89cfce7a7 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageView.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import org.eclipse.che.ide.api.mvp.View; + +/** + * The view of {@link NodeJsDebuggerConfigurationPagePresenter}. + * + * @author Anatolii Bazko + */ +public interface NodeJsDebuggerConfigurationPageView extends View { + + /** Returns path to the binary. */ + String getScriptPath(); + + /** Sets path to the binary. */ + void setScriptPath(String path); + + /** Action handler for the view's controls. */ + interface ActionDelegate { + + /** Called when 'Binary Path' has been changed. */ + void onScriptPathChanged(); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.java new file mode 100644 index 000000000000..e92360e6b352 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.KeyUpEvent; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.UiHandler; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.TextBox; +import com.google.gwt.user.client.ui.Widget; + +/** + * The implementation of {@link NodeJsDebuggerConfigurationPageView}. + * + * @author Anatolii Bazko + */ +public class NodeJsDebuggerConfigurationPageViewImpl implements NodeJsDebuggerConfigurationPageView { + + private static final NodeJsDebugConfigurationPageViewImplUiBinder UI_BINDER = + GWT.create(NodeJsDebugConfigurationPageViewImplUiBinder.class); + + private final FlowPanel rootElement; + + @UiField + TextBox scriptPath; + + private ActionDelegate delegate; + + public NodeJsDebuggerConfigurationPageViewImpl() { + rootElement = UI_BINDER.createAndBindUi(this); + } + + @Override + public void setDelegate(ActionDelegate delegate) { + this.delegate = delegate; + } + + @Override + public Widget asWidget() { + return rootElement; + } + + @Override + public String getScriptPath() { + return scriptPath.getValue(); + } + + @Override + public void setScriptPath(String path) { + this.scriptPath.setValue(path); + } + + @UiHandler({"scriptPath"}) + void onScriptPathKeyUp(KeyUpEvent event) { + delegate.onScriptPathChanged(); + } + + interface NodeJsDebugConfigurationPageViewImplUiBinder extends UiBinder { + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.ui.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.ui.xml new file mode 100644 index 000000000000..96e69e705f6f --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.ui.xml @@ -0,0 +1,21 @@ + + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationType.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationType.java new file mode 100644 index 000000000000..14a12579f654 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationType.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.debug.DebugConfiguration; +import org.eclipse.che.ide.api.debug.DebugConfigurationPage; +import org.eclipse.che.ide.api.debug.DebugConfigurationType; +import org.eclipse.che.ide.api.icon.Icon; +import org.eclipse.che.ide.api.icon.IconRegistry; +import org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebugger; +import org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebuggerResources; + +/** + * NodeJs debug configuration type. + * + * @author Anatolii Bazko + */ +@Singleton +public class NodeJsDebuggerConfigurationType implements DebugConfigurationType { + + public static final String DISPLAY_NAME = "NodeJs"; + + private final NodeJsDebuggerConfigurationPagePresenter page; + + @Inject + public NodeJsDebuggerConfigurationType(NodeJsDebuggerConfigurationPagePresenter page, + IconRegistry iconRegistry, + NodeJsDebuggerResources resources) { + this.page = page; + iconRegistry.registerIcon(new Icon(NodeJsDebugger.ID + ".debug.configuration.type.icon", resources.nodeJsDebugConfigurationType())); + } + + @Override + public String getId() { + return NodeJsDebugger.ID; + } + + @Override + public String getDisplayName() { + return DISPLAY_NAME; + } + + @Override + public DebugConfigurationPage getConfigurationPage() { + return page; + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/NodeJsDebugger.gwt.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/NodeJsDebugger.gwt.xml new file mode 100644 index 000000000000..8b761f90ffad --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/NodeJsDebugger.gwt.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.properties b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.properties new file mode 100644 index 000000000000..c80fa2b8c6c1 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.properties @@ -0,0 +1,16 @@ +# +# Copyright (c) 2012-2016 Codenvy, S.A. +# 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: +# Codenvy, S.A. - initial API and implementation +# + +# NodeJsDebuggerConfigurationPage +view.nodeJsDebuggerConfigurationPage.hostLabel=Host +view.nodeJsDebuggerConfigurationPage.portLabel=Port +view.nodeJsDebuggerConfigurationPage.pidLabel=PID +view.nodeJsDebuggerConfigurationPage.scriptLabel=Script diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/configuration/nodejs-debugger-configuration-type.svg b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/configuration/nodejs-debugger-configuration-type.svg new file mode 100644 index 000000000000..41ad226705ff --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/configuration/nodejs-debugger-configuration-type.svg @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java new file mode 100644 index 000000000000..7733ee642885 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.gwt.user.client.ui.AcceptsOneWidget; + +import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.debug.DebugConfiguration; +import org.eclipse.che.ide.api.debug.DebugConfigurationPage; +import org.eclipse.che.ide.api.machine.MachineServiceClient; +import org.eclipse.che.ide.api.machine.RecipeServiceClient; +import org.eclipse.che.ide.extension.machine.client.command.valueproviders.CurrentProjectPathProvider; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; + +import java.util.Map; + +import static org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebugger.ConnectionProperties.SCRIPT; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** @author Artem Zatsarynnyi */ +@RunWith(MockitoJUnitRunner.class) +public class NodeJsDebuggerConfigurationPagePresenterTest { + + private static final String HOST = "localhost"; + private static final int PORT = 8000; + + @Mock + private NodeJsDebuggerConfigurationPageView pageView; + @Mock + private DebugConfiguration configuration; + @Mock + private CurrentProjectPathProvider currentProjectPathProvider; + @Mock + private AppContext appContext; + @Mock + private RecipeServiceClient recipeServiceClient; + @Mock + private MachineServiceClient machineServiceClient; + + @InjectMocks + private NodeJsDebuggerConfigurationPagePresenter pagePresenter; + + @Before + public void setUp() { + when(configuration.getHost()).thenReturn(HOST); + when(configuration.getPort()).thenReturn(PORT); + + pagePresenter.resetFrom(configuration); + } + + @Test + public void testResetting() throws Exception { + verify(configuration, atLeastOnce()).getConnectionProperties(); + verify(currentProjectPathProvider).getKey(); + } + + @Test + public void testGo() throws Exception { + AcceptsOneWidget container = Mockito.mock(AcceptsOneWidget.class); + when(machineServiceClient.getMachines(appContext.getWorkspaceId())).thenReturn(mock(Promise.class)); + + pagePresenter.go(container); + + verify(container).setWidget(eq(pageView)); + verify(configuration, atLeastOnce()).getConnectionProperties(); + verify(pageView).setScriptPath(anyString()); + } + + @Test + public void testOnBinaryPathChanged() throws Exception { + String binPath = "/path"; + when(pageView.getScriptPath()).thenReturn(binPath); + + final DebugConfigurationPage.DirtyStateListener listener = mock(DebugConfigurationPage.DirtyStateListener.class); + pagePresenter.setDirtyStateListener(listener); + + pagePresenter.onScriptPathChanged(); + + verify(pageView).getScriptPath(); + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(Map.class); + + verify(configuration).setConnectionProperties(argumentCaptor.capture()); + Map argumentCaptorValue = argumentCaptor.getValue(); + assertEquals(binPath, argumentCaptorValue.get(SCRIPT.toString())); + + verify(listener).onDirtyStateChanged(); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationTypeTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationTypeTest.java new file mode 100644 index 000000000000..72e71ba271be --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationTypeTest.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.gwtmockito.GwtMockitoTestRunner; + +import org.eclipse.che.ide.api.debug.DebugConfiguration; +import org.eclipse.che.ide.api.debug.DebugConfigurationPage; +import org.eclipse.che.ide.api.icon.IconRegistry; +import org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebugger; +import org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebuggerResources; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +import static org.junit.Assert.assertEquals; + +/** @author Anatolii Bazko */ +@RunWith(GwtMockitoTestRunner.class) +public class NodeJsDebuggerConfigurationTypeTest { + + @Mock + private NodeJsDebuggerResources resources; + @Mock + private NodeJsDebuggerConfigurationPagePresenter nodeJsDebuggerConfigurationPagePresenter; + @Mock + private IconRegistry iconRegistry; + + @InjectMocks + private NodeJsDebuggerConfigurationType nodeJsDebuggerConfigurationType; + + @Test + public void testGetId() throws Exception { + final String id = nodeJsDebuggerConfigurationType.getId(); + + assertEquals(NodeJsDebugger.ID, id); + } + + @Test + public void testGetDisplayName() throws Exception { + final String displayName = nodeJsDebuggerConfigurationType.getDisplayName(); + + assertEquals(NodeJsDebuggerConfigurationType.DISPLAY_NAME, displayName); + } + + @Test + public void testGetConfigurationPage() throws Exception { + final DebugConfigurationPage page = nodeJsDebuggerConfigurationType.getConfigurationPage(); + + assertEquals(nodeJsDebuggerConfigurationPagePresenter, page); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/resources/logback-test.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/resources/logback-test.xml new file mode 100644 index 000000000000..e8898502279e --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/resources/logback-test.xml @@ -0,0 +1,26 @@ + + + + + + + %-41(%date[%.15thread]) %-45([%-5level] [%.30logger{30} %L]) - %msg%n + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/pom.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/pom.xml new file mode 100644 index 000000000000..77112c8d7133 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/pom.xml @@ -0,0 +1,117 @@ + + + + 4.0.0 + + che-plugin-nodejs-debugger-parent + org.eclipse.che.plugin + 5.0.0-M5-SNAPSHOT + + che-plugin-nodejs-debugger-server + jar + Che Plugin :: NodeJs Debugger :: Server + + + com.google.code.gson + gson + + + com.google.guava + guava + + + com.google.inject + guice + + + com.google.inject.extensions + guice-multibindings + + + org.eclipse.che.core + che-core-api-debug + + + org.eclipse.che.core + che-core-api-debug-shared + + + org.eclipse.che.core + che-core-commons-annotations + + + org.eclipse.che.core + che-core-commons-inject + + + org.eclipse.che.core + che-core-commons-lang + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + test + + + org.mockito + mockito-all + test + + + org.testng + testng + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + com.mycila + license-maven-plugin + + + **/*.js + + + + + + + + nodejs-debugger-tests + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugProcess.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugProcess.java new file mode 100644 index 000000000000..7e6e56a26741 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugProcess.java @@ -0,0 +1,248 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; + +import org.eclipse.che.commons.lang.IoUtil; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import static java.lang.Math.min; + +/** + * Wrapper over NodeJs process is being run. + * Communication is performed through standard input/output streams. + * + * @author Anatoliy Bazko + */ +public class NodeJsDebugProcess implements NodeJsProcessObservable { + private static final Logger LOG = LoggerFactory.getLogger(NodeJsDebugProcess.class); + private static final int MAX_OUTPUT = 4096; + + private static final String NODEJS_COMMAND = detectNodeJsCommand(); + + private final Process process; + private final String outputSeparator; + private final ScheduledExecutorService executor; + private final BufferedWriter processWriter; + + private final List observers; + + private NodeJsDebugProcess(String outputSeparator, String... options) throws NodeJsDebuggerException { + this.observers = new CopyOnWriteArrayList<>(); + this.outputSeparator = outputSeparator; + + List commands = new ArrayList<>(1 + options.length); + commands.add(NODEJS_COMMAND); + commands.addAll(Arrays.asList(options)); + + ProcessBuilder processBuilder = new ProcessBuilder(commands); + try { + process = processBuilder.start(); + } catch (IOException e) { + throw new NodeJsDebuggerException("NodeJs process failed.", e); + } + + processWriter = new BufferedWriter(new OutputStreamWriter(process.getOutputStream())); + + executor = Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setNameFormat("nodejs-debugger-%d") + .setDaemon(true) + .build()); + executor.scheduleWithFixedDelay(new OutputReader(), 0, 100, TimeUnit.MILLISECONDS); + } + + public static NodeJsDebugProcess start(String file) throws NodeJsDebuggerException { + return new NodeJsDebugProcess("debug> ", "debug", "--debug-brk", file); + } + + @Override + public void addObserver(NodeJsProcessObserver observer) { + observers.add(observer); + } + + @Override + public void removeObserver(NodeJsProcessObserver observer) { + observers.remove(observer); + } + + /** + * Stops process. + */ + void stop() { + try { + send("quit"); + } catch (NodeJsDebuggerException e) { + LOG.warn(e.getMessage()); + } + + executor.shutdown(); + try { + if (!executor.awaitTermination(10, TimeUnit.SECONDS)) { + executor.shutdownNow(); + if (!executor.awaitTermination(10, TimeUnit.SECONDS)) { + LOG.warn("Unable to terminate main pool"); + } + } + } catch (InterruptedException e) { + LOG.warn(e.getMessage()); + } + + + process.destroy(); + try { + if (!process.waitFor(10, TimeUnit.SECONDS)) { + LOG.error("Unable to terminate NodeJs"); + } + } catch (InterruptedException e) { + LOG.warn(e.getMessage()); + } + + try { + processWriter.close(); + } catch (IOException e) { + LOG.warn("Failed to close NodeJs process output stream", e); + } + observers.clear(); + } + + public synchronized void send(String command) throws NodeJsDebuggerException { + LOG.debug("Execute: {}", command); + + if (!process.isAlive()) { + throw new NodeJsDebuggerTerminatedException("NodeJs process is terminated."); + } + + try { + processWriter.write(command); + processWriter.newLine(); + processWriter.flush(); + } catch (IOException e) { + LOG.error(String.format("Command execution <%s> failed", command), e); + } + } + + + /** + * Continuously reads process output and store in the {@code #outputs}. + */ + private class OutputReader implements Runnable { + private final StringBuffer outputBuffer; + + public OutputReader() { + this.outputBuffer = new StringBuffer(); + } + + @Override + public void run() { + try { + InputStream in = getInput(); + if (in != null) { + String outputData = read(in); + if (!outputData.isEmpty()) { + outputBuffer.append(outputData); + if (outputBuffer.length() > MAX_OUTPUT) { + outputBuffer.delete(0, outputBuffer.length() - MAX_OUTPUT); + } + + extractOutputs(); + } + } + } catch (IOException e) { + LOG.error(e.getMessage(), e); + } + } + + private InputStream getInput() throws IOException { + return hasError() ? process.getErrorStream() + : (hasInput() ? (hasError() ? process.getErrorStream() + : process.getInputStream()) + : null); + } + + private void extractOutputs() { + int indexOf; + while ((indexOf = outputBuffer.indexOf(outputSeparator)) >= 0) { + NodeJsOutput nodeJsOutput = NodeJsOutput.of(outputBuffer.substring(0, indexOf)); + outputBuffer.delete(0, indexOf + outputSeparator.length()); + + notifyObservers(nodeJsOutput); + } + } + + private boolean hasError() throws IOException { + return process.getErrorStream().available() != 0; + } + + private boolean hasInput() throws IOException { + return process.getInputStream().available() != 0; + } + + private String read(InputStream in) throws IOException { + int available = min(in.available(), MAX_OUTPUT); + byte[] buf = new byte[available]; + int read = in.read(buf, 0, available); + + return new String(buf, 0, read, StandardCharsets.UTF_8); + } + } + + private void notifyObservers(NodeJsOutput nodeJsOutput) { + LOG.debug("{}{}", outputSeparator, nodeJsOutput.getOutput()); + + for (NodeJsProcessObserver observer : observers) { + try { + if (observer.onOutputProduced(nodeJsOutput)) { + break; + } + } catch (NodeJsDebuggerException e) { + LOG.error(e.getMessage(), e); + } + } + } + + /** + * Returns NodeJs command to run: either {@code nodejs} or {@code node}. + */ + private static String detectNodeJsCommand() { + String detectionCommand = "if command -v nodejs >/dev/null 2>&1; then echo -n 'nodejs'; else echo -n 'node'; fi"; + ProcessBuilder builder = new ProcessBuilder("sh", "-c", detectionCommand); + + try { + Process process = builder.start(); + int resultCode = process.waitFor(); + if (resultCode != 0) { + String errMsg = IoUtil.readAndCloseQuietly(process.getErrorStream()); + throw new IllegalStateException("NodeJs not found. " + errMsg); + } + + return IoUtil.readAndCloseQuietly(process.getInputStream()); + } catch (IOException | InterruptedException e) { + throw new IllegalStateException("NodeJs not found", e); + } + } + +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugger.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugger.java new file mode 100644 index 000000000000..960e8baeff95 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugger.java @@ -0,0 +1,309 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.api.debug.shared.model.DebuggerInfo; +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.SimpleValue; +import org.eclipse.che.api.debug.shared.model.StackFrameDump; +import org.eclipse.che.api.debug.shared.model.Variable; +import org.eclipse.che.api.debug.shared.model.VariablePath; +import org.eclipse.che.api.debug.shared.model.action.ResumeAction; +import org.eclipse.che.api.debug.shared.model.action.StartAction; +import org.eclipse.che.api.debug.shared.model.action.StepIntoAction; +import org.eclipse.che.api.debug.shared.model.action.StepOutAction; +import org.eclipse.che.api.debug.shared.model.action.StepOverAction; +import org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl; +import org.eclipse.che.api.debug.shared.model.impl.DebuggerInfoImpl; +import org.eclipse.che.api.debug.shared.model.impl.SimpleValueImpl; +import org.eclipse.che.api.debug.shared.model.impl.StackFrameDumpImpl; +import org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl; +import org.eclipse.che.api.debug.shared.model.impl.event.DisconnectEventImpl; +import org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl; +import org.eclipse.che.api.debugger.server.Debugger; +import org.eclipse.che.api.debugger.server.exceptions.DebuggerException; +import org.eclipse.che.commons.annotation.Nullable; +import org.eclipse.che.plugin.nodejsdbg.server.command.NodeJsDebugCommandsLibrary; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.regex.Pattern; + +/** + * Server side NodeJs debugger. + * + * @author Anatoliy Bazko + */ +public class NodeJsDebugger implements Debugger { + private static final Logger LOG = LoggerFactory.getLogger(NodeJsDebugger.class); + + private final Integer pid; + private final URI uri; + private final String name; + private final String version; + private final String script; + + private final NodeJsDebugProcess nodeJsDebugProcess; + private final DebuggerCallback debuggerCallback; + private final NodeJsDebugCommandsLibrary library; + private final Set pendingBreakpoints; + + NodeJsDebugger(@Nullable Integer pid, + @Nullable URI uri, + @Nullable String script, + NodeJsDebugProcess nodeJsDebugProcess, + DebuggerCallback debuggerCallback) throws NodeJsDebuggerException { + this.pid = pid; + this.uri = uri; + this.script = script; + this.nodeJsDebugProcess = nodeJsDebugProcess; + this.library = new NodeJsDebugCommandsLibrary(nodeJsDebugProcess); + this.name = library.getName(); + this.version = library.getVersion(); + this.debuggerCallback = debuggerCallback; + this.pendingBreakpoints = new CopyOnWriteArraySet<>(); + } + + public static NodeJsDebugger newInstance(@Nullable Integer pid, + @Nullable URI uri, + String file, + DebuggerCallback debuggerCallback) throws DebuggerException { + NodeJsDebugProcess nodeJsDebugProcess = NodeJsDebugProcess.start(file); + return new NodeJsDebugger(pid, + uri, + file, + nodeJsDebugProcess, + debuggerCallback); + } + + @Override + public DebuggerInfo getInfo() throws DebuggerException { + return new DebuggerInfoImpl(uri == null ? "" : uri.getHost(), + uri == null ? -1 : uri.getPort(), + name, + version, + pid == null ? -1 : pid, + script); + } + + @Override + public void disconnect() { + debuggerCallback.onEvent(new DisconnectEventImpl()); + nodeJsDebugProcess.stop(); + } + + @Override + public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException { + try { + Location location = breakpoint.getLocation(); + pendingBreakpoints.add(location); + library.setBreakpoint(location.getTarget(), location.getLineNumber()); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't add breakpoint: " + breakpoint + ". " + e.getMessage(), e); + } + } + + @Override + public void deleteBreakpoint(Location location) throws DebuggerException { + try { + pendingBreakpoints.remove(location); + library.clearBreakpoint(location.getTarget(), location.getLineNumber()); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't delete breakpoint: " + location + ". " + e.getMessage(), e); + } + } + + @Override + public void deleteAllBreakpoints() throws DebuggerException { + try { + for (Breakpoint breakpoint : library.getBreakpoints()) { + try { + deleteBreakpoint(breakpoint.getLocation()); + } catch (NodeJsDebuggerException e) { + LOG.error("Can't delete breakpoint: {}", breakpoint.getLocation(), e); + } + } + pendingBreakpoints.clear(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't delete all breakpoints. " + e.getMessage(), e); + } + } + + @Override + public List getAllBreakpoints() throws DebuggerException { + try { + return library.getBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't get all breakpoints. " + e.getMessage(), e); + } + } + + @Override + public void start(StartAction action) throws DebuggerException { + try { + for (Breakpoint breakpoint : action.getBreakpoints()) { + Location location = breakpoint.getLocation(); + library.setBreakpoint(location.getTarget(), location.getLineNumber()); + pendingBreakpoints.add(location); + } + + debuggerCallback.onEvent(new SuspendEventImpl(library.backtrace())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Start error. " + e.getMessage(), e); + } + } + + @Override + public void stepOver(StepOverAction action) throws DebuggerException { + try { + debuggerCallback.onEvent(new SuspendEventImpl(library.next())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Step over error. " + e.getMessage(), e); + } + } + + @Override + public void stepInto(StepIntoAction action) throws DebuggerException { + try { + debuggerCallback.onEvent(new SuspendEventImpl(library.stepIn())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Step into error. " + e.getMessage(), e); + } + } + + @Override + public void stepOut(StepOutAction action) throws DebuggerException { + try { + debuggerCallback.onEvent(new SuspendEventImpl(library.stepOut())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Step out error. " + e.getMessage(), e); + } + } + + @Override + public void resume(ResumeAction action) throws DebuggerException { + try { + debuggerCallback.onEvent(new SuspendEventImpl(library.cont())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Resume error. " + e.getMessage(), e); + } + } + + @Override + public void setValue(Variable variable) throws DebuggerException { + try { + List path = variable.getVariablePath().getPath(); + if (path.isEmpty()) { + throw new DebuggerException("Variable path is empty"); + } + library.setVar(path.get(0), variable.getValue()); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't set value for " + variable.getName() + ". " + e.getMessage(), e); + } + } + + @Override + public SimpleValue getValue(VariablePath variablePath) throws DebuggerException { + try { + List path = variablePath.getPath(); + if (path.isEmpty()) { + throw new DebuggerException("Variable path is empty"); + } + + return new SimpleValueImpl(Collections.emptyList(), library.getVar(path.get(0))); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't get value for " + variablePath + ". " + e.getMessage(), e); + } + } + + @Override + public String evaluate(String expression) throws DebuggerException { + try { + return library.evaluate(expression); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't evaluate '" + expression + "'. " + e.getMessage(), e); + } + } + + @Override + public StackFrameDump dumpStackFrame() throws DebuggerException { + return new StackFrameDumpImpl(Collections.emptyList(), Collections.emptyList()); + } + + private void checkActivatedBreakpoints() throws DebuggerException { + Set brk2Remove = new HashSet<>(); + for (Breakpoint breakpoint : library.getBreakpoints()) { + for (Location pending : pendingBreakpoints) { + Location added = breakpoint.getLocation(); + if (added.getLineNumber() == pending.getLineNumber() && + Pattern.compile(added.getTarget()).matcher(pending.getTarget()).matches()) { + + BreakpointImpl brkToSend = new BreakpointImpl(pending, breakpoint.isEnabled(), breakpoint.getCondition()); + debuggerCallback.onEvent(new BreakpointActivatedEventImpl(brkToSend)); + brk2Remove.add(pending); + } + } + } + + pendingBreakpoints.removeAll(brk2Remove); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerFactory.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerFactory.java new file mode 100644 index 000000000000..8445de3f7c79 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerFactory.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import org.eclipse.che.api.debugger.server.Debugger; +import org.eclipse.che.api.debugger.server.DebuggerFactory; +import org.eclipse.che.api.debugger.server.exceptions.DebuggerException; + +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Map; + +import static com.google.common.base.Strings.isNullOrEmpty; +import static java.util.stream.Collectors.toMap; + +/** + * Factory to create nodejs debugger instance. + * Allowed the following connection properties: + * + * uri - connects to the process via the URI such as localhost:5858 + * pid - connects to the process via the pid + * script - entrypoint to start debugger + * + * @author Anatoliy Bazko + */ +public class NodeJsDebuggerFactory implements DebuggerFactory { + private static final String TYPE = "nodejsdbg"; + + @Override + public String getType() { + return TYPE; + } + + @Override + public Debugger create(Map properties, Debugger.DebuggerCallback debuggerCallback) throws DebuggerException { + Map normalizedProps = properties.entrySet() + .stream() + .collect(toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue)); + + + Integer pid = null; + URI uri = null; + + String pidStr = normalizedProps.get("pid"); + if (!isNullOrEmpty(pidStr)) { + try { + pid = Integer.valueOf(pidStr); + } catch (NumberFormatException e) { + throw new DebuggerException(String.format("Illegal 'pid' format %s. Debugger can't be started.", pidStr)); + } + } + + String uriStr = normalizedProps.get("uri"); + if (!isNullOrEmpty(uriStr)) { + try { + uri = URI.create(uriStr); + } catch (IllegalArgumentException e) { + throw new DebuggerException(String.format("Illegal 'uri' format %s. Debugger can't be started.", uriStr)); + } + } + + String script = normalizedProps.get("script"); + if (!isNullOrEmpty(script) && !Files.exists(Paths.get(script))) { + throw new DebuggerException(String.format("Script '%s' to debug not found. Debugger can't be started.", script)); + } + + if (isNullOrEmpty(pidStr) && isNullOrEmpty(uriStr) && isNullOrEmpty(script)) { + throw new DebuggerException("Unrecognized debug connection options. Allowed only: pid, uri or script."); + } + + return NodeJsDebugger.newInstance(pid, uri, script, debuggerCallback); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerModule.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerModule.java new file mode 100644 index 000000000000..dc1d64d1cf96 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerModule.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import com.google.inject.AbstractModule; +import com.google.inject.multibindings.Multibinder; + +import org.eclipse.che.api.debugger.server.DebuggerFactory; +import org.eclipse.che.inject.DynaModule; + +/** + * @author Anatoliy Bazko + */ +@DynaModule +public class NodeJsDebuggerModule extends AbstractModule { + + @Override + protected void configure() { + Multibinder.newSetBinder(binder(), DebuggerFactory.class).addBinding().to(NodeJsDebuggerFactory.class); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsOutput.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsOutput.java new file mode 100644 index 000000000000..b57081874409 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsOutput.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +/** + * Wrapper for NodeJs output. + * + * @author Anatoliy Bazko + */ +public class NodeJsOutput { + private final String output; + + private NodeJsOutput(String output) { + this.output = output; + } + + public static NodeJsOutput of(String output) { + return new NodeJsOutput(strip(output)); + } + + public String getOutput() { + return output; + } + + public boolean isEmpty() { + return output.isEmpty(); + } + + private static String strip(String output) { + if (output.endsWith("\n")) { + output = output.substring(0, output.length() - 1); + } + + return output.replaceAll("\\u001B\\[[0-9][0-9]m", "") + .replace("\b", ""); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObservable.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObservable.java new file mode 100644 index 000000000000..ec5af8e2da4d --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObservable.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +/** + * @author Anatolii Bazko + */ +public interface NodeJsProcessObservable { + + /** + * Adds observer. + */ + void addObserver(NodeJsProcessObserver observer); + + /** + * Removes observer. + */ + void removeObserver(NodeJsProcessObserver observer); +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObserver.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObserver.java new file mode 100644 index 000000000000..bdadd41dde70 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObserver.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; + +/** + * @author Anatolii Bazko + */ +public interface NodeJsProcessObserver { + + /** + * Is occurred when a nodejs generates a new output. + * + * Returns {@code true} if no processing requires after. + */ + boolean onOutputProduced(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerException; +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommand.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommand.java new file mode 100644 index 000000000000..c349287e2c14 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommand.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.command; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsDebugProcess; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsProcessObserver; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; + +import java.util.concurrent.Future; + +/** + * Any nodejs command to execute in debug. + * + * @see NodeJsDebugProcess + * @see NodeJsDebugCommandsLibrary + * + * @author Anatolii Bazko + */ +public interface NodeJsDebugCommand extends NodeJsProcessObserver { + + /** + * Executes command. Deferred result is returned. + * + * @param process + * the target process + * @return the result of command execution + * + * @throws NodeJsDebuggerException + * if execution failed + */ + Future execute(NodeJsDebugProcess process) throws NodeJsDebuggerException; +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandImpl.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandImpl.java new file mode 100644 index 000000000000..aa46d74c3f42 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandImpl.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.command; + +import com.google.common.util.concurrent.SettableFuture; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsDebugProcess; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsOutputParser; + +import java.util.concurrent.Future; + +/** + * Basic implementation of {@link NodeJsDebugCommand}. + * When command is executed, it scans outputs until appropriate found, parses it and returns result of execution. + * + * @author Anatolii Bazko + */ +public class NodeJsDebugCommandImpl implements NodeJsDebugCommand { + + private final SettableFuture result; + public final NodeJsOutputParser parser; + private final String input; + + public NodeJsDebugCommandImpl(NodeJsOutputParser parser, String input) { + this.parser = parser; + this.input = input; + this.result = SettableFuture.create(); + } + + @Override + public Future execute(NodeJsDebugProcess process) throws NodeJsDebuggerException { + process.send(input); + return result; + } + + @Override + public boolean onOutputProduced(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + if (parser.match(nodeJsOutput)) { + T t = parser.parse(nodeJsOutput); + return result.set(t); + } + + return false; + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandsLibrary.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandsLibrary.java new file mode 100644 index 000000000000..6956b6f00248 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandsLibrary.java @@ -0,0 +1,261 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.command; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsDebugProcess; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsDebugger; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsBackTraceParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsBreakpointsParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsBreakpointsParser.Breakpoints; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsOutputParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsOutputParser.NodeJsOutputRegExpParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsScriptsParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsScriptsParser.Scripts; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsStepParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.file.Paths; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.regex.Pattern; + +import static java.lang.String.format; + +/** + * Library of the NodeJs debug commands: https://nodejs.org/api/debugger.html + * + * @author Anatolii Bazko + */ +public class NodeJsDebugCommandsLibrary { + private static final Logger LOG = LoggerFactory.getLogger(NodeJsDebugger.class); + private static final Pattern PROCESS_TITLE_COMMAND_OUTPUT_PATTERN = Pattern.compile("^'?(node|nodejs)'?$"); + private static final Pattern PROCESS_VERSION_COMMAND_OUTPUT_PATTERN = Pattern.compile("^'?(v|)[0-9\\.]+'?$"); + private static final Pattern PROCESS_PID_COMMAND_OUTPUT_PATTERN = Pattern.compile("^[0-9]+$"); + private static final Pattern RUN_COMMAND_OUTPUT_PATTERN = Pattern.compile("(break in.*|App is already running.*)"); + + private final NodeJsDebugProcess process; + private final String name; + private final String version; + private final int pid; + + public NodeJsDebugCommandsLibrary(NodeJsDebugProcess process) throws NodeJsDebuggerException { + this.process = process; + run(); + + this.name = detectName(); + this.version = detectVersion(); + this.pid = detectPid(); + } + + /** + * Execute {@code bt} command. + */ + public Location backtrace() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("bt", NodeJsBackTraceParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code sb} command. + */ + public Void setBreakpoint(String scriptPath, int lineNumber) throws NodeJsDebuggerException { + String scriptName = Paths.get(scriptPath).getFileName().toString(); + String input = format("sb('%s', %d)", scriptName, lineNumber); + NodeJsDebugCommand command = createCommand(input, NodeJsOutputParser.VOID); + return doExecute(command); + } + + /** + * Execute {@code breakpoints} command. + * @see NodeJsBackTraceParser + */ + public List getBreakpoints() throws NodeJsDebuggerException { + NodeJsDebugCommand breakpointsCommand = createCommand("breakpoints", NodeJsBreakpointsParser.INSTANCE); + List breakpoints = doExecute(breakpointsCommand).getAll(); + + NodeJsDebugCommand scriptsCommand = createCommand("scripts", NodeJsScriptsParser.INSTANCE); + Map scripts = doExecute(scriptsCommand).getAll(); + + for (int i = 0; i < breakpoints.size(); i++) { + Breakpoint breakpoint = breakpoints.get(i); + Location location = breakpoint.getLocation(); + + String newTarget; + String[] target = location.getTarget().split(":"); + if (target.length != 2) { + LOG.error(format("Illegal breakpoint location format %s", target)); + continue; + } + + if (target[0].equals("scriptId")) { + newTarget = scripts.get((int)Double.parseDouble(target[1])); + } else { + newTarget = target[1]; + } + + Location newLocation = new LocationImpl(newTarget, location.getLineNumber()); + Breakpoint newBreakpoint = new BreakpointImpl(newLocation, breakpoint.isEnabled(), breakpoint.getCondition()); + breakpoints.set(i, newBreakpoint); + } + + return breakpoints; + } + + /** + * Execute {@code cb} command. + */ + public Void clearBreakpoint(String script, int lineNumber) throws NodeJsDebuggerException { + String input = format("cb('%s', %d)", script, lineNumber); + NodeJsDebugCommand command = createCommand(input, NodeJsOutputParser.VOID); + return doExecute(command); + } + + /** + * Execute {@code run} command. + */ + public String run() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("run", + new NodeJsOutputRegExpParser(RUN_COMMAND_OUTPUT_PATTERN)); + return doExecute(nextCommand); + } + + + /** + * Execute {@code next} command. + */ + public Location next() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("next", NodeJsStepParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code cont} command. + */ + public Location cont() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("cont", NodeJsStepParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code step in} command. + */ + public Location stepIn() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("step", NodeJsStepParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code step out} command. + */ + public Location stepOut() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("out", NodeJsStepParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code exec} command to set a new value for the giving variable. + */ + public Void setVar(String varName, String newValue) throws NodeJsDebuggerException { + String input = format("exec %s=%s", varName, newValue); + NodeJsDebugCommand command = createCommand(input, NodeJsOutputParser.VOID); + return doExecute(command); + } + + /** + * Execute {@code exec} command to get value for the giving variable. + */ + public String getVar(String varName) throws NodeJsDebuggerException { + String line = format("exec %s", varName); + NodeJsDebugCommand command = createCommand(line, NodeJsOutputParser.DEFAULT); + return doExecute(command); + } + + /** + * Execute {@code exec} command to evaluate expression. + */ + public String evaluate(String expression) throws NodeJsDebuggerException { + String line = format("exec %s", expression); + NodeJsDebugCommand command = createCommand(line, NodeJsOutputParser.DEFAULT); + return doExecute(command); + } + + /** + * Returns NodeJs version. + */ + public String getVersion() { + return version; + } + + /** + * Returns NodeJs title. + */ + public String getName() { + return name; + } + + /** + * Returns NodeJs pid. + */ + public int getPid() { + return pid; + } + + /** + * Returns NodeJs version. + */ + private String detectVersion() throws NodeJsDebuggerException { + NodeJsDebugCommand command = createCommand("process.version", + new NodeJsOutputRegExpParser(PROCESS_VERSION_COMMAND_OUTPUT_PATTERN)); + return doExecute(command); + } + + /** + * Returns NodeJs pid. + */ + private int detectPid() throws NodeJsDebuggerException { + NodeJsDebugCommand command = createCommand("process.pid", + new NodeJsOutputRegExpParser(PROCESS_PID_COMMAND_OUTPUT_PATTERN)); + return Integer.parseInt(doExecute(command)); + } + + /** + * Returns NodeJs title. + */ + private String detectName() throws NodeJsDebuggerException { + NodeJsDebugCommand command = createCommand("process.title", + new NodeJsOutputRegExpParser(PROCESS_TITLE_COMMAND_OUTPUT_PATTERN)); + return doExecute(command); + } + + private V doExecute(NodeJsDebugCommand command) throws NodeJsDebuggerException { + process.addObserver(command); + try { + Future result = command.execute(process); + return result.get(); + } catch (InterruptedException | ExecutionException e) { + throw new NodeJsDebuggerException(e.getMessage(), e); + } finally { + process.removeObserver(command); + } + } + + private NodeJsDebugCommand createCommand(String input, NodeJsOutputParser outputParser) { + return new NodeJsDebugCommandImpl<>(outputParser, input); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerException.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerException.java new file mode 100644 index 000000000000..5fcae57f0502 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerException.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.exception; + +import org.eclipse.che.api.debugger.server.exceptions.DebuggerException; + +/** + * @author Anatoliy Bazko + */ +public class NodeJsDebuggerException extends DebuggerException { + public NodeJsDebuggerException(String message) { + super(message); + } + + public NodeJsDebuggerException(String message, Exception cause) { + super(message, cause); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerParseException.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerParseException.java new file mode 100644 index 000000000000..b7bd25401fea --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerParseException.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.exception; + +import static java.lang.Math.min; + +/** + * @author Anatoliy Bazko + */ +@SuppressWarnings("serial") +public class NodeJsDebuggerParseException extends NodeJsDebuggerException { + + public static final int MAX_OUTPUT_LENGTH = 80; + + public NodeJsDebuggerParseException(Class clazz, String output) { + super("Can't parse '" + + output.substring(0, min(output.length(), MAX_OUTPUT_LENGTH)) + + "' into " + + clazz.getSimpleName()); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerTerminatedException.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerTerminatedException.java new file mode 100644 index 000000000000..9bcf510d9f28 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerTerminatedException.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.exception; + +/** + * @author Anatoliy Bazko + */ +public class NodeJsDebuggerTerminatedException extends NodeJsDebuggerException { + public NodeJsDebuggerTerminatedException(String message) { + super(message); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParser.java new file mode 100644 index 000000000000..9a8b57d50703 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParser.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * {@code backtrace} command parser. + * + * @author Anatoliy Bazko + */ +public class NodeJsBackTraceParser implements NodeJsOutputParser { + + public static final NodeJsBackTraceParser INSTANCE = new NodeJsBackTraceParser(); + public static final Pattern PATTERN = Pattern.compile("#0(.*) (.*):(.*):(.*)"); + + private NodeJsBackTraceParser() { } + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return nodeJsOutput.getOutput().startsWith("#0"); + } + + @Override + public Location parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + String output = nodeJsOutput.getOutput(); + + for (String line : output.split("\n")) { + Matcher matcher = PATTERN.matcher(line); + if (matcher.find()) { + String file = matcher.group(2); + String lineNumber = matcher.group(3); + return new LocationImpl(file, Integer.parseInt(lineNumber)); + } + } + + throw new NodeJsDebuggerParseException(Location.class, output); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParser.java new file mode 100644 index 000000000000..76b4dc5257e8 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParser.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * {@code breakpoints} command parser. + * + * @author Anatoliy Bazko + */ +public class NodeJsBreakpointsParser implements NodeJsOutputParser { + private static final Logger LOG = LoggerFactory.getLogger(NodeJsBreakpointsParser.class); + + public static final NodeJsBreakpointsParser INSTANCE = new NodeJsBreakpointsParser(); + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return nodeJsOutput.getOutput().startsWith("{ breakpoints:"); + } + + @Override + public Breakpoints parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + final List breakpoints = new ArrayList<>(); + + JsonObject json = new JsonParser().parse(nodeJsOutput.getOutput()).getAsJsonObject(); + if (json.has("breakpoints")) { + Iterator iter = json.getAsJsonArray("breakpoints").iterator(); + while (iter.hasNext()) { + JsonObject item = iter.next().getAsJsonObject(); + try { + final String condition = item.has("condition") && !item.get("condition").isJsonNull() + ? item.get("condition").getAsString() + : null; + final boolean isEnabled = item.has("active") && !item.get("active").isJsonNull() && item.get("active").getAsBoolean(); + final int lineNumber = item.get("line").getAsInt(); + + final String target; + String targetType = item.get("type").getAsString(); + + switch (targetType) { + case "scriptId": + target = String.valueOf(item.get("script_id").getAsInt()); + break; + case "scriptRegExp": + target = item.get("script_regexp").getAsString(); + break; + default: + throw new IllegalArgumentException("Unsupported 'type' value: " + targetType); + } + + Location location = new LocationImpl(targetType + ":" + target, lineNumber + 1); + Breakpoint breakpoint = new BreakpointImpl(location, isEnabled, condition); + breakpoints.add(breakpoint); + } catch (Exception e) { + LOG.error("Failed to parse breakpoint: " + item.toString(), e); + } + } + } + + return new Breakpoints(breakpoints); + } + + public static class Breakpoints { + private final List breakpoints; + + private Breakpoints(List breakpoints) {this.breakpoints = breakpoints;} + + public List getAll() { + return breakpoints; + } + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsOutputParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsOutputParser.java new file mode 100644 index 000000000000..c1af509d3130 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsOutputParser.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; + +import java.util.regex.Pattern; + +/** + * @author Anatolii Bazko + */ +public interface NodeJsOutputParser { + + /** + * Indicates if output matches + */ + boolean match(NodeJsOutput nodeJsOutput); + + /** + * Parses {@link NodeJsOutput} into valuable result. + */ + T parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException; + + /** + * Doesn't parse output, just returns as is. + */ + NodeJsOutputParser DEFAULT = new NodeJsOutputParser() { + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return true; + } + + @Override + public String parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + return nodeJsOutput.getOutput(); + } + }; + + /** + * {@link NodeJsOutputParser} when result will be skipped. + */ + NodeJsOutputParser VOID = new NodeJsOutputParser() { + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return true; + } + + @Override + public Void parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + return null; + } + }; + + class NodeJsOutputRegExpParser implements NodeJsOutputParser { + private final Pattern pattern; + + public NodeJsOutputRegExpParser(Pattern pattern) { + this.pattern = pattern; + } + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return pattern.matcher(nodeJsOutput.getOutput()).find(); + } + + @Override + public String parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + return nodeJsOutput.getOutput(); + } + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParser.java new file mode 100644 index 000000000000..6895a99e11a3 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParser.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * {@code scripts} command parser. + * + * @author Anatoliy Bazko + */ +public class NodeJsScriptsParser implements NodeJsOutputParser { + private static final Pattern SCRIPT = Pattern.compile(".* ([0-9]*): (.*)"); + + public static final NodeJsScriptsParser INSTANCE = new NodeJsScriptsParser(); + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + for (String line : nodeJsOutput.getOutput().split("\n")) { + Matcher matcher = SCRIPT.matcher(line); + if (!matcher.find()) { + return false; + } + } + + return !nodeJsOutput.isEmpty(); + } + + @Override + public Scripts parse(NodeJsOutput nodeJsOutput) { + Map scripts = new HashMap<>(); + + for (String line : nodeJsOutput.getOutput().split("\n")) { + Matcher matcher = SCRIPT.matcher(line); + if (matcher.find()) { + int number = Integer.parseInt(matcher.group(1)); + String script = matcher.group(2); + + scripts.put(number, script); + } + } + + return new Scripts(scripts); + } + + public static class Scripts { + private final Map scripts; + + public Scripts(Map scripts) {this.scripts = scripts;} + + public Map getAll() { + return scripts; + } + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParser.java new file mode 100644 index 000000000000..4176d45e78b9 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParser.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * {@code backtrace} command parser. + * + * @author Anatoliy Bazko + */ +public class NodeJsStepParser implements NodeJsOutputParser { + + public static final NodeJsStepParser INSTANCE = new NodeJsStepParser(); + public static final Pattern PATTERN = Pattern.compile("^break in (.*):([0-9]+)"); + + private NodeJsStepParser() { } + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return nodeJsOutput.getOutput().startsWith("break in"); + } + + @Override + public Location parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + String output = nodeJsOutput.getOutput(); + + for (String line : output.split("\n")) { + Matcher matcher = PATTERN.matcher(line); + if (matcher.find()) { + String file = matcher.group(1); + String lineNumber = matcher.group(2); + return new LocationImpl(file, Integer.parseInt(lineNumber)); + } + } + + throw new NodeJsDebuggerParseException(Location.class, output); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerTest.java new file mode 100644 index 000000000000..a75a251df5e7 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerTest.java @@ -0,0 +1,122 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.api.debug.shared.model.DebuggerInfo; +import org.eclipse.che.api.debug.shared.model.event.BreakpointActivatedEvent; +import org.eclipse.che.api.debug.shared.model.event.SuspendEvent; +import org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.api.debug.shared.model.impl.action.StepIntoActionImpl; +import org.eclipse.che.api.debug.shared.model.impl.action.StepOutActionImpl; +import org.eclipse.che.api.debug.shared.model.impl.action.StepOverActionImpl; +import org.eclipse.che.api.debugger.server.Debugger; +import org.mockito.ArgumentCaptor; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.List; + +import static com.google.common.base.Strings.isNullOrEmpty; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsDebuggerTest { + private NodeJsDebugger debugger; + private Debugger.DebuggerCallback callback; + + @BeforeMethod + public void setUp() throws Exception { + String file = NodeJsDebuggerTest.class.getResource("/app.js").getFile(); + + callback = mock(Debugger.DebuggerCallback.class); + debugger = NodeJsDebugger.newInstance(null, null, file, callback); + } + + @Test + public void testGetInfo() throws Exception { + DebuggerInfo info = debugger.getInfo(); + + assertTrue(info.getFile().endsWith("app.js")); + assertTrue(!isNullOrEmpty(info.getVersion())); + assertTrue(info.getName().equals("'node'") || info.getName().equals("'nodejs'")); + } + + @Test + public void testManageBreakpoints() throws Exception { + List breakpoints = debugger.getAllBreakpoints(); + assertEquals(breakpoints.size(), 1); + + debugger.addBreakpoint(new BreakpointImpl(new LocationImpl("app.js", 2))); + + ArgumentCaptor breakpointActivated = ArgumentCaptor.forClass(BreakpointActivatedEvent.class); + verify(callback).onEvent(breakpointActivated.capture()); + BreakpointActivatedEvent event = breakpointActivated.getValue(); + Breakpoint breakpoint = event.getBreakpoint(); + assertEquals(breakpoint.getLocation().getTarget(), "app.js"); + assertEquals(breakpoint.getLocation().getLineNumber(), 2); + + debugger.addBreakpoint(new BreakpointImpl(new LocationImpl("app.js", 5))); + + breakpoints = debugger.getAllBreakpoints(); + assertEquals(breakpoints.size(), 3); + + debugger.deleteBreakpoint(new LocationImpl("app.js", 2)); + breakpoints = debugger.getAllBreakpoints(); + assertEquals(breakpoints.size(), 2); + + debugger.deleteAllBreakpoints(); + breakpoints = debugger.getAllBreakpoints(); + assertEquals(breakpoints.size(), 1); + } + + @Test + public void testEvaluation() throws Exception { + String result = debugger.evaluate("2+2"); + assertEquals(result, "4"); + + result = debugger.evaluate("console.log('hello')"); + assertEquals(result, "< hello"); + + result = debugger.evaluate("var y=1"); + assertEquals(result, "undefined"); + } + + @Test + public void testSteps() throws Exception { + debugger.stepOver(new StepOverActionImpl()); + + ArgumentCaptor suspendEventCaptor = ArgumentCaptor.forClass(SuspendEvent.class); + verify(callback, atLeastOnce()).onEvent(suspendEventCaptor.capture()); + SuspendEvent suspendEvent = suspendEventCaptor.getValue(); + assertEquals(suspendEvent.getLocation().getLineNumber(), 2); + assertTrue(suspendEvent.getLocation().getTarget().endsWith("app.js")); + + debugger.stepInto(new StepIntoActionImpl()); + verify(callback, atLeastOnce()).onEvent(suspendEventCaptor.capture()); + suspendEvent = suspendEventCaptor.getValue(); + assertEquals(suspendEvent.getLocation().getLineNumber(), 5); + assertTrue(suspendEvent.getLocation().getTarget().endsWith("app.js")); + + debugger.stepOut(new StepOutActionImpl()); + verify(callback, atLeastOnce()).onEvent(suspendEventCaptor.capture()); + suspendEvent = suspendEventCaptor.getValue(); + assertEquals(suspendEvent.getLocation().getLineNumber(), 9); + assertTrue(suspendEvent.getLocation().getTarget().endsWith("app.js")); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParserTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParserTest.java new file mode 100644 index 000000000000..c60b19ee41f6 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParserTest.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsBackTraceParserTest { + + private NodeJsBackTraceParser parser; + + @BeforeMethod + public void setUp() throws Exception { + parser = NodeJsBackTraceParser.INSTANCE; + } + + @Test(dataProvider = "match") + public void testMatch(String output, Boolean result) throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of(output); + + assertTrue(parser.match(nodeJsOutput) == result); + } + + @Test(dataProvider = "parse") + public void testParse(String output, String script, int line) throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of(output); + + Location location = parser.parse(nodeJsOutput); + + assertEquals(location.getTarget(), script); + assertEquals(location.getLineNumber(), line); + } + + @DataProvider(name = "match") + public static Object[][] match() { + return new Object[][] {{"#0 app.js:1:71", true}, + {"#0 app.js:1:71\n#1 app.js:1:71", true}, + {"#0 Object.defineProperty.get bootstrap_node.js:253:9", true}, + {"#1 app.js:1:71", false}}; + } + + @DataProvider(name = "parse") + public static Object[][] parse() { + return new Object[][] {{"#0 app.js:1:71", "app.js", 1}, + {"#0 app.js:1:71\n#1 app.js:1:71", "app.js", 1}, + {"#0 Object.defineProperty.get bootstrap_node.js:253:9", "bootstrap_node.js", 253}}; + + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParserTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParserTest.java new file mode 100644 index 000000000000..55e8de8ad96d --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParserTest.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsBreakpointsParserTest { + + private NodeJsBreakpointsParser parser; + + @BeforeMethod + public void setUp() throws Exception { + parser = new NodeJsBreakpointsParser(); + } + + @Test + public void testParseBreakpoints() throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of("{ breakpoints: \n" + + " [ { number: 1,\n" + + " line: 1,\n" + + " column: null,\n" + + " groupId: null,\n" + + " active: true,\n" + + " condition: null,\n" + + " actual_locations: [Object],\n" + + " type: 'scriptId',\n" + + " script_id: '63' } ],\n" + + " breakOnExceptions: false,\n" + + " breakOnUncaughtExceptions: false }"); + + assertTrue(parser.match(nodeJsOutput)); + + List breakpoints = parser.parse(nodeJsOutput).getAll(); + assertEquals(breakpoints.size(), 1); + + Breakpoint breakpoint = breakpoints.get(0); + assertEquals(breakpoint.getLocation().getLineNumber(), 2); + assertEquals(breakpoint.getLocation().getTarget(), "scriptId:63"); + assertNull(breakpoint.getCondition()); + assertTrue(breakpoint.isEnabled()); + } + + @Test + public void testParseBreakpointsWhenScriptIsNotLoaded() throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of("{ breakpoints: \n" + + " [ { number: 1,\n" + + " line: 1,\n" + + " column: null,\n" + + " groupId: null,\n" + + " active: true,\n" + + " condition: null,\n" + + " actual_locations: [Object],\n" + + " type: 'scriptRegExp',\n" + + " script_regexp: '^(.*[\\\\/\\\\\\\\])?df3dfasdfs\\\\.js$' } ]," + + " breakOnExceptions: false,\n" + + " breakOnUncaughtExceptions: false }"); + + assertTrue(parser.match(nodeJsOutput)); + + List breakpoints = parser.parse(nodeJsOutput).getAll(); + assertEquals(breakpoints.size(), 1); + + Breakpoint breakpoint = breakpoints.get(0); + assertEquals(breakpoint.getLocation().getLineNumber(), 2); + assertEquals(breakpoint.getLocation().getTarget(), "scriptRegExp:^(.*[\\/\\\\])?df3dfasdfs\\.js$"); + assertNull(breakpoint.getCondition()); + assertTrue(breakpoint.isEnabled()); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParserTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParserTest.java new file mode 100644 index 000000000000..fd9e80a70b6f --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParserTest.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.Map; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsScriptsParserTest { + + private NodeJsScriptsParser parser; + + @BeforeMethod + public void setUp() throws Exception { + parser = new NodeJsScriptsParser(); + } + + @Test + public void testParseScriptCommand() throws Exception { + NodeJsOutput output = NodeJsOutput.of(" 35: bootstrap_node.js\n" + + "* 63: app.js\n"); + + assertTrue(parser.match(output)); + + Map scripts = parser.parse(output).getAll(); + + assertEquals(scripts.size(), 2); + assertEquals(scripts.get(35), "bootstrap_node.js"); + assertEquals(scripts.get(63), "app.js"); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParserTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParserTest.java new file mode 100644 index 000000000000..60598d4a93d1 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParserTest.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsStepParserTest { + private NodeJsStepParser parser; + + @BeforeMethod + public void setUp() throws Exception { + parser = NodeJsStepParser.INSTANCE; + } + + @Test + public void testMatch() throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of("break in module.js:559\n" + + " 557 if (depth === 0) stat.cache = null;\n" + + " 558 return result;\n" + + ">559 };\n" + + " 560 \n" + + " 561"); + + assertTrue(parser.match(nodeJsOutput)); + } + + @Test + public void testParse() throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of("break in module.js:559\n" + + " 557 if (depth === 0) stat.cache = null;\n" + + " 558 return result;\n" + + ">559 };\n" + + " 560 \n" + + " 561"); + + Location location = parser.parse(nodeJsOutput); + + assertEquals(location.getTarget(), "module.js"); + assertEquals(location.getLineNumber(), 559); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/app.js b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/app.js new file mode 100644 index 000000000000..29acbf4c50dd --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/app.js @@ -0,0 +1,7 @@ +var x = 1; +say("Hello", x); + +function say(str, num) { + console.log(str + " " + x); +} + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/logback-test.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/logback-test.xml new file mode 100644 index 000000000000..33ab360a1fef --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/logback-test.xml @@ -0,0 +1,25 @@ + + + + + + %-41(%date[%.25thread]) %-45([%-5level] [%.30logger{30} %L]) - %msg%n%nopex + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/pom.xml b/plugins/plugin-nodejs-debugger/pom.xml new file mode 100644 index 000000000000..4b10f40ce87f --- /dev/null +++ b/plugins/plugin-nodejs-debugger/pom.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + + che-plugin-parent + org.eclipse.che.plugin + 5.0.0-M5-SNAPSHOT + + che-plugin-nodejs-debugger-parent + pom + Che Plugin :: NodeJs Debugger :: Parent + + che-plugin-nodejs-debugger-server + che-plugin-nodejs-debugger-ide + + + + + windows + + + Windows + + + + true + + + + diff --git a/plugins/pom.xml b/plugins/pom.xml index 3cbf987006bb..f589b650b053 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -46,6 +46,7 @@ plugin-cpp plugin-csharp plugin-nodejs + plugin-nodejs-debugger plugin-php plugin-ssh-machine plugin-ssh-key diff --git a/pom.xml b/pom.xml index ef0e6a77ff66..892aa8bdb894 100644 --- a/pom.xml +++ b/pom.xml @@ -591,6 +591,16 @@ che-plugin-maven-shared ${che.version} + + org.eclipse.che.plugin + che-plugin-nodejs-debugger-ide + ${che.version} + + + org.eclipse.che.plugin + che-plugin-nodejs-debugger-server + ${che.version} + org.eclipse.che.plugin che-plugin-nodejs-lang-ide From bd5a9af1626e4b87780430f15447dab60b9e4b1f Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Fri, 30 Sep 2016 09:36:33 +0200 Subject: [PATCH 02/33] Fix #2649 : Allow on Mac to use alt + 5 which is for example to enter { (map to use action keybinding instead of alt) (#2656) Change-Id: I632415dfc97eaac87cdfc16649056fa198d4f033 Signed-off-by: Florent BENOIT --- .../che/plugin/debugger/ide/DebuggerExtension.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/plugin-debugger/che-plugin-debugger-ide/src/main/java/org/eclipse/che/plugin/debugger/ide/DebuggerExtension.java b/plugins/plugin-debugger/che-plugin-debugger-ide/src/main/java/org/eclipse/che/plugin/debugger/ide/DebuggerExtension.java index 33f2b0fcaa76..8d58dc035168 100644 --- a/plugins/plugin-debugger/che-plugin-debugger-ide/src/main/java/org/eclipse/che/plugin/debugger/ide/DebuggerExtension.java +++ b/plugins/plugin-debugger/che-plugin-debugger-ide/src/main/java/org/eclipse/che/plugin/debugger/ide/DebuggerExtension.java @@ -18,6 +18,7 @@ import org.eclipse.che.ide.api.extension.Extension; import org.eclipse.che.ide.api.keybinding.KeyBindingAgent; import org.eclipse.che.ide.api.keybinding.KeyBuilder; +import org.eclipse.che.ide.util.browser.UserAgent; import org.eclipse.che.plugin.debugger.ide.actions.ChangeVariableValueAction; import org.eclipse.che.plugin.debugger.ide.actions.DebugAction; import org.eclipse.che.plugin.debugger.ide.actions.DeleteAllBreakpointsAction; @@ -143,6 +144,11 @@ public DebuggerExtension(DebuggerResources debuggerResources, keyBinding.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.F9).build(), RESUME_EXECUTION_ID); keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.F8).build(), EVALUATE_EXPRESSION_ID); keyBinding.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.F2).build(), CHANGE_VARIABLE_VALUE_ID); - keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('5').build(), SHOW_HIDE_DEBUGGER_PANEL_ID); + + if (UserAgent.isMac()) { + keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('5').build(), SHOW_HIDE_DEBUGGER_PANEL_ID); + } else { + keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('5').build(), SHOW_HIDE_DEBUGGER_PANEL_ID); + } } } From 5fb212f654e0eb4577957702cfb46c0d535caa2a Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Fri, 30 Sep 2016 12:16:03 +0300 Subject: [PATCH 03/33] CHE-2214: Fix compilation error (#2665) --- .../NodeJsDebuggerConfigurationPagePresenterTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java index 7733ee642885..217af9391263 100644 --- a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java @@ -12,7 +12,6 @@ import com.google.gwt.user.client.ui.AcceptsOneWidget; -import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.debug.DebugConfiguration; import org.eclipse.che.ide.api.debug.DebugConfigurationPage; @@ -79,7 +78,6 @@ public void testResetting() throws Exception { @Test public void testGo() throws Exception { AcceptsOneWidget container = Mockito.mock(AcceptsOneWidget.class); - when(machineServiceClient.getMachines(appContext.getWorkspaceId())).thenReturn(mock(Promise.class)); pagePresenter.go(container); From 716b48caf7009b1f1a7fdb6400e147f67b84e012 Mon Sep 17 00:00:00 2001 From: Ann Shumilova Date: Mon, 3 Oct 2016 10:49:48 +0300 Subject: [PATCH 04/33] CHE-2593: disable stack deletion if current user is not creator Signed-off-by: Ann Shumilova --- .../stacks/list-stacks/list-stacks.controller.ts | 16 ++++++++++++++-- .../src/app/stacks/list-stacks/list-stacks.html | 3 ++- .../stack-item/stack-item.directive.ts | 3 ++- .../list-stacks/stack-item/stack-item.html | 10 ++++++---- .../list-stacks/stack-item/stack-item.styl | 4 ++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/dashboard/src/app/stacks/list-stacks/list-stacks.controller.ts b/dashboard/src/app/stacks/list-stacks/list-stacks.controller.ts index dbdedb2e7343..94f84a1857cf 100644 --- a/dashboard/src/app/stacks/list-stacks/list-stacks.controller.ts +++ b/dashboard/src/app/stacks/list-stacks/list-stacks.controller.ts @@ -22,7 +22,7 @@ export class ListStacksController { * Default constructor that is using resource * @ngInject for Dependency injection */ - constructor(cheStack, $log, $mdDialog, cheNotification, $rootScope, lodash, $q) { + constructor(cheStack, cheProfile, $log, $mdDialog, cheNotification, $rootScope, lodash, $q) { this.cheStack = cheStack; this.$log = $log; this.$mdDialog = $mdDialog; @@ -40,7 +40,19 @@ export class ListStacksController { this.isNoSelected = true; this.stacks = []; - this.getStacks(); + + this.profile = cheProfile.getProfile(); + if (this.profile.userId) { + this.userId = this.profile.userId; + this.getStacks(); + } else { + this.profile.$promise.then(() => { + this.userId = this.profile.userId ? this.profile.userId : undefined; + this.getStacks(); + }, () => { + this.userId = undefined; + }); + } } /** diff --git a/dashboard/src/app/stacks/list-stacks/list-stacks.html b/dashboard/src/app/stacks/list-stacks/list-stacks.html index 462bdbf2a9e4..18c9eba7d7fa 100644 --- a/dashboard/src/app/stacks/list-stacks/list-stacks.html +++ b/dashboard/src/app/stacks/list-stacks/list-stacks.html @@ -66,7 +66,8 @@ che-on-checkbox-click="listStacksController.updateSelectionState()" che-on-delete="listStacksController.deleteStack(stack)" che-on-duplicate="listStacksController.duplicateStack(stack)" - che-stack="stack"> + stack="stack" + user-id="listStacksController.userId">
diff --git a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.directive.ts b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.directive.ts index 93f7cbaba27e..6d9fc5ff30d4 100644 --- a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.directive.ts +++ b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.directive.ts @@ -28,7 +28,8 @@ export class StackItem { // scope values this.scope = { - stack: '=cheStack', + stack: '=stack', + userId: '=userId', isSelectable: '=cheSelectable', isSelect: '=?ngModel', onCheckboxClick: '&?cheOnCheckboxClick', diff --git a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.html b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.html index 673b5aabbaeb..ed2b19d1f876 100644 --- a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.html +++ b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.html @@ -19,9 +19,10 @@ layout-align="start center" class="che-checkbox-area" ng-if="stackItemController.isSelectable === true"> - +
Actions - + diff --git a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.styl b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.styl index 9032b0b0d83c..e11ebbb1a627 100644 --- a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.styl +++ b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.styl @@ -3,3 +3,7 @@ stack-item:last-child .che-list-item border-bottom none + +stack-item .che-list-actions a[disabled] + pointer-events none + opacity 0.5 From 4323f58992f8ace68b5f5289eecc4f3953627cc6 Mon Sep 17 00:00:00 2001 From: Oleksii Orel Date: Fri, 30 Sep 2016 17:26:02 +0300 Subject: [PATCH 05/33] CHE-2518: add ability to add/remove stack's tags Signed-off-by: Oleksii Orel --- .../stacks/stack-details/stack.controller.ts | 69 ++++++++++++++--- .../src/app/stacks/stack-details/stack.html | 24 ++++++ .../src/app/stacks/stack-details/stack.styl | 77 ++++++++++++++++++- 3 files changed, 157 insertions(+), 13 deletions(-) diff --git a/dashboard/src/app/stacks/stack-details/stack.controller.ts b/dashboard/src/app/stacks/stack-details/stack.controller.ts index bc3165048094..60926f4f6dab 100644 --- a/dashboard/src/app/stacks/stack-details/stack.controller.ts +++ b/dashboard/src/app/stacks/stack-details/stack.controller.ts @@ -16,6 +16,27 @@ * @author Ann Shumilova */ export class StackController { + $log: ng.ILogService; + $filter: ng.IFilterService; + $timeout: ng.ITimeoutService; + $location: ng.ILocationService; + $mdDialog: angular.material.IDialogService; + + loading: boolean; + isLoading: boolean; + isCreation: boolean; + + stackId: string; + stackName: string; + stackContent: string; + invalidStack: string; + + stack: any; + editorOptions: any; + changesPromise: any; + + cheStack; + cheNotification; /** * Default constructor that is using resource injection @@ -57,14 +78,14 @@ export class StackController { * * @returns {{stack}} new stack template */ - getNewStackTemplate() { + getNewStackTemplate(): any { this.stackName = 'New Stack'; - let stack = {}; + let stack: any = {}; stack.name = this.stackName; stack.description = ''; stack.source = {}; stack.source.origin = ''; - stack.source.type = '' + stack.source.type = ''; stack.components = []; stack.tags = []; stack.workspaceConfig = {}; @@ -75,7 +96,7 @@ export class StackController { /** * Fetch the stack details. */ - fetchStack() { + fetchStack(): void { this.loading = true; this.stack = this.cheStack.getStackById(this.stackId); @@ -102,10 +123,36 @@ export class StackController { }); } + /** + * Handle stack's tag adding. + * + * @param tag {string} stack's tag + * @returns {string} tag if it is unique one, otherwise null + */ + handleTagAdding(tag: string): string { + //Prevents mentioning same tags twice: + if (this.stack.tags.includes(tag)) { + return null; + } + + return tag; + } + + /** + * Update stack's editor content. + */ + updateEditorContent(): void { + this.stackContent = this.$filter('json')(this.stack); + } + /** * Prepare data to be displayed. */ - prepareStackData() { + prepareStackData(): void { + if (!this.stack.tags) { + this.stack.tags = []; + } + delete this.stack.links; this.stackName = angular.copy(this.stack.name); this.stackContent = this.$filter('json')(this.stack); @@ -115,14 +162,14 @@ export class StackController { * Updates stack info. * @param isFormValid {Boolean} true if form is valid */ - updateStack(isFormValid) { + updateStack(isFormValid: boolean) { if (this.isCreation) { this.stack.name = this.stackName; - this.stackContent = this.$filter('json')(this.stack); + this.updateEditorContent(); return; } - this.stackContent = this.$filter('json')(this.stack); + this.updateEditorContent(); if (this.changesPromise) { this.$timeout.cancel(this.changesPromise); @@ -154,7 +201,7 @@ export class StackController { /** * Saves stack configuration - creates new one or updates existing. */ - saveStack() { + saveStack(): void { if (this.isCreation) { this.createStack(); return; @@ -176,7 +223,7 @@ export class StackController { /** * Creates new stack. */ - createStack() { + createStack(): void { this.cheStack.createStack(this.stackContent).then((stack) => { this.cheNotification.showInfo('Stack is successfully created.'); this.stack = stack; @@ -193,7 +240,7 @@ export class StackController { /** * Deletes current stack if user confirms. */ - deleteStack() { + deleteStack(): void { let confirmTitle = 'Would you like to delete ' + this.stack.name + '?'; let confirm = this.$mdDialog.confirm() diff --git a/dashboard/src/app/stacks/stack-details/stack.html b/dashboard/src/app/stacks/stack-details/stack.html index f21a6f435091..1d8b203a885d 100644 --- a/dashboard/src/app/stacks/stack-details/stack.html +++ b/dashboard/src/app/stacks/stack-details/stack.html @@ -47,6 +47,30 @@
+ + +
+ + +
{{$chip | uppercase}}
+
+ +
+
+
+
+
Reset
+
+
+
+
doc * * @author Yevhenii Voevodin + * @author Anton Korneta */ +@Singleton public class JpaInitializer { @Inject - public JpaInitializer(PersistService persistService) { + public void init(PersistService persistService) { persistService.start(); } } From e079338a11905dbe2a73bc7b5b034d40e02b72d1 Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Tue, 4 Oct 2016 11:49:24 +0300 Subject: [PATCH 07/33] CHE-2552: Language server module refactoring (#2677) --- assembly/assembly-ide-war/pom.xml | 4 - .../resources/org/eclipse/che/ide/IDE.gwt.xml | 1 + assembly/assembly-wsagent-war/pom.xml | 14 +- .../che-plugin-csharp-lang-server/pom.xml | 16 +++ .../plugin/csharp/inject/CSharpModule.java | 4 + .../CSharpLanguageServerLauncher.java | 38 +++--- .../che-plugin-json-server/pom.xml | 52 +++++++ .../che/plugin/json/inject/JsonModule.java | 29 ++++ .../JsonLanguageServerLauncher.java | 33 +++-- plugins/plugin-json/pom.xml | 28 ++++ .../che-plugin-languageserver-ide/pom.xml | 100 +++++++++++++- .../ide/LanguageServerExtension.java | 10 +- .../ide/LanguageServerFileTypeRegister.java | 2 +- .../ide/editor/DiagnosticAnnotation.java | 2 +- .../ide/editor/DiagnosticCollector.java | 3 +- .../editor/LanguageServerAnnotationModel.java | 4 +- .../ide/editor/LanguageServerFormatter.java | 16 +-- .../editor/PublishDiagnosticsProcessor.java | 4 +- ...CompletionItemBasedCompletionProposal.java | 6 +- .../LanguageServerCodeAssistProcessor.java | 6 +- .../LanguageServerSignatureHelp.java | 4 +- .../editor/signature/ParamterInfoImpl.java | 2 +- .../editor/signature/SignatureHelpImpl.java | 4 +- .../editor/signature/SignatureInfoImpl.java | 4 +- .../sync/FullTextDocumentSynchronize.java | 6 +- .../IncrementalTextDocumentSynchronize.java | 10 +- .../ide/hover/HoverProvider.java | 8 +- .../ide/location/OpenLocationPresenter.java | 4 +- .../ide/location/OpenLocationView.java | 2 +- .../ide/location/OpenLocationViewImpl.java | 2 +- .../declaration/FindDefinitionAction.java | 4 +- .../references/FindReferencesAction.java | 10 +- .../navigation/symbol/GoToSymbolAction.java | 8 +- .../workspace/FindSymbolAction.java | 12 +- .../ide/registry/LanguageServerRegistry.java | 13 +- .../LanguageServerRegistryServiceClient.java | 4 +- .../service/TextDocumentServiceClient.java | 34 ++--- .../ide/service/WorkspaceServiceClient.java | 4 +- .../ide/util/DtoBuildHelper.java | 6 +- .../api/languageserver/LanguageServer.gwt.xml | 19 +++ .../languageserver/LanguageServer.gwt.xml | 1 - .../server/LanguageServerModule.java | 49 ------- .../FatJarBasedLanguageServerLauncher.java | 128 ------------------ plugins/plugin-languageserver/pom.xml | 2 - .../che-plugin-php-lang-server/pom.xml | 12 ++ .../che/plugin/php/inject/PhpModule.java | 4 + .../PhpLanguageServerLauncher.java | 31 +++-- plugins/pom.xml | 1 + pom.xml | 21 +-- .../pom.xml | 108 ++++++--------- .../shared/ProjectExtensionKey.java | 2 +- .../shared/ProjectExtensionKeyDto.java | 2 +- .../LanguageServerInitializeEventDto.java | 6 +- .../shared/lsapi/CancelParamsDTO.java | 2 +- .../shared/lsapi/ClientCapabilitiesDTO.java | 2 +- .../shared/lsapi/CodeActionContextDTO.java | 2 +- .../shared/lsapi/CodeActionParamsDTO.java | 2 +- .../shared/lsapi/CodeLensDTO.java | 2 +- .../shared/lsapi/CodeLensOptionsDTO.java | 2 +- .../shared/lsapi/CodeLensParamsDTO.java | 2 +- .../shared/lsapi/CommandDTO.java | 2 +- .../shared/lsapi/CompletionItemDTO.java | 2 +- .../shared/lsapi/CompletionOptionsDTO.java | 2 +- .../shared/lsapi/DiagnosticDTO.java | 2 +- .../DidChangeConfigurationParamsDTO.java | 2 +- .../lsapi/DidChangeTextDocumentParamsDTO.java | 2 +- .../lsapi/DidChangeWatchedFilesParamsDTO.java | 2 +- .../lsapi/DidCloseTextDocumentParamsDTO.java | 2 +- .../lsapi/DidOpenTextDocumentParamsDTO.java | 2 +- .../lsapi/DidSaveTextDocumentParamsDTO.java | 2 +- .../lsapi/DocumentFormattingParamsDTO.java | 2 +- .../shared/lsapi/DocumentHighlightDTO.java | 2 +- .../DocumentOnTypeFormattingOptionsDTO.java | 2 +- .../DocumentOnTypeFormattingParamsDTO.java | 2 +- .../DocumentRangeFormattingParamsDTO.java | 2 +- .../shared/lsapi/DocumentSymbolParamsDTO.java | 2 +- .../shared/lsapi/FileEventDTO.java | 2 +- .../shared/lsapi/FormattingOptionsDTO.java | 2 +- .../languageserver/shared/lsapi/HoverDTO.java | 2 +- .../shared/lsapi/InitializeErrorDTO.java | 2 +- .../shared/lsapi/InitializeResultDTO.java | 2 +- .../shared/lsapi/LanguageDescriptionDTO.java | 4 +- .../shared/lsapi/LocationDTO.java | 2 +- .../shared/lsapi/MarkedStringDTO.java | 2 +- .../shared/lsapi/MessageActionItemDTO.java | 2 +- .../shared/lsapi/MessageDTO.java | 2 +- .../shared/lsapi/MessageParamsDTO.java | 2 +- .../shared/lsapi/NotificationMessageDTO.java | 2 +- .../shared/lsapi/ParameterInformationDTO.java | 2 +- .../shared/lsapi/PositionDTO.java | 2 +- .../lsapi/PublishDiagnosticsParamsDTO.java | 2 +- .../languageserver/shared/lsapi/RangeDTO.java | 2 +- .../shared/lsapi/ReferenceContextDTO.java | 2 +- .../shared/lsapi/ReferenceParamsDTO.java | 2 +- .../shared/lsapi/RenameParamsDTO.java | 2 +- .../shared/lsapi/RequestMessageDTO.java | 2 +- .../shared/lsapi/ResponseErrorDTO.java | 2 +- .../shared/lsapi/ResponseMessageDTO.java | 2 +- .../shared/lsapi/ServerCapabilitiesDTO.java | 2 +- .../lsapi/ShowMessageRequestParamsDTO.java | 2 +- .../shared/lsapi/SignatureHelpDTO.java | 2 +- .../shared/lsapi/SignatureHelpOptionsDTO.java | 2 +- .../shared/lsapi/SignatureInformationDTO.java | 2 +- .../shared/lsapi/SymbolInformationDTO.java | 2 +- .../TextDocumentContentChangeEventDTO.java | 2 +- .../lsapi/TextDocumentIdentifierDTO.java | 2 +- .../shared/lsapi/TextDocumentItemDTO.java | 2 +- .../lsapi/TextDocumentPositionParamsDTO.java | 2 +- .../shared/lsapi/TextEditDTO.java | 2 +- .../VersionedTextDocumentIdentifierDTO.java | 2 +- .../shared/lsapi/WorkspaceEditDTO.java | 2 +- .../lsapi/WorkspaceSymbolParamsDTO.java | 2 +- .../shared/model/LanguageDescription.java | 2 +- .../model/impl/InitializeResultImpl.java | 4 +- .../model/impl/LanguageDescriptionImpl.java | 4 +- .../che-core-api-languageserver}/pom.xml | 32 ++--- .../che/api/languageserver}/DtoConverter.java | 18 +-- .../languageserver/LanguageServerModule.java | 40 ++++++ .../exception/LanguageServerException.java | 2 +- .../launcher/LanguageServerLauncher.java | 6 +- .../LanguageServerLauncherTemplate.java | 5 +- .../messager/InitializeEventMessenger.java | 18 +-- .../PublishDiagnosticsParamsMessenger.java | 2 +- .../registry/LanguageServerDescription.java | 7 +- .../registry/LanguageServerRegistry.java | 8 +- .../registry/LanguageServerRegistryImpl.java | 12 +- .../registry/ServerInitializer.java | 6 +- .../registry/ServerInitializerImpl.java | 18 +-- .../registry/ServerInitializerObservable.java | 2 +- .../registry/ServerInitializerObserver.java | 4 +- .../service/LanguageRegistryService.java | 20 +-- .../service/TextDocumentService.java | 30 ++-- .../service/WorkspaceService.java | 12 +- .../LanguageServerRegistryImplTest.java | 17 +-- .../registry/ServerInitializerImplTest.java | 8 +- .../src/test/resources/logback-test.xml | 0 wsagent/pom.xml | 2 + 137 files changed, 695 insertions(+), 603 deletions(-) rename plugins/{plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher => plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/languageserver}/CSharpLanguageServerLauncher.java (71%) create mode 100644 plugins/plugin-json/che-plugin-json-server/pom.xml create mode 100644 plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/inject/JsonModule.java rename plugins/{plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher => plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver}/JsonLanguageServerLauncher.java (69%) create mode 100644 plugins/plugin-json/pom.xml create mode 100644 plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/api/languageserver/LanguageServer.gwt.xml delete mode 100644 plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/LanguageServerModule.java delete mode 100644 plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/FatJarBasedLanguageServerLauncher.java rename plugins/{plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher => plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver}/PhpLanguageServerLauncher.java (71%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared => wsagent/che-core-api-languageserver-shared}/pom.xml (69%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/ProjectExtensionKey.java (97%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/ProjectExtensionKeyDto.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/event/LanguageServerInitializeEventDto.java (81%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/CancelParamsDTO.java (90%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/ClientCapabilitiesDTO.java (89%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/CodeActionContextDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/CodeActionParamsDTO.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/CodeLensDTO.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/CodeLensOptionsDTO.java (91%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/CodeLensParamsDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/CommandDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/CompletionItemDTO.java (97%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/CompletionOptionsDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DiagnosticDTO.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java (90%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java (96%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DocumentHighlightDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/FileEventDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/FormattingOptionsDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/HoverDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/InitializeErrorDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/InitializeResultDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/LanguageDescriptionDTO.java (88%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/LocationDTO.java (91%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/MarkedStringDTO.java (90%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/MessageActionItemDTO.java (91%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/MessageDTO.java (89%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/MessageParamsDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/NotificationMessageDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/ParameterInformationDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/PositionDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/RangeDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/ReferenceContextDTO.java (91%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/ReferenceParamsDTO.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/RenameParamsDTO.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/RequestMessageDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/ResponseErrorDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/ResponseMessageDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/ServerCapabilitiesDTO.java (98%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/SignatureHelpDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/SignatureInformationDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/SymbolInformationDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java (91%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/TextDocumentItemDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/TextEditDTO.java (94%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/WorkspaceEditDTO.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java (91%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/model/LanguageDescription.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/model/impl/InitializeResultImpl.java (90%) rename {plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin => wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api}/languageserver/shared/model/impl/LanguageDescriptionImpl.java (95%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server => wsagent/che-core-api-languageserver}/pom.xml (81%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/DtoConverter.java (89%) create mode 100644 wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/LanguageServerModule.java rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/exception/LanguageServerException.java (93%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/launcher/LanguageServerLauncher.java (80%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/launcher/LanguageServerLauncherTemplate.java (88%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/messager/InitializeEventMessenger.java (78%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/messager/PublishDiagnosticsParamsMessenger.java (97%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/registry/LanguageServerDescription.java (86%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/registry/LanguageServerRegistry.java (78%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/registry/LanguageServerRegistryImpl.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/registry/ServerInitializer.java (82%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/registry/ServerInitializerImpl.java (87%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/registry/ServerInitializerObservable.java (92%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/registry/ServerInitializerObserver.java (89%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/service/LanguageRegistryService.java (76%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/service/TextDocumentService.java (90%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver}/service/WorkspaceService.java (87%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver}/registry/LanguageServerRegistryImplTest.java (85%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server => wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver}/registry/ServerInitializerImplTest.java (90%) rename {plugins/plugin-languageserver/che-plugin-languageserver-server => wsagent/che-core-api-languageserver}/src/test/resources/logback-test.xml (100%) diff --git a/assembly/assembly-ide-war/pom.xml b/assembly/assembly-ide-war/pom.xml index aa03387bb7a5..46ac9856da8e 100644 --- a/assembly/assembly-ide-war/pom.xml +++ b/assembly/assembly-ide-war/pom.xml @@ -160,10 +160,6 @@ org.eclipse.che.plugin che-plugin-languageserver-ide
- - org.eclipse.che.plugin - che-plugin-languageserver-shared - org.eclipse.che.plugin che-plugin-machine-ext-client diff --git a/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml b/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml index e951b39f2a04..b2421f5206d7 100644 --- a/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml +++ b/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml @@ -81,6 +81,7 @@ + diff --git a/assembly/assembly-wsagent-war/pom.xml b/assembly/assembly-wsagent-war/pom.xml index b03d28444605..6443e43bee16 100644 --- a/assembly/assembly-wsagent-war/pom.xml +++ b/assembly/assembly-wsagent-war/pom.xml @@ -70,6 +70,14 @@ org.eclipse.che.core che-core-api-git + + org.eclipse.che.core + che-core-api-languageserver + + + org.eclipse.che.core + che-core-api-languageserver-shared + org.eclipse.che.core che-core-api-project @@ -146,11 +154,7 @@ org.eclipse.che.plugin - che-plugin-languageserver-server - - - org.eclipse.che.plugin - che-plugin-languageserver-shared + che-plugin-json-server org.eclipse.che.plugin diff --git a/plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml b/plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml index b430de5fffd8..76048a34568f 100644 --- a/plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml +++ b/plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml @@ -36,10 +36,22 @@ com.google.inject.extensions guice-multibindings + + io.typefox.lsapi + io.typefox.lsapi.services + org.eclipse.che.core che-core-api-core + + org.eclipse.che.core + che-core-api-languageserver + + + org.eclipse.che.core + che-core-api-languageserver-shared + org.eclipse.che.core che-core-api-project @@ -48,6 +60,10 @@ org.eclipse.che.core che-core-commons-inject + + org.eclipse.che.core + che-core-commons-lang + org.eclipse.che.plugin che-plugin-csharp-lang-shared diff --git a/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/inject/CSharpModule.java b/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/inject/CSharpModule.java index ca859731029f..50c8e9eff430 100644 --- a/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/inject/CSharpModule.java +++ b/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/inject/CSharpModule.java @@ -13,9 +13,11 @@ import com.google.inject.AbstractModule; import com.google.inject.multibindings.Multibinder; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; import org.eclipse.che.api.project.server.handlers.ProjectHandler; import org.eclipse.che.api.project.server.type.ProjectTypeDef; import org.eclipse.che.inject.DynaModule; +import org.eclipse.che.plugin.csharp.languageserver.CSharpLanguageServerLauncher; import org.eclipse.che.plugin.csharp.projecttype.CSharpProjectType; import org.eclipse.che.plugin.csharp.projecttype.CreateNetCoreProjectHandler; @@ -31,5 +33,7 @@ protected void configure() { Multibinder projectHandlersMultibinder = Multibinder.newSetBinder(binder(), ProjectHandler.class); projectHandlersMultibinder.addBinding().to(CreateNetCoreProjectHandler.class); + + Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(CSharpLanguageServerLauncher.class); } } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/CSharpLanguageServerLauncher.java b/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/languageserver/CSharpLanguageServerLauncher.java similarity index 71% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/CSharpLanguageServerLauncher.java rename to plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/languageserver/CSharpLanguageServerLauncher.java index 486d9562d3be..9c2477ef355e 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/CSharpLanguageServerLauncher.java +++ b/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/languageserver/CSharpLanguageServerLauncher.java @@ -8,19 +8,22 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.launcher; +package org.eclipse.che.plugin.csharp.languageserver; import io.typefox.lsapi.services.json.JsonBasedLanguageServer; +import com.google.inject.Inject; import com.google.inject.Singleton; -import org.apache.commons.io.IOUtils; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; -import org.eclipse.che.plugin.languageserver.shared.model.impl.LanguageDescriptionImpl; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncherTemplate; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.impl.LanguageDescriptionImpl; +import org.eclipse.che.commons.lang.IoUtil; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; @@ -33,12 +36,12 @@ @Singleton public class CSharpLanguageServerLauncher extends LanguageServerLauncherTemplate { - public static final String LANGUAGE_ID = "csharp"; - public static final String[] EXTENSIONS = new String[] {"cs", "csx"}; - public static final String[] MIME_TYPES = new String[] {"text/x-csharp"}; + private static final String LANGUAGE_ID = "csharp"; + private static final String[] EXTENSIONS = new String[] {"cs", "csx"}; + private static final String[] MIME_TYPES = new String[] {"text/x-csharp"}; + private static final LanguageDescriptionImpl description; - public static final LanguageDescriptionImpl description; - private static final String SCRIPT_PATH = "che/ls-csharp/launch.sh"; + private final Path launchScript; static { description = new LanguageDescriptionImpl(); @@ -47,12 +50,16 @@ public class CSharpLanguageServerLauncher extends LanguageServerLauncherTemplate description.setMimeTypes(Arrays.asList(MIME_TYPES)); } + @Inject + public CSharpLanguageServerLauncher() { + launchScript = Paths.get(System.getenv("HOME"), "che/ls-csharp/launch.sh"); + } + @Override protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException { restoreDependencies(projectPath); - Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH); - ProcessBuilder processBuilder = new ProcessBuilder(launchFile.toString()); + ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString()); processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE); processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); @@ -70,8 +77,8 @@ private void restoreDependencies(String projectPath) throws LanguageServerExcept Process process = processBuilder.start(); int resultCode = process.waitFor(); if (resultCode != 0) { - String err = IOUtils.toString(process.getErrorStream()); - String in = IOUtils.toString(process.getInputStream()); + String err = IoUtil.readStream(process.getErrorStream()); + String in = IoUtil.readStream(process.getInputStream()); throw new LanguageServerException("Can't restore dependencies. Error: " + err + ". Output: " + in); } } catch (IOException | InterruptedException e) { @@ -93,7 +100,6 @@ public LanguageDescription getLanguageDescription() { @Override public boolean isAbleToLaunch() { - Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH); - return launchFile.toFile().exists(); + return Files.exists(launchScript); } } diff --git a/plugins/plugin-json/che-plugin-json-server/pom.xml b/plugins/plugin-json/che-plugin-json-server/pom.xml new file mode 100644 index 000000000000..da55f21e6ccc --- /dev/null +++ b/plugins/plugin-json/che-plugin-json-server/pom.xml @@ -0,0 +1,52 @@ + + + + 4.0.0 + + che-plugin-json-parent + org.eclipse.che.plugin + 5.0.0-M5-SNAPSHOT + + che-plugin-json-server + Che Plugin :: JSON :: Extension Server + + false + + + + com.google.inject + guice + + + com.google.inject.extensions + guice-multibindings + + + io.typefox.lsapi + io.typefox.lsapi.services + + + org.eclipse.che.core + che-core-api-languageserver + + + org.eclipse.che.core + che-core-api-languageserver-shared + + + org.eclipse.che.core + che-core-commons-inject + + + diff --git a/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/inject/JsonModule.java b/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/inject/JsonModule.java new file mode 100644 index 000000000000..1b055aad4020 --- /dev/null +++ b/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/inject/JsonModule.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.json.inject; + +import com.google.inject.AbstractModule; +import com.google.inject.multibindings.Multibinder; + +import org.eclipse.che.inject.DynaModule; +import org.eclipse.che.plugin.json.languageserver.JsonLanguageServerLauncher; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; + +/** + * @author Anatolii Bazko + */ +@DynaModule +public class JsonModule extends AbstractModule { + @Override + protected void configure() { + Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(JsonLanguageServerLauncher.class); + } +} diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/JsonLanguageServerLauncher.java b/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServerLauncher.java similarity index 69% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/JsonLanguageServerLauncher.java rename to plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServerLauncher.java index 0b7d78e01759..24948ecbd52c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/JsonLanguageServerLauncher.java +++ b/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServerLauncher.java @@ -8,17 +8,20 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.launcher; +package org.eclipse.che.plugin.json.languageserver; import io.typefox.lsapi.services.json.JsonBasedLanguageServer; +import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; -import org.eclipse.che.plugin.languageserver.shared.model.impl.LanguageDescriptionImpl; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncherTemplate; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.impl.LanguageDescriptionImpl; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -31,12 +34,12 @@ @Singleton public class JsonLanguageServerLauncher extends LanguageServerLauncherTemplate { - public static final String LANGUAGE_ID = "json"; - public static final String[] EXTENSIONS = new String[] {"json", "bowerrc", "jshintrc", "jscsrc", "eslintrc", "babelrc"}; - public static final String[] MIME_TYPES = new String[] {"application/json"}; - + private static final String LANGUAGE_ID = "json"; + private static final String[] EXTENSIONS = new String[] {"json", "bowerrc", "jshintrc", "jscsrc", "eslintrc", "babelrc"}; + private static final String[] MIME_TYPES = new String[] {"application/json"}; private static final LanguageDescriptionImpl description; - private static final String SCRIPT_PATH = "che/ls-json/launch.sh"; + + private final Path launchScript; static { description = new LanguageDescriptionImpl(); @@ -45,6 +48,11 @@ public class JsonLanguageServerLauncher extends LanguageServerLauncherTemplate { description.setMimeTypes(asList(MIME_TYPES)); } + @Inject + public JsonLanguageServerLauncher() { + launchScript = Paths.get(System.getenv("HOME"), "che/ls-json/launch.sh"); + } + @Override public LanguageDescription getLanguageDescription() { return description; @@ -52,8 +60,7 @@ public LanguageDescription getLanguageDescription() { @Override public boolean isAbleToLaunch() { - Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH); - return launchFile.toFile().exists(); + return Files.exists(launchScript); } protected JsonBasedLanguageServer connectToLanguageServer(Process languageServerProcess) { @@ -63,9 +70,7 @@ protected JsonBasedLanguageServer connectToLanguageServer(Process languageServer } protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException { - Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH); - - ProcessBuilder processBuilder = new ProcessBuilder(launchFile.toString()); + ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString()); processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE); processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); try { diff --git a/plugins/plugin-json/pom.xml b/plugins/plugin-json/pom.xml new file mode 100644 index 000000000000..8294c99db06e --- /dev/null +++ b/plugins/plugin-json/pom.xml @@ -0,0 +1,28 @@ + + + + 4.0.0 + + che-plugin-parent + org.eclipse.che.plugin + 5.0.0-M5-SNAPSHOT + ../pom.xml + + che-plugin-json-parent + pom + Che Plugin :: JSON :: Parent + + che-plugin-json-server + + diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml b/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml index 7872b40101b3..f26da4505ac2 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml @@ -22,6 +22,9 @@ che-plugin-languageserver-ide jar Che Plugin :: Language Server :: IDE + + ${project.build.directory}/generated-sources/dto/ + com.google.guava @@ -51,6 +54,14 @@ javax.validation validation-api + + org.eclipse.che.core + che-core-api-dto + + + org.eclipse.che.core + che-core-api-languageserver-shared + org.eclipse.che.core che-core-commons-annotations @@ -71,10 +82,6 @@ org.eclipse.che.core che-core-ide-ui - - org.eclipse.che.plugin - che-plugin-languageserver-shared - org.eclipse.che.plugin che-plugin-orion-editor @@ -95,6 +102,7 @@ + target/classes src/main/java @@ -102,6 +110,90 @@ src/main/resources + + ${dto-generator-out-directory} + + + + src/test/resources + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-resource + process-sources + + add-resource + + + + + ${dto-generator-out-directory}/META-INF + META-INF + + + + + + add-source + process-sources + + add-source + + + + ${dto-generator-out-directory} + + + + + + + maven-compiler-plugin + + + pre-compile + generate-sources + + compile + + + + + + org.eclipse.che.core + che-core-api-dto-maven-plugin + ${project.version} + + + generate-client-dto + process-sources + + generate + + + + org.eclipse.che.api.languageserver.shared + + ${dto-generator-out-directory} + org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls + client + + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + + diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerExtension.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerExtension.java index e21b162fb11e..0994da899fc7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerExtension.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerExtension.java @@ -14,6 +14,11 @@ import com.google.inject.Singleton; import com.google.web.bindery.event.shared.EventBus; +import org.eclipse.che.api.languageserver.shared.lsapi.DidCloseTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidOpenTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidSaveTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentItemDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.ide.api.action.ActionManager; @@ -33,11 +38,6 @@ import org.eclipse.che.plugin.languageserver.ide.navigation.symbol.GoToSymbolAction; import org.eclipse.che.plugin.languageserver.ide.navigation.workspace.FindSymbolAction; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidCloseTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidOpenTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidSaveTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentIdentifierDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentItemDTO; import static org.eclipse.che.ide.api.action.IdeActions.GROUP_ASSISTANT; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerFileTypeRegister.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerFileTypeRegister.java index d7f3429cc616..2ae697a18031 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerFileTypeRegister.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerFileTypeRegister.java @@ -15,6 +15,7 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -30,7 +31,6 @@ import org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorProvider; import org.eclipse.che.plugin.languageserver.ide.hover.HoverProvider; import org.eclipse.che.plugin.languageserver.ide.service.LanguageServerRegistryServiceClient; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LanguageDescriptionDTO; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticAnnotation.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticAnnotation.java index 7c6910ee1e3f..60ddfff77b50 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticAnnotation.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticAnnotation.java @@ -14,10 +14,10 @@ import elemental.js.dom.JsElement; import io.typefox.lsapi.DiagnosticSeverity; +import org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO; import org.eclipse.che.ide.api.editor.text.annotation.Annotation; import org.eclipse.che.ide.util.dom.Elements; import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DiagnosticDTO; import org.vectomatic.dom.svg.ui.SVGImage; /** diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticCollector.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticCollector.java index 803a3aaeb8ac..9220a940f8a7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticCollector.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticCollector.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.editor; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DiagnosticDTO; + +import org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO; /** * @author Evgen Vidolob diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerAnnotationModel.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerAnnotationModel.java index aa995bf04b8a..30664a0debb6 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerAnnotationModel.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerAnnotationModel.java @@ -13,6 +13,8 @@ import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; +import org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; import org.eclipse.che.ide.api.editor.annotation.AnnotationModelImpl; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.document.DocumentHandle; @@ -22,8 +24,6 @@ import org.eclipse.che.ide.api.editor.texteditor.EditorResources; import org.eclipse.che.ide.editor.orion.client.OrionAnnotationSeverityProvider; import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DiagnosticDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.RangeDTO; import java.util.ArrayList; import java.util.HashMap; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java index e23e1f3abe86..e0edbe92d6fa 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java @@ -15,6 +15,14 @@ import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentOnTypeFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.FormattingOptionsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextEditDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -32,14 +40,6 @@ import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.ide.util.loging.Log; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentOnTypeFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.FormattingOptionsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.PositionDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.RangeDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentIdentifierDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextEditDTO; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/PublishDiagnosticsProcessor.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/PublishDiagnosticsProcessor.java index 5627b1533d94..3829ac0520fc 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/PublishDiagnosticsProcessor.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/PublishDiagnosticsProcessor.java @@ -13,14 +13,14 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.PublishDiagnosticsParamsDTO; import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; import org.eclipse.che.ide.api.editor.annotation.AnnotationModel; import org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.resource.Path; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DiagnosticDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.PublishDiagnosticsParamsDTO; /** * @author Anatolii Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java index 31e6570ad90f..030182e67ec2 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java @@ -17,6 +17,9 @@ import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; +import org.eclipse.che.api.languageserver.shared.lsapi.CompletionItemDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.PromiseError; @@ -29,9 +32,6 @@ import org.eclipse.che.ide.util.loging.Log; import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; -import org.eclipse.che.plugin.languageserver.shared.lsapi.CompletionItemDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.RangeDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentIdentifierDTO; /** * @author Anatolii Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java index 82dea9b9fe9a..ff3396f12f58 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java @@ -15,6 +15,9 @@ import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; +import org.eclipse.che.api.languageserver.shared.lsapi.CompletionItemDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.PromiseError; @@ -25,9 +28,6 @@ import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper; -import org.eclipse.che.plugin.languageserver.shared.lsapi.CompletionItemDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentIdentifierDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java index fc1a34ecc0d8..92d535efb2cc 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java @@ -17,6 +17,8 @@ import com.google.inject.assistedinject.Assisted; import com.google.web.bindery.event.shared.HandlerRegistration; +import org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.api.promises.client.Function; import org.eclipse.che.api.promises.client.FunctionException; import org.eclipse.che.api.promises.client.Promise; @@ -33,8 +35,6 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SignatureHelpDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/ParamterInfoImpl.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/ParamterInfoImpl.java index fae7787101ef..86c6d8fd001b 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/ParamterInfoImpl.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/ParamterInfoImpl.java @@ -12,8 +12,8 @@ import com.google.common.base.Optional; +import org.eclipse.che.api.languageserver.shared.lsapi.ParameterInformationDTO; import org.eclipse.che.ide.api.editor.signature.ParameterInfo; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ParameterInformationDTO; /** * @author Evgen Vidolob diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureHelpImpl.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureHelpImpl.java index 3bc501d9ffde..bee769dde669 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureHelpImpl.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureHelpImpl.java @@ -12,10 +12,10 @@ import com.google.common.base.Optional; +import org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.SignatureInformationDTO; import org.eclipse.che.ide.api.editor.signature.SignatureHelp; import org.eclipse.che.ide.api.editor.signature.SignatureInfo; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SignatureHelpDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SignatureInformationDTO; import java.util.ArrayList; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureInfoImpl.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureInfoImpl.java index 4667da4bdcea..ea6927892de0 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureInfoImpl.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureInfoImpl.java @@ -12,10 +12,10 @@ import com.google.common.base.Optional; +import org.eclipse.che.api.languageserver.shared.lsapi.ParameterInformationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.SignatureInformationDTO; import org.eclipse.che.ide.api.editor.signature.ParameterInfo; import org.eclipse.che.ide.api.editor.signature.SignatureInfo; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ParameterInformationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SignatureInformationDTO; import java.util.ArrayList; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java index c5c02a95caed..a198c268f219 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java @@ -13,13 +13,13 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentContentChangeEventDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.VersionedTextDocumentIdentifierDTO; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentContentChangeEventDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.VersionedTextDocumentIdentifierDTO; import java.util.Collections; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java index 98e75629ddf0..154d23441187 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java @@ -13,16 +13,16 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentContentChangeEventDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.VersionedTextDocumentIdentifierDTO; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.PositionDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.RangeDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentContentChangeEventDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.VersionedTextDocumentIdentifierDTO; import java.util.Collections; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/hover/HoverProvider.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/hover/HoverProvider.java index 35e88f77c822..8373be874327 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/hover/HoverProvider.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/hover/HoverProvider.java @@ -13,6 +13,11 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.HoverDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.MarkedStringDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.api.promises.client.Function; import org.eclipse.che.api.promises.client.FunctionException; import org.eclipse.che.api.promises.client.Promise; @@ -28,9 +33,6 @@ import org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper; -import org.eclipse.che.plugin.languageserver.shared.lsapi.HoverDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.MarkedStringDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; /** * Provides hover LS functionality for Orion editor. diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationPresenter.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationPresenter.java index f2fa80b67c3c..deb967a7dcb1 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationPresenter.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationPresenter.java @@ -15,6 +15,8 @@ import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; +import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -28,8 +30,6 @@ import org.eclipse.che.ide.api.parts.base.BasePresenter; import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources; import org.eclipse.che.plugin.languageserver.ide.util.OpenFileInEditorHelper; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.RangeDTO; import org.vectomatic.dom.svg.ui.SVGResource; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationView.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationView.java index fdce0d577e5a..dbcb7659fc12 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationView.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationView.java @@ -12,9 +12,9 @@ import com.google.inject.ImplementedBy; +import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; import org.eclipse.che.ide.api.mvp.View; import org.eclipse.che.ide.api.parts.base.BaseActionDelegate; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LocationDTO; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationViewImpl.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationViewImpl.java index d8d4a9576f02..265363b6be58 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationViewImpl.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationViewImpl.java @@ -14,6 +14,7 @@ import com.google.gwt.user.client.ui.DockLayoutPanel; import com.google.inject.Inject; +import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.data.tree.AbstractTreeNode; import org.eclipse.che.ide.api.data.tree.HasAction; @@ -27,7 +28,6 @@ import org.eclipse.che.ide.ui.smartTree.Tree; import org.eclipse.che.ide.ui.smartTree.presentation.HasPresentation; import org.eclipse.che.ide.ui.smartTree.presentation.NodePresentation; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LocationDTO; import javax.validation.constraints.NotNull; import java.util.Collections; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/declaration/FindDefinitionAction.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/declaration/FindDefinitionAction.java index a7683d3d211b..2838f4c39eb3 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/declaration/FindDefinitionAction.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/declaration/FindDefinitionAction.java @@ -15,6 +15,8 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -30,8 +32,6 @@ import org.eclipse.che.plugin.languageserver.ide.location.OpenLocationPresenterFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import javax.validation.constraints.NotNull; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/references/FindReferencesAction.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/references/FindReferencesAction.java index 8c6cca3b3013..b053ecabcb2e 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/references/FindReferencesAction.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/references/FindReferencesAction.java @@ -14,6 +14,11 @@ import com.google.inject.Inject; +import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.ReferenceContextDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; import org.eclipse.che.ide.api.action.ActionEvent; @@ -26,11 +31,6 @@ import org.eclipse.che.plugin.languageserver.ide.location.OpenLocationPresenter; import org.eclipse.che.plugin.languageserver.ide.location.OpenLocationPresenterFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.PositionDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ReferenceContextDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ReferenceParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentIdentifierDTO; import javax.validation.constraints.NotNull; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/GoToSymbolAction.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/GoToSymbolAction.java index 41baa795590a..53f4b8abd402 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/GoToSymbolAction.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/GoToSymbolAction.java @@ -15,6 +15,10 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentSymbolParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -39,10 +43,6 @@ import org.eclipse.che.plugin.languageserver.ide.quickopen.QuickOpenModel; import org.eclipse.che.plugin.languageserver.ide.quickopen.QuickOpenPresenter; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentSymbolParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.RangeDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SymbolInformationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentIdentifierDTO; import javax.validation.constraints.NotNull; import java.util.ArrayList; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/FindSymbolAction.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/FindSymbolAction.java index 16f09e7204ef..a64df32ac266 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/FindSymbolAction.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/FindSymbolAction.java @@ -15,12 +15,16 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; +import org.eclipse.che.api.promises.async.Task; +import org.eclipse.che.api.promises.async.ThrottledDelayer; import org.eclipse.che.api.promises.client.Function; import org.eclipse.che.api.promises.client.FunctionException; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.js.Promises; -import org.eclipse.che.api.promises.async.Task; -import org.eclipse.che.api.promises.async.ThrottledDelayer; import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; import org.eclipse.che.ide.api.action.ActionEvent; import org.eclipse.che.ide.api.editor.EditorAgent; @@ -35,10 +39,6 @@ import org.eclipse.che.plugin.languageserver.ide.quickopen.QuickOpenPresenter; import org.eclipse.che.plugin.languageserver.ide.service.WorkspaceServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.OpenFileInEditorHelper; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.RangeDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SymbolInformationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; import javax.validation.constraints.NotNull; import java.util.ArrayList; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/registry/LanguageServerRegistry.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/registry/LanguageServerRegistry.java index 235304a5a84b..5a6be4bbe66a 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/registry/LanguageServerRegistry.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/registry/LanguageServerRegistry.java @@ -18,6 +18,11 @@ import com.google.inject.Singleton; import com.google.web.bindery.event.shared.EventBus; +import org.eclipse.che.api.languageserver.shared.ProjectExtensionKey; +import org.eclipse.che.api.languageserver.shared.event.LanguageServerInitializeEventDto; +import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.impl.InitializeResultImpl; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -35,17 +40,13 @@ import org.eclipse.che.ide.websocket.rest.SubscriptionHandler; import org.eclipse.che.ide.websocket.rest.Unmarshallable; import org.eclipse.che.plugin.languageserver.ide.service.LanguageServerRegistryServiceClient; -import org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey; -import org.eclipse.che.plugin.languageserver.shared.event.LanguageServerInitializeEventDto; -import org.eclipse.che.plugin.languageserver.shared.lsapi.InitializeResultDTO; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; -import org.eclipse.che.plugin.languageserver.shared.model.impl.InitializeResultImpl; import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey.createProjectKey; +import static org.eclipse.che.api.languageserver.shared.ProjectExtensionKey.createProjectKey; + /** * @author Anatoliy Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/LanguageServerRegistryServiceClient.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/LanguageServerRegistryServiceClient.java index 72009b05a739..fdf02799c7b7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/LanguageServerRegistryServiceClient.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/LanguageServerRegistryServiceClient.java @@ -12,12 +12,12 @@ import com.google.inject.Inject; +import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.rest.AsyncRequestFactory; import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; -import org.eclipse.che.plugin.languageserver.shared.lsapi.InitializeResultDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LanguageDescriptionDTO; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/TextDocumentServiceClient.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/TextDocumentServiceClient.java index 825cfb335170..53dde2597aaf 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/TextDocumentServiceClient.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/TextDocumentServiceClient.java @@ -15,6 +15,23 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.CompletionItemDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidCloseTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidOpenTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidSaveTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentOnTypeFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentSymbolParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.HoverDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.PublishDiagnosticsParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextEditDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -31,23 +48,6 @@ import org.eclipse.che.ide.websocket.WebSocketException; import org.eclipse.che.ide.websocket.rest.SubscriptionHandler; import org.eclipse.che.plugin.languageserver.ide.editor.PublishDiagnosticsProcessor; -import org.eclipse.che.plugin.languageserver.shared.lsapi.CompletionItemDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidCloseTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidOpenTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidSaveTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentOnTypeFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentSymbolParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.HoverDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.PublishDiagnosticsParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ReferenceParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SignatureHelpDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SymbolInformationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextEditDTO; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/WorkspaceServiceClient.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/WorkspaceServiceClient.java index 909123c982c5..b3c7acafbca5 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/WorkspaceServiceClient.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/WorkspaceServiceClient.java @@ -13,13 +13,13 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.rest.AsyncRequestFactory; import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; import org.eclipse.che.ide.rest.Unmarshallable; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SymbolInformationDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/DtoBuildHelper.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/DtoBuildHelper.java index eac6cc49d83f..830ab22ce319 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/DtoBuildHelper.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/DtoBuildHelper.java @@ -13,12 +13,12 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.ide.dto.DtoFactory; -import org.eclipse.che.plugin.languageserver.shared.lsapi.PositionDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentIdentifierDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; /** * Helps to create LS DTO objects diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/api/languageserver/LanguageServer.gwt.xml b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/api/languageserver/LanguageServer.gwt.xml new file mode 100644 index 000000000000..3d98f2401f7a --- /dev/null +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/api/languageserver/LanguageServer.gwt.xml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/LanguageServer.gwt.xml b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/LanguageServer.gwt.xml index 2e816929159a..06e2e9c0a5bc 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/LanguageServer.gwt.xml +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/LanguageServer.gwt.xml @@ -27,5 +27,4 @@ - diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/LanguageServerModule.java b/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/LanguageServerModule.java deleted file mode 100644 index 6897f33e0302..000000000000 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/LanguageServerModule.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server; - -import com.google.inject.AbstractModule; -import com.google.inject.multibindings.Multibinder; - -import org.eclipse.che.inject.DynaModule; -import org.eclipse.che.plugin.languageserver.server.launcher.CSharpLanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.launcher.JsonLanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.launcher.PhpLanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.messager.InitializeEventMessenger; -import org.eclipse.che.plugin.languageserver.server.messager.PublishDiagnosticsParamsMessenger; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistry; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistryImpl; -import org.eclipse.che.plugin.languageserver.server.registry.ServerInitializer; -import org.eclipse.che.plugin.languageserver.server.registry.ServerInitializerImpl; -import org.eclipse.che.plugin.languageserver.server.service.LanguageRegistryService; -import org.eclipse.che.plugin.languageserver.server.service.TextDocumentService; -import org.eclipse.che.plugin.languageserver.server.service.WorkspaceService; - -@DynaModule -public class LanguageServerModule extends AbstractModule { - - @Override - protected void configure() { - Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(JsonLanguageServerLauncher.class); - Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(PhpLanguageServerLauncher.class); - Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(CSharpLanguageServerLauncher.class); - - bind(LanguageServerRegistry.class).to(LanguageServerRegistryImpl.class); - bind(ServerInitializer.class).to(ServerInitializerImpl.class); - - bind(LanguageRegistryService.class); - bind(TextDocumentService.class); - bind(WorkspaceService.class); - bind(PublishDiagnosticsParamsMessenger.class); - bind(InitializeEventMessenger.class); - } -} diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/FatJarBasedLanguageServerLauncher.java b/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/FatJarBasedLanguageServerLauncher.java deleted file mode 100644 index 422176fad019..000000000000 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/FatJarBasedLanguageServerLauncher.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.launcher; - -import io.typefox.lsapi.services.LanguageServer; -import io.typefox.lsapi.services.json.JsonBasedLanguageServer; - -import com.google.inject.Singleton; - -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.file.FileVisitOption; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Iterator; -import java.util.stream.Stream; - -@Singleton -public class FatJarBasedLanguageServerLauncher extends LanguageServerLauncherTemplate { - - private final static Logger LOG = LoggerFactory.getLogger(FatJarBasedLanguageServerLauncher.class); - private final static String JAVA_EXEC = System.getProperty("java.home") + "/bin/java"; - - @Override - protected LanguageServer connectToLanguageServer(Process languageServerProcess) { - JsonBasedLanguageServer languageServer = new JsonBasedLanguageServer(); - languageServer.connect(languageServerProcess.getInputStream(), languageServerProcess.getOutputStream()); - return languageServer; - } - - @Override - protected Process startLanguageServerProcess(String projectPath) { - Stream paths; - try { - paths = Files.find(Paths.get("/projects"), - 0, - (path, basicFileAttributes) -> path.endsWith("-languageserver.jar"), - FileVisitOption.FOLLOW_LINKS); - } catch (IOException e) { - String errMsg = "Can't find jar"; - LOG.error(errMsg); - - throw new IllegalStateException(e); - } - - Path filePath; - Iterator iterator = paths.iterator(); - if (!iterator.hasNext()) { - filePath = iterator.next(); - } else { - String errMsg = "Can't find jar"; - LOG.error(errMsg); - - throw new IllegalStateException(errMsg); - } - - ProcessBuilder processBuilder = new ProcessBuilder(JAVA_EXEC, "-jar", filePath.toString(), - "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044", - "debug"); - processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE); - processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); - - Process process; - try { - process = processBuilder.start(); - } catch (IOException e) { - String errMsg = "Can't start JSON language server"; - LOG.error(errMsg, e); - - throw new IllegalStateException(errMsg, e); - } - - Thread thread = new Thread(new StreamReader(process)); - thread.setDaemon(true); - thread.start(); - - if (!process.isAlive()) { - LOG.error("Couldn't start process : " + processBuilder.command()); - } - - return process; - } - - @Override - public LanguageDescription getLanguageDescription() { - return null; - } - - @Override - public boolean isAbleToLaunch() { - return true; - } - - private static class StreamReader implements Runnable { - public Process process; - - public StreamReader(Process process) { - this.process = process; - } - - @Override - public void run() { - BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream())); - while (process.isAlive()) { - try { - String errorLine = reader.readLine(); - LOG.error("languageserver ["+process+"] : " +errorLine); - } catch (IOException e) { - LOG.error(e.getMessage(), e); - } - } - } - } -} diff --git a/plugins/plugin-languageserver/pom.xml b/plugins/plugin-languageserver/pom.xml index 0841a18fd8b6..3d33f61f4c36 100644 --- a/plugins/plugin-languageserver/pom.xml +++ b/plugins/plugin-languageserver/pom.xml @@ -23,8 +23,6 @@ pom Che Plugin :: Language Server :: Parent - che-plugin-languageserver-shared - che-plugin-languageserver-server che-plugin-languageserver-ide diff --git a/plugins/plugin-php/che-plugin-php-lang-server/pom.xml b/plugins/plugin-php/che-plugin-php-lang-server/pom.xml index 64a31a7c04c0..9b14b175c4a1 100644 --- a/plugins/plugin-php/che-plugin-php-lang-server/pom.xml +++ b/plugins/plugin-php/che-plugin-php-lang-server/pom.xml @@ -32,6 +32,18 @@ com.google.inject.extensions guice-multibindings + + io.typefox.lsapi + io.typefox.lsapi.services + + + org.eclipse.che.core + che-core-api-languageserver + + + org.eclipse.che.core + che-core-api-languageserver-shared + org.eclipse.che.core che-core-api-project diff --git a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java index 985f80d3d681..85dda46ba784 100644 --- a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java @@ -13,8 +13,10 @@ import com.google.inject.AbstractModule; import com.google.inject.multibindings.Multibinder; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; import org.eclipse.che.api.project.server.type.ProjectTypeDef; import org.eclipse.che.inject.DynaModule; +import org.eclipse.che.plugin.php.languageserver.PhpLanguageServerLauncher; import org.eclipse.che.plugin.php.projecttype.PhpProjectType; /** @@ -26,5 +28,7 @@ public class PhpModule extends AbstractModule { protected void configure() { Multibinder projectTypeMultibinder = Multibinder.newSetBinder(binder(), ProjectTypeDef.class); projectTypeMultibinder.addBinding().to(PhpProjectType.class); + + Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(PhpLanguageServerLauncher.class); } } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/PhpLanguageServerLauncher.java b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java similarity index 71% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/PhpLanguageServerLauncher.java rename to plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java index 9dda3b2a27d0..4c581f3adc27 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/PhpLanguageServerLauncher.java +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java @@ -8,17 +8,20 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.launcher; +package org.eclipse.che.plugin.php.languageserver; import io.typefox.lsapi.services.json.JsonBasedLanguageServer; +import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; -import org.eclipse.che.plugin.languageserver.shared.model.impl.LanguageDescriptionImpl; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncherTemplate; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.impl.LanguageDescriptionImpl; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -31,13 +34,13 @@ */ @Singleton public class PhpLanguageServerLauncher extends LanguageServerLauncherTemplate { + private static final String LANGUAGE_ID = "php"; + private static final String[] EXTENSIONS = new String[] {"php"}; + private static final String[] MIME_TYPES = new String[] {"text/x-php"}; - public static final String LANGUAGE_ID = "php"; - public static final String[] EXTENSIONS = new String[] {"php"}; - public static final String[] MIME_TYPES = new String[] {"text/x-php"}; + private final Path launchScript; private static final LanguageDescriptionImpl description; - private static final String SCRIPT_PATH = "che/ls-php/launch.sh"; static { description = new LanguageDescriptionImpl(); @@ -46,6 +49,11 @@ public class PhpLanguageServerLauncher extends LanguageServerLauncherTemplate { description.setMimeTypes(asList(MIME_TYPES)); } + @Inject + public PhpLanguageServerLauncher() { + this.launchScript = Paths.get(System.getenv("HOME"), "che/ls-php/launch.sh"); + } + @Override public LanguageDescription getLanguageDescription() { return description; @@ -53,8 +61,7 @@ public LanguageDescription getLanguageDescription() { @Override public boolean isAbleToLaunch() { - Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH); - return launchFile.toFile().exists(); + return Files.exists(launchScript); } protected JsonBasedLanguageServer connectToLanguageServer(Process languageServerProcess) { @@ -64,9 +71,7 @@ protected JsonBasedLanguageServer connectToLanguageServer(Process languageServer } protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException { - Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH); - - ProcessBuilder processBuilder = new ProcessBuilder(launchFile.toString()); + ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString()); processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE); processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); try { diff --git a/plugins/pom.xml b/plugins/pom.xml index f589b650b053..d190c8402beb 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -51,5 +51,6 @@ plugin-ssh-machine plugin-ssh-key plugin-languageserver + plugin-json diff --git a/pom.xml b/pom.xml index 892aa8bdb894..5de426d13d64 100644 --- a/pom.xml +++ b/pom.xml @@ -178,6 +178,16 @@ che-core-api-jdbc-vendor-h2 ${project.version} + + org.eclipse.che.core + che-core-api-languageserver + ${che.version} + + + org.eclipse.che.core + che-core-api-languageserver-shared + ${che.version} + org.eclipse.che.core che-core-api-machine @@ -543,17 +553,12 @@ org.eclipse.che.plugin - che-plugin-languageserver-ide - ${project.version} - - - org.eclipse.che.plugin - che-plugin-languageserver-server - ${project.version} + che-plugin-json-server + ${che.version} org.eclipse.che.plugin - che-plugin-languageserver-shared + che-plugin-languageserver-ide ${project.version} diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/pom.xml b/wsagent/che-core-api-languageserver-shared/pom.xml similarity index 69% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/pom.xml rename to wsagent/che-core-api-languageserver-shared/pom.xml index e4de24f31574..8ef463a013e3 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/pom.xml +++ b/wsagent/che-core-api-languageserver-shared/pom.xml @@ -14,12 +14,13 @@ 4.0.0 - che-plugin-languageserver-parent - org.eclipse.che.plugin + che-agent-parent + org.eclipse.che.core 5.0.0-M5-SNAPSHOT - che-plugin-languageserver-shared - Che Plugin :: Language Server :: Shared + che-core-api-languageserver-shared + jar + Che Core :: API :: Language Server Shared ${project.build.directory}/generated-sources/dto/ false @@ -29,10 +30,6 @@ com.google.code.gson gson - - com.google.inject - guice - io.typefox.lsapi io.typefox.lsapi @@ -41,15 +38,6 @@ org.eclipse.che.core che-core-api-dto - - org.eclipse.che.core - che-core-commons-gwt - - - com.google.gwt - gwt-user - provided - @@ -60,7 +48,7 @@ src/main/resources - ${dto-generator-out-directory} + ${generated.sources.directory} @@ -74,37 +62,32 @@ - org.codehaus.mojo - build-helper-maven-plugin + org.eclipse.che.core + che-core-api-dto-maven-plugin + ${project.version} - add-resource - process-sources - - add-resource - - - - - ${dto-generator-out-directory}/META-INF - META-INF - - - - - - add-source process-sources - add-source + generate - - - ${dto-generator-out-directory} - - + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + + + org.eclipse.che.api.languageserver.shared + + ${dto-generator-out-directory} + org.eclipse.che.api.languageserver.server.dto.DtoServerImpls + server + maven-compiler-plugin @@ -119,48 +102,37 @@ - org.eclipse.che.core - che-core-api-dto-maven-plugin - ${project.version} + org.codehaus.mojo + build-helper-maven-plugin - generate-client-dto + add-resource process-sources - generate + add-resource - - org.eclipse.che.plugin.languageserver.shared - - ${dto-generator-out-directory} - org.eclipse.che.plugin.languageserver.shared.dto.DtoClientImpls - client + + + ${dto-generator-out-directory}/META-INF + META-INF + + - generate-server-dto + add-source process-sources - generate + add-source - - org.eclipse.che.plugin.languageserver.shared - - ${dto-generator-out-directory} - org.eclipse.che.plugin.languageserver.shared.dto.DtoServerImpls - server + + ${dto-generator-out-directory} + - - - ${project.groupId} - ${project.artifactId} - ${project.version} - - diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKey.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java similarity index 97% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKey.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java index 52e329a443e5..ef55e856d90c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKey.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared; +package org.eclipse.che.api.languageserver.shared; import java.util.Objects; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKeyDto.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKeyDto.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java index 57efb7f9b57d..45cd703522d7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKeyDto.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared; +package org.eclipse.che.api.languageserver.shared; import org.eclipse.che.dto.shared.DTO; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/event/LanguageServerInitializeEventDto.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java similarity index 81% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/event/LanguageServerInitializeEventDto.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java index c56c4b5a226a..ccb89979d5f2 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/event/LanguageServerInitializeEventDto.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java @@ -8,11 +8,11 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared.event; +package org.eclipse.che.api.languageserver.shared.event; +import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.ServerCapabilitiesDTO; import org.eclipse.che.dto.shared.DTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LanguageDescriptionDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ServerCapabilitiesDTO; /** * @author Anatoliy Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CancelParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CancelParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java index 391e1cda7f18..b2c3db04f110 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CancelParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CancelParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ClientCapabilitiesDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java similarity index 89% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ClientCapabilitiesDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java index 94dad845dbed..572afeb4827a 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ClientCapabilitiesDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ClientCapabilities; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionContextDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionContextDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java index 6173030ca0cd..10a44b3b4bc7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionContextDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeActionContext; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java index 5a504e84c562..0e9fce86c064 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeActionParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java index 879e353be1fe..116b847fbb0d 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeLens; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java index eddb70a45974..0342246676b1 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeLensOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java index c6f2b85da12f..8ab8c939b7b3 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeLensParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CommandDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CommandDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java index c892ba42253e..8917ee3cc377 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CommandDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Command; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionItemDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java similarity index 97% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionItemDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java index 54a7435eb488..710b7e838a15 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionItemDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CompletionItem; import io.typefox.lsapi.CompletionItemKind; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java index be47d7b6ab00..af7cdbb64add 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CompletionOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DiagnosticDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DiagnosticDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java index e4a19e2239c8..d6d4f97ce80a 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DiagnosticDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Diagnostic; import io.typefox.lsapi.DiagnosticSeverity; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java index 4d5bc3c99692..673638c97da0 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidChangeConfigurationParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java similarity index 96% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java index bbf1effe8bf2..57c5c3c20989 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidChangeTextDocumentParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java index fd800cef85d9..5b630d802fc7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidChangeWatchedFilesParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java index 044504f3f065..2370d6124f9f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidCloseTextDocumentParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java index f23dd90f8277..b4456ed95908 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidOpenTextDocumentParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java index c0a6c502aa35..70f56310f1e0 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidSaveTextDocumentParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java index 7f1c97c9a25a..d66e91930135 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentFormattingParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentHighlightDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentHighlightDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java index deec360f0dbd..74bfc9043957 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentHighlightDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentHighlight; import io.typefox.lsapi.DocumentHighlightKind; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java index 3ad0ed074e43..a11fe493dcde 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentOnTypeFormattingOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java index 17724d697f1f..f3a17ffbd721 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentOnTypeFormattingParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java index 2c45fd0858ab..90e729550204 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentRangeFormattingParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java index f5113e4dd47e..575edae84517 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentSymbolParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FileEventDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FileEventDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java index 742b2163c96e..d35cf6062fd7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FileEventDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.FileChangeType; import io.typefox.lsapi.FileEvent; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FormattingOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FormattingOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java index d6a754a4b387..2979ac008a52 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FormattingOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.FormattingOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/HoverDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/HoverDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java index 821b5be58de1..8d5a7974caca 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/HoverDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Hover; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeErrorDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeErrorDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java index 30c208d2bf7c..397641db2f09 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeErrorDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.InitializeError; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeResultDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeResultDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java index 0869e5ffaa02..9dd579ee3794 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeResultDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java @@ -10,7 +10,7 @@ * Codenvy, S.A. - initial API and implementation * ***************************************************************************** */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.InitializeResult; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LanguageDescriptionDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java similarity index 88% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LanguageDescriptionDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java index 0795a3b3e502..7ec434c7862c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LanguageDescriptionDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java @@ -5,10 +5,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.eclipse.che.dto.shared.DTO; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LocationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LocationDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java index 1909aadecc2e..5e17997a95f6 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LocationDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Location; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MarkedStringDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MarkedStringDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java index d915662eabbf..47300dfc0ca7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MarkedStringDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.MarkedString; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageActionItemDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageActionItemDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java index 315362d33f16..38ea8ee1505f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageActionItemDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.MessageActionItem; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java similarity index 89% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java index 6e6086e4c46b..b63f1fc854e7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Message; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java index 40766e263533..7436cb14a3cf 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.MessageParams; import io.typefox.lsapi.MessageType; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/NotificationMessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/NotificationMessageDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java index 0a10897cf920..18ea6c57705c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/NotificationMessageDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.NotificationMessage; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ParameterInformationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ParameterInformationDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java index dc9b877387ff..7d4ce9d0ed33 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ParameterInformationDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ParameterInformation; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PositionDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PositionDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java index 74be92c16f51..f147a092d2dd 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PositionDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Position; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java index df78ab499ed6..3b5fd84d9170 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.PublishDiagnosticsParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RangeDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RangeDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java index 9aa74651b734..08513dc468f5 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RangeDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Range; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceContextDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceContextDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java index c7b202062a06..2e2b0204f31e 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceContextDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ReferenceContext; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java index d6177851a988..4e99522a6eaa 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ReferenceParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RenameParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RenameParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java index 2c4b83234c10..6dd241663ea1 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RenameParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.RenameParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RequestMessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RequestMessageDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java index 4430c7c363a1..ef978eeca9ab 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RequestMessageDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.RequestMessage; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseErrorDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseErrorDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java index 2899fa61a1ca..20d58f38cbec 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseErrorDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ResponseError; import io.typefox.lsapi.ResponseErrorCode; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseMessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseMessageDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java index 915aa287411d..75f4a295330e 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseMessageDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ResponseMessage; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ServerCapabilitiesDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java similarity index 98% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ServerCapabilitiesDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java index 0a172143aa7c..80a95e3fbd6c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ServerCapabilitiesDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.TextDocumentSyncKind; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java index 1bf42759084a..d658bc7934b0 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.MessageType; import io.typefox.lsapi.ShowMessageRequestParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java index 9d4073a8bbcc..9b230cc40ce4 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.SignatureHelp; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java index 94ef506cfc1c..28889cb0458c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.SignatureHelpOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureInformationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureInformationDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java index 8e4bc44a11b3..374f8716a088 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureInformationDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.SignatureInformation; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SymbolInformationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SymbolInformationDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java index 659e0217a3e8..ce89a16da49f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SymbolInformationDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.SymbolInformation; import io.typefox.lsapi.SymbolKind; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java index 75181829b05a..371a9c3279cb 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextDocumentContentChangeEvent; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java index 6fffcac153e1..656363271228 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextDocumentIdentifier; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentItemDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentItemDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java index 6ee2dd9b974f..c83000898980 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentItemDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextDocumentItem; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java index 704335c803c9..bb36ff1a4aed 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextDocumentPositionParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextEditDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextEditDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java index a96baf31fa86..6cfe35a24cf4 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextEditDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextEdit; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java index c7261ee4aa61..b22a2517eeb4 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.VersionedTextDocumentIdentifier; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceEditDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceEditDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java index e9f7058b51ed..e614749a48fc 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceEditDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.WorkspaceEdit; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java index bff46e3c68ba..68c89c2f2c1b 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.WorkspaceSymbolParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/LanguageDescription.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/LanguageDescription.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java index 6373d5f7f602..460dc40b3cc9 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/LanguageDescription.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared.model; +package org.eclipse.che.api.languageserver.shared.model; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/InitializeResultImpl.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/InitializeResultImpl.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java index cee03b0629df..648e23606118 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/InitializeResultImpl.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java @@ -8,12 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared.model.impl; +package org.eclipse.che.api.languageserver.shared.model.impl; import io.typefox.lsapi.InitializeResult; import io.typefox.lsapi.ServerCapabilities; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/LanguageDescriptionImpl.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/LanguageDescriptionImpl.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java index d15e0fd633d1..2c6cf767f233 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/LanguageDescriptionImpl.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java @@ -8,10 +8,10 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared.model.impl; +package org.eclipse.che.api.languageserver.shared.model.impl; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import java.util.List; import java.util.Objects; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/pom.xml b/wsagent/che-core-api-languageserver/pom.xml similarity index 81% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/pom.xml rename to wsagent/che-core-api-languageserver/pom.xml index 7d1a3944115e..56e9752c4e10 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/pom.xml +++ b/wsagent/che-core-api-languageserver/pom.xml @@ -14,16 +14,13 @@ 4.0.0 - che-plugin-languageserver-parent - org.eclipse.che.plugin + che-agent-parent + org.eclipse.che.core 5.0.0-M5-SNAPSHOT - che-plugin-languageserver-server - Che Plugin :: Language Server :: Server - - false - 2.10.0 - + che-core-api-languageserver + jar + Che Core :: API :: Language Server com.google.code.gson @@ -37,14 +34,6 @@ com.google.inject guice - - com.google.inject.extensions - guice-multibindings - - - commons-io - commons-io - io.typefox.lsapi io.typefox.lsapi @@ -77,6 +66,10 @@ org.eclipse.che.core che-core-api-dto + + org.eclipse.che.core + che-core-api-languageserver-shared + org.eclipse.che.core che-core-api-project @@ -89,10 +82,6 @@ org.eclipse.che.core che-core-commons-inject - - org.eclipse.che.plugin - che-plugin-languageserver-shared - org.everrest everrest-websockets @@ -123,9 +112,6 @@ - src/main/java - src/test/java - target/classes src/main/java diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/DtoConverter.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java similarity index 89% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/DtoConverter.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java index a4cc06d15270..4212ca9cd5ab 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/DtoConverter.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server; +package org.eclipse.che.api.languageserver; import io.typefox.lsapi.CodeLensOptions; import io.typefox.lsapi.CompletionOptions; @@ -17,14 +17,14 @@ import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.SignatureHelpOptions; -import org.eclipse.che.plugin.languageserver.shared.lsapi.CodeLensOptionsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.CompletionOptionsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentOnTypeFormattingOptionsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.InitializeResultDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LanguageDescriptionDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ServerCapabilitiesDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SignatureHelpOptionsDTO; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.lsapi.CodeLensOptionsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.CompletionOptionsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentOnTypeFormattingOptionsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.ServerCapabilitiesDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpOptionsDTO; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import static org.eclipse.che.dto.server.DtoFactory.newDto; diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/LanguageServerModule.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/LanguageServerModule.java new file mode 100644 index 000000000000..2fd68b280d8d --- /dev/null +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/LanguageServerModule.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.api.languageserver; + +import com.google.inject.AbstractModule; + +import org.eclipse.che.api.languageserver.messager.PublishDiagnosticsParamsMessenger; +import org.eclipse.che.api.languageserver.registry.ServerInitializer; +import org.eclipse.che.api.languageserver.service.LanguageRegistryService; +import org.eclipse.che.api.languageserver.service.TextDocumentService; +import org.eclipse.che.inject.DynaModule; +import org.eclipse.che.api.languageserver.messager.InitializeEventMessenger; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.registry.ServerInitializerImpl; +import org.eclipse.che.api.languageserver.service.WorkspaceService; + +@DynaModule +public class LanguageServerModule extends AbstractModule { + + @Override + protected void configure() { + bind(LanguageServerRegistry.class).to(LanguageServerRegistryImpl.class); + bind(ServerInitializer.class).to(ServerInitializerImpl.class); + + bind(LanguageRegistryService.class); + bind(TextDocumentService.class); + bind(WorkspaceService.class); + bind(PublishDiagnosticsParamsMessenger.class); + bind(InitializeEventMessenger.class); + } +} diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/exception/LanguageServerException.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/exception/LanguageServerException.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java index 0b498d14d3c9..4499b57f2c89 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/exception/LanguageServerException.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.exception; +package org.eclipse.che.api.languageserver.exception; import org.eclipse.che.api.core.ServerException; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncher.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java similarity index 80% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncher.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java index 1a65f27b961b..5638be959e79 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncher.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java @@ -8,12 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.launcher; +package org.eclipse.che.api.languageserver.launcher; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; /** * @author Anatoliy Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncherTemplate.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java similarity index 88% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncherTemplate.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java index e3d2b6effba0..26bebfdb6758 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncherTemplate.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java @@ -8,11 +8,11 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.launcher; +package org.eclipse.che.api.languageserver.launcher; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; /** * @author Anatolii Bazko @@ -25,7 +25,6 @@ public final LanguageServer launch(String projectPath) throws LanguageServerExce return connectToLanguageServer(languageServerProcess); } - abstract protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException; abstract protected LanguageServer connectToLanguageServer(Process languageServerProcess) throws LanguageServerException; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/InitializeEventMessenger.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java similarity index 78% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/InitializeEventMessenger.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java index 0f74cc7db5ba..855548e9c98f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/InitializeEventMessenger.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java @@ -8,18 +8,19 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.messager; +package org.eclipse.che.api.languageserver.messager; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.services.LanguageServer; import com.google.gson.Gson; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistryImpl; -import org.eclipse.che.plugin.languageserver.server.registry.ServerInitializer; -import org.eclipse.che.plugin.languageserver.server.registry.ServerInitializerObserver; -import org.eclipse.che.plugin.languageserver.shared.event.LanguageServerInitializeEventDto; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.DtoConverter; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.registry.ServerInitializer; +import org.eclipse.che.api.languageserver.registry.ServerInitializerObserver; +import org.eclipse.che.api.languageserver.shared.event.LanguageServerInitializeEventDto; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.everrest.websockets.WSConnectionContext; import org.everrest.websockets.message.ChannelBroadcastMessage; import org.slf4j.Logger; @@ -33,7 +34,6 @@ import java.io.IOException; import static org.eclipse.che.dto.server.DtoFactory.newDto; -import static org.eclipse.che.plugin.languageserver.server.DtoConverter.asDto; /** * @author Anatolii Bazko @@ -56,8 +56,8 @@ public void onServerInitialized(LanguageServer server, String projectPath) { LanguageServerInitializeEventDto initializeEventDto = newDto(LanguageServerInitializeEventDto.class); - initializeEventDto.setSupportedLanguages(asDto(languageDescription)); - initializeEventDto.setServerCapabilities(asDto(serverCapabilities)); + initializeEventDto.setSupportedLanguages(DtoConverter.asDto(languageDescription)); + initializeEventDto.setServerCapabilities(DtoConverter.asDto(serverCapabilities)); initializeEventDto.setProjectPath(projectPath.substring(LanguageServerRegistryImpl.PROJECT_FOLDER_PATH.length())); send(initializeEventDto); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/PublishDiagnosticsParamsMessenger.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java similarity index 97% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/PublishDiagnosticsParamsMessenger.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java index 68a7f556d6e5..416491a69e67 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/PublishDiagnosticsParamsMessenger.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.messager; +package org.eclipse.che.api.languageserver.messager; import io.typefox.lsapi.PublishDiagnosticsParams; import io.typefox.lsapi.impl.PublishDiagnosticsParamsImpl; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerDescription.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java similarity index 86% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerDescription.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java index 3f73b80a2c99..a5d0fdd40263 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerDescription.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java @@ -8,11 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.InitializeResult; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; + /** * Simple container for {@link InitializeResult} and {@link LanguageDescription} @@ -20,7 +21,7 @@ * @author Evgen Vidolob */ public class LanguageServerDescription { - private final InitializeResult initializeResult; + private final InitializeResult initializeResult; private final LanguageDescription languageDescription; public LanguageServerDescription(InitializeResult initializeResult, diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistry.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java similarity index 78% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistry.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java index 64aeba1d43af..183b99c05144 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistry.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java @@ -8,14 +8,14 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.services.LanguageServer; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.shared.ProjectExtensionKey; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.eclipse.che.commons.annotation.Nullable; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; import java.util.List; import java.util.Map; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImpl.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImpl.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java index d6b63df73b11..6753de38f423 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImpl.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.services.LanguageServer; @@ -18,14 +18,14 @@ import com.google.inject.Singleton; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.shared.ProjectExtensionKey; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.eclipse.che.api.project.server.FolderEntry; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.VirtualFileEntry; import org.eclipse.che.commons.annotation.Nullable; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; import java.net.URI; import java.util.ArrayList; @@ -37,7 +37,7 @@ import java.util.stream.Collectors; import static com.google.common.io.Files.getFileExtension; -import static org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey.createProjectKey; +import static org.eclipse.che.api.languageserver.shared.ProjectExtensionKey.createProjectKey; @Singleton public class LanguageServerRegistryImpl implements LanguageServerRegistry, ServerInitializerObserver { diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializer.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java similarity index 82% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializer.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java index c02e96f9f3c2..d959a28f58a4 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializer.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java @@ -8,12 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; import java.util.Map; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImpl.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java similarity index 87% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImpl.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java index d44ff80d66de..16c6db44f9fb 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImpl.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.InitializeResult; import io.typefox.lsapi.ServerCapabilities; @@ -19,10 +19,10 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.messager.PublishDiagnosticsParamsMessenger; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.messager.PublishDiagnosticsParamsMessenger; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,19 +92,11 @@ public LanguageServer initialize(LanguageServerLauncher launcher, String project synchronized (launcher) { LanguageServer server = languageIdToServers.get(languageId); if (server != null) { -// LanguageServerDescription initializeResult = serversToInitResult.get(server); -// if (!initializeResult.getCapabilities().isMultiplyProjectsProvider()) { server = doInitialize(launcher, projectPath); -// } } else { server = doInitialize(launcher, projectPath); languageIdToServers.put(languageId, server); } -// InitializeResult initializeResult = serversToInitResult.get(server); -// if (initializeResult instanceof InitializeResultImpl) { -// ((InitializeResultImpl)initializeResult) -// .setSupportedLanguages(Collections.singletonList((LanguageDescriptionImpl)launcher.getLanguageDescription())); -// } onServerInitialized(server, serversToInitResult.get(server).getInitializeResult().getCapabilities(), launcher.getLanguageDescription(), projectPath); return server; } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObservable.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObservable.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObservable.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObservable.java index 28ea78d7eac4..448c3848e928 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObservable.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObservable.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; /** * @author Anatoliy Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObserver.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java similarity index 89% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObserver.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java index 5e610c37e0a1..728e05e4921d 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObserver.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java @@ -8,12 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; /** * @author Anatoliy Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/LanguageRegistryService.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java similarity index 76% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/LanguageRegistryService.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java index bf0d44cba030..8e462436f1fe 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/LanguageRegistryService.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java @@ -8,19 +8,19 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.service; +package org.eclipse.che.api.languageserver.service; import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.DtoConverter; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerDescription; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistry; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistryImpl; -import org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey; -import org.eclipse.che.plugin.languageserver.shared.lsapi.InitializeResultDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LanguageDescriptionDTO; +import org.eclipse.che.api.languageserver.DtoConverter; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.registry.LanguageServerDescription; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.shared.ProjectExtensionKey; +import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -32,8 +32,8 @@ import java.util.List; import static java.util.stream.Collectors.toList; +import static org.eclipse.che.api.languageserver.DtoConverter.asDto; import static org.eclipse.che.dto.server.DtoFactory.newDto; -import static org.eclipse.che.plugin.languageserver.server.DtoConverter.asDto; @Singleton @Path("languageserver") diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/TextDocumentService.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/TextDocumentService.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java index 3b4993c904b5..0e514259369b 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/TextDocumentService.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.service; +package org.eclipse.che.api.languageserver.service; import io.typefox.lsapi.CompletionItem; import io.typefox.lsapi.Hover; @@ -22,20 +22,20 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistry; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistryImpl; -import org.eclipse.che.plugin.languageserver.shared.lsapi.CompletionItemDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidCloseTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidOpenTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidSaveTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentOnTypeFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentSymbolParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ReferenceParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.shared.lsapi.CompletionItemDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidCloseTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidOpenTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidSaveTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentOnTypeFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentSymbolParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/WorkspaceService.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java similarity index 87% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/WorkspaceService.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java index 66ccdfc5e9b4..b77e33c90a20 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/WorkspaceService.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java @@ -8,20 +8,20 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.service; +package org.eclipse.che.api.languageserver.service; import io.typefox.lsapi.Location; -import io.typefox.lsapi.impl.LocationImpl; import io.typefox.lsapi.SymbolInformation; +import io.typefox.lsapi.impl.LocationImpl; import io.typefox.lsapi.services.LanguageServer; import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistry; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistryImpl; -import org.eclipse.che.plugin.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImplTest.java b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java similarity index 85% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImplTest.java rename to wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java index 4bc5036522d2..6a9db491ded3 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImplTest.java +++ b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.InitializeParams; import io.typefox.lsapi.InitializeResult; @@ -17,9 +17,8 @@ import io.typefox.lsapi.services.TextDocumentService; import io.typefox.lsapi.services.WindowService; -import org.eclipse.che.plugin.languageserver.server.launcher.JsonLanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; @@ -29,7 +28,6 @@ import java.util.Collections; import java.util.concurrent.CompletableFuture; -import static java.util.Arrays.asList; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; @@ -48,7 +46,7 @@ public class LanguageServerRegistryImplTest { private static final String PREFIX = "file://"; - private static final String FILE_PATH = "/projects/1/test.json"; + private static final String FILE_PATH = "/projects/1/test.txt"; private static final String PROJECT_PATH = "/1"; @Mock @@ -72,13 +70,12 @@ public class LanguageServerRegistryImplTest { public void setUp() throws Exception { when(completableFuture.get()).thenReturn(initializeResult); when(initializeResult.getCapabilities()).thenReturn(serverCapabilities); -// when(serverCapabilities.isMultiplyProjectsProvider()).thenReturn(true); when(languageServerLauncher.getLanguageDescription()).thenReturn(languageDescription); when(languageServerLauncher.isAbleToLaunch()).thenReturn(true); - when(languageDescription.getLanguageId()).thenReturn(JsonLanguageServerLauncher.LANGUAGE_ID); - when(languageDescription.getFileExtensions()).thenReturn(asList(JsonLanguageServerLauncher.EXTENSIONS)); - when(languageDescription.getMimeTypes()).thenReturn(asList(JsonLanguageServerLauncher.MIME_TYPES)); + when(languageDescription.getLanguageId()).thenReturn("id"); + when(languageDescription.getFileExtensions()).thenReturn(Collections.singletonList("txt")); + when(languageDescription.getMimeTypes()).thenReturn(Collections.singletonList("plain/text")); when(languageServer.getTextDocumentService()).thenReturn(mock(TextDocumentService.class)); when(languageServer.getWindowService()).thenReturn(mock(WindowService.class)); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImplTest.java b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImplTest.java rename to wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java index 4e354c1d06fc..17791051cd28 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImplTest.java +++ b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java @@ -8,16 +8,16 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.InitializeParams; import io.typefox.lsapi.InitializeResult; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.messager.PublishDiagnosticsParamsMessenger; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.messager.PublishDiagnosticsParamsMessenger; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/resources/logback-test.xml b/wsagent/che-core-api-languageserver/src/test/resources/logback-test.xml similarity index 100% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/resources/logback-test.xml rename to wsagent/che-core-api-languageserver/src/test/resources/logback-test.xml diff --git a/wsagent/pom.xml b/wsagent/pom.xml index 96e200d64239..0d984ea45db3 100644 --- a/wsagent/pom.xml +++ b/wsagent/pom.xml @@ -32,6 +32,8 @@ che-core-git-impl-jgit che-core-api-debug che-core-api-debug-shared + che-core-api-languageserver + che-core-api-languageserver-shared wsagent-local From f6d5bf6ae8f828bcc1007684a94f2ee303e9cc29 Mon Sep 17 00:00:00 2001 From: Oleksii Orel Date: Tue, 4 Oct 2016 15:07:11 +0300 Subject: [PATCH 08/33] change deprecated package manager to a new one Signed-off-by: Oleksii Orel --- dashboard/.gitignore | 1 + dashboard/package.json | 1 + dashboard/tsd.json | 48 ------------------------------------------ dashboard/typings.json | 18 ++++++++++++++++ 4 files changed, 20 insertions(+), 48 deletions(-) delete mode 100644 dashboard/tsd.json create mode 100644 dashboard/typings.json diff --git a/dashboard/.gitignore b/dashboard/.gitignore index 55ff2df0b810..1c93788306f8 100644 --- a/dashboard/.gitignore +++ b/dashboard/.gitignore @@ -23,3 +23,4 @@ docs target/ uE001-README.MD +typings/ diff --git a/dashboard/package.json b/dashboard/package.json index 3002f789da04..abf5a4730eb2 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -58,6 +58,7 @@ "tsd": "~0.6.4", "tslint-loader": "~1.0.1", "typescript": "^1.8.10", + "typings": "^1.4.0", "uglify-save-license": "~0.4.1", "webpack": "^1.12.11", "webpack-stream": "~2.1.0", diff --git a/dashboard/tsd.json b/dashboard/tsd.json deleted file mode 100644 index 0e5db4575951..000000000000 --- a/dashboard/tsd.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "version": "v4", - "repo": "DefinitelyTyped/DefinitelyTyped", - "ref": "master", - "path": ".tmp/typings", - "bundle": ".tmp/typings/tsd.d.ts", - "installed": { - "angularjs/angular-animate.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "angularjs/angular-cookies.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "angularjs/angular-sanitize.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "jquery/jquery.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "angularjs/angular-resource.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "angularjs/angular-route.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "angular-material/angular-material.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "angularjs/angular.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "angularjs/angular-mocks.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "jasmine/jasmine.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "karma-jasmine/karma-jasmine.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "moment/moment.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - }, - "moment/moment-node.d.ts": { - "commit": "bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" - } - } -} diff --git a/dashboard/typings.json b/dashboard/typings.json new file mode 100644 index 000000000000..e87b33189028 --- /dev/null +++ b/dashboard/typings.json @@ -0,0 +1,18 @@ +{ + "name": "che-dashboard", + "globalDependencies": { + "angular-animate": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-animate.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "angular-cookies": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-cookies.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "angular-sanitize": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-sanitize.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "angular-resource": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-resource.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "angular-route": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-route.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "angular-material": "github:DefinitelyTyped/DefinitelyTyped/angular-material/angular-material.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "angular": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "angular-mocks": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-mocks.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "karma-jasmine": "github:DefinitelyTyped/DefinitelyTyped/karma-jasmine/karma-jasmine.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "moment": "github:DefinitelyTyped/DefinitelyTyped/moment/moment.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2", + "moment-node": "github:DefinitelyTyped/DefinitelyTyped/moment/moment-node.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2" + } +} From f036887eb5a6721d53722fa537d13930866fdde3 Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Tue, 4 Oct 2016 16:14:50 +0200 Subject: [PATCH 09/33] Adds Chefile mapping so we can have syntax highlighting (#2657) Linked to 2266 Change-Id: Id812a92bf51d58cabda4a9840acbb3e7f6cbafe2 Signed-off-by: Florent BENOIT --- .../ide/api/editor/filetype/FileNameFileTypeIdentifier.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/filetype/FileNameFileTypeIdentifier.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/filetype/FileNameFileTypeIdentifier.java index e718eda605a6..ca094ae583e5 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/filetype/FileNameFileTypeIdentifier.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/filetype/FileNameFileTypeIdentifier.java @@ -12,6 +12,7 @@ import org.eclipse.che.ide.api.resources.VirtualFile; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -41,6 +42,9 @@ public List identifyType(final VirtualFile file) { if ("Dockerfile".equals(filename)) { return Collections.singletonList("text/x-dockerfile"); } + if ("Chefile".equals(filename)) { + return Arrays.asList("application/javascript", "text/javascript"); + } // not a known file name return null; From 8b0de5e07216f27a0e429abec5aed4fe0fb9f10f Mon Sep 17 00:00:00 2001 From: Vitaliy Guliy Date: Tue, 4 Oct 2016 17:15:08 +0300 Subject: [PATCH 10/33] CHE-1756 Add ability to download workspace starting outputs from IDE loader (#2686) Signed-off-by: Vitaliy Guliy --- .../che/ide/api/dialogs/DialogFactory.java | 34 ++++++ .../ide/api/outputconsole/OutputConsole.java | 12 ++- .../org/eclipse/che/ide/theme/DarkTheme.java | 2 +- .../start/StartWorkspaceNotification.java | 3 +- .../org/eclipse/che/ide/ui/FontAwesome.java | 5 + .../dialogs/input/InputDialogPresenter.java | 24 +++++ .../ide/ui/dialogs/input/InputDialogView.java | 6 +- .../ui/dialogs/input/InputDialogViewImpl.java | 5 + .../loaders/DownloadWorkspaceOutputEvent.java | 41 +++++++ .../che/ide/ui/loaders/LoaderPresenter.java | 15 ++- .../che/ide/ui/loaders/PopupLoader.java | 19 ++++ .../che/ide/ui/loaders/PopupLoaderImpl.java | 27 +++++ .../che/ide/ui/loaders/PopupLoaderImpl.ui.xml | 17 ++- .../ide/ui/loaders/PopupLoaderMessages.java | 3 + .../ui/loaders/PopupLoaderMessages.properties | 1 + .../GitOutputConsolePresenter.java | 23 ++-- .../client/MachineLocalizationConstant.java | 6 ++ .../CommandOutputConsolePresenter.java | 29 +++-- .../console/DefaultOutputConsole.java | 34 ++++-- .../console/OutputConsoleView.java | 11 ++ .../console/OutputConsoleViewImpl.java | 30 ++++++ .../console/OutputConsoleViewImpl.ui.xml | 1 + .../panel/ProcessesPanelPresenter.java | 102 +++++++++++++++++- .../MachineLocalizationConstant.properties | 3 + .../panel/ProcessesPanelPresenterTest.java | 2 +- .../SubversionOutputConsolePresenter.java | 31 +++--- 26 files changed, 427 insertions(+), 59 deletions(-) create mode 100644 ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/DownloadWorkspaceOutputEvent.java diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/dialogs/DialogFactory.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/dialogs/DialogFactory.java index 954ec74db87a..5105c1175239 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/dialogs/DialogFactory.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/dialogs/DialogFactory.java @@ -206,6 +206,40 @@ InputDialog createInputDialog(@NotNull @Assisted("title") String title, @Nullable InputCallback inputCallback, @Nullable CancelCallback cancelCallback); + /** + * Create an input dialog with the specified initial value. + *

+ * The {@code initialValue} may be pre-selected. Selection begins + * at the specified {@code selectionStartIndex} and extends to the + * character at index {@code selectionLength}. + * + * @param title + * the window title + * @param label + * the label of the input field + * @param initialValue + * the value used to initialize the input + * @param selectionStartIndex + * the beginning index of the {@code initialValue} to select, inclusive + * @param selectionLength + * the number of characters of the {@code initialValue} to be selected + * @param okButtonLabel + * label for OK button + * @param inputCallback + * the callback used on OK + * @param cancelCallback + * the callback used on cancel + * @return an {@link InputDialog} instance + */ + InputDialog createInputDialog(@NotNull @Assisted("title") String title, + @NotNull @Assisted("label") String label, + @NotNull @Assisted("initialValue") String initialValue, + @NotNull @Assisted("selectionStartIndex") Integer selectionStartIndex, + @NotNull @Assisted("selectionLength") Integer selectionLength, + @NotNull @Assisted("okButtonLabel") String okButtonLabel, + @Nullable InputCallback inputCallback, + @Nullable CancelCallback cancelCallback); + /** * Create a choice dialog with only text as content. * Use empty string for button label to hide button. diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/outputconsole/OutputConsole.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/outputconsole/OutputConsole.java index 6df8d76245aa..ddbfd14ddf9a 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/outputconsole/OutputConsole.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/outputconsole/OutputConsole.java @@ -40,17 +40,21 @@ public interface OutputConsole extends Presenter { void close(); /** - * Listener for new output in the console. + * Action Delegate interface. */ - interface ConsoleOutputListener { + interface ActionDelegate { + /** Is called when new is printed */ void onConsoleOutput(OutputConsole console); + /** Is called when user asked to download output */ + void onDownloadOutput(OutputConsole console); + } /** - * Adds an output listener. + * Sets action delegate. */ - void addOutputListener(ConsoleOutputListener listener); + void addActionDelegate(ActionDelegate actionDelegate); } diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/DarkTheme.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/DarkTheme.java index 95482df337d1..a5b62bdd4f56 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/DarkTheme.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/DarkTheme.java @@ -788,7 +788,7 @@ public String colsolesToolbarBorderColor() { @Override public String consolesToolbarButtonColor() { - return "#aaaaaa"; + return "#808080"; } @Override diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/start/StartWorkspaceNotification.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/start/StartWorkspaceNotification.java index 75476dd4a556..fbfeee166351 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/start/StartWorkspaceNotification.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/start/StartWorkspaceNotification.java @@ -88,8 +88,7 @@ public void apply(List snapshots) throws OperationException { Widget widget = uiBinder.createAndBindUi(StartWorkspaceNotification.this); if (snapshots.isEmpty()) { - restore.setValue(false); - restore.setEnabled(false); + restore.setVisible(false); } loader.show(LoaderPresenter.Phase.WORKSPACE_STOPPED, widget); diff --git a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/FontAwesome.java b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/FontAwesome.java index 829f3c9dc77b..dd2a9dcc0936 100644 --- a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/FontAwesome.java +++ b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/FontAwesome.java @@ -42,6 +42,11 @@ public class FontAwesome { */ public static final String DOT_CIRCLE = ""; + /** + * http://fortawesome.github.io/Font-Awesome/icon/download/ + */ + public static final String DOWNLOAD = ""; + /** * http://fortawesome.github.io/Font-Awesome/icon/expand/ */ diff --git a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogPresenter.java b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogPresenter.java index 33b5b6465486..35c9ccf6cc38 100644 --- a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogPresenter.java +++ b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogPresenter.java @@ -74,6 +74,30 @@ public InputDialogPresenter(final @NotNull InputDialogView view, this.localizationConstant = localizationConstant; } + @AssistedInject + public InputDialogPresenter(final @NotNull InputDialogView view, + final @NotNull @Assisted("title") String title, + final @NotNull @Assisted("label") String label, + final @NotNull @Assisted("initialValue") String initialValue, + final @NotNull @Assisted("selectionStartIndex") Integer selectionStartIndex, + final @NotNull @Assisted("selectionLength") Integer selectionLength, + final @NotNull @Assisted("okButtonLabel") String okButtonLabel, + final @Nullable @Assisted InputCallback inputCallback, + final @Nullable @Assisted CancelCallback cancelCallback, + final UILocalizationConstant localizationConstant) { + this.view = view; + this.view.setContent(label); + this.view.setTitle(title); + this.view.setValue(initialValue); + this.view.setSelectionStartIndex(selectionStartIndex); + this.view.setSelectionLength(selectionLength); + this.view.setOkButtonLabel(okButtonLabel); + this.inputCallback = inputCallback; + this.cancelCallback = cancelCallback; + this.view.setDelegate(this); + this.localizationConstant = localizationConstant; + } + @Override public void cancelled() { view.closeDialog(); diff --git a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogView.java b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogView.java index 1f14d5c74624..c5768da5fb3a 100644 --- a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogView.java +++ b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogView.java @@ -36,6 +36,9 @@ public interface InputDialogView { /** Sets the window title. */ void setTitle(String title); + /** Sets new label for Ok button */ + void setOkButtonLabel(String label); + /** Returns the input value. */ String getValue(); @@ -62,7 +65,7 @@ public interface InputDialogView { boolean isCancelButtonInFocus(); /** The interface for the action delegate. */ - public interface ActionDelegate { + interface ActionDelegate { /** Defines what's done when the user clicks cancel. */ void cancelled(); @@ -76,4 +79,5 @@ public interface ActionDelegate { /** Performs any actions appropriate in response to the user having clicked the Enter key. */ void onEnterClicked(); } + } diff --git a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogViewImpl.java b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogViewImpl.java index 5c7fc71aac89..3561965b3ec0 100644 --- a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogViewImpl.java +++ b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/dialogs/input/InputDialogViewImpl.java @@ -104,6 +104,11 @@ public void setValue(String value) { this.value.setText(value); } + @Override + public void setOkButtonLabel(String label) { + footer.getOkButton().setText(label); + } + @Override public String getValue() { return value.getValue(); diff --git a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/DownloadWorkspaceOutputEvent.java b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/DownloadWorkspaceOutputEvent.java new file mode 100644 index 000000000000..26210b95bec6 --- /dev/null +++ b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/DownloadWorkspaceOutputEvent.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.ide.ui.loaders; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; + +/** + * Fire this event to download logs of the current workspace. + * + * @author Vitaliy Guliy + */ +public class DownloadWorkspaceOutputEvent extends GwtEvent { + + public interface Handler extends EventHandler { + + void onDownloadWorkspaceOutput(DownloadWorkspaceOutputEvent event); + + } + + public static final Type TYPE = new Type<>(); + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onDownloadWorkspaceOutput(this); + } + +} diff --git a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/LoaderPresenter.java b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/LoaderPresenter.java index 6b7a45498e8f..d935da86935f 100644 --- a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/LoaderPresenter.java +++ b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/LoaderPresenter.java @@ -13,6 +13,7 @@ import com.google.gwt.user.client.ui.Widget; import com.google.inject.Inject; import com.google.inject.Singleton; +import com.google.web.bindery.event.shared.EventBus; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,7 @@ * @author Vitaliy Guliy */ @Singleton -public class LoaderPresenter { +public class LoaderPresenter implements PopupLoader.ActionDelegate { public enum Phase { STARTING_WORKSPACE_RUNTIME, @@ -36,14 +37,17 @@ public enum Phase { private PopupLoaderFactory popupLoaderFactory; private PopupLoaderMessages locale; + private EventBus eventBus; private Map popups = new HashMap<>(); @Inject public LoaderPresenter(PopupLoaderFactory popupLoaderFactory, - PopupLoaderMessages locale) { + PopupLoaderMessages locale, + EventBus eventBus) { this.popupLoaderFactory = popupLoaderFactory; this.locale = locale; + this.eventBus = eventBus; } /** @@ -78,6 +82,7 @@ public PopupLoader show(Phase phase, Widget widget) { switch (phase) { case STARTING_WORKSPACE_RUNTIME: loader = popupLoaderFactory.getPopup(locale.startingWorkspaceRuntime(), locale.startingWorkspaceRuntimeDescription()); + loader.showDownloadButton(); break; case STARTING_WORKSPACE_AGENT: loader = popupLoaderFactory.getPopup(locale.startingWorkspaceAgent(), locale.startingWorkspaceAgentDescription()); @@ -96,6 +101,7 @@ public PopupLoader show(Phase phase, Widget widget) { break; } + loader.setDelegate(this); popups.put(phase, loader); return loader; } @@ -130,4 +136,9 @@ public void setError(Phase phase) { } } + @Override + public void onDownloadLogs() { + eventBus.fireEvent(new DownloadWorkspaceOutputEvent()); + } + } diff --git a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoader.java b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoader.java index dc8b2b06af58..e8bd53704ab1 100644 --- a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoader.java +++ b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoader.java @@ -27,4 +27,23 @@ public interface PopupLoader { */ void setError(); + /** + * Shows a button to download logs. + */ + void showDownloadButton(); + + /** + * Sets an action delegate to handle user actions. + * + * @param actionDelegate + * action delegate + */ + void setDelegate(ActionDelegate actionDelegate); + + interface ActionDelegate { + + void onDownloadLogs(); + + } + } diff --git a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderImpl.java b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderImpl.java index 6839dfc35603..a017a46ea863 100644 --- a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderImpl.java +++ b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderImpl.java @@ -10,11 +10,14 @@ *******************************************************************************/ package org.eclipse.che.ide.ui.loaders; +import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Hyperlink; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; @@ -53,6 +56,11 @@ interface LoaderPopupImplUiBinder extends UiBinder { @UiField FlowPanel customWidget; + @UiField + Hyperlink downloadOutputs; + + private ActionDelegate actionDelegate; + @AssistedInject public PopupLoaderImpl(LoaderPopupImplUiBinder uiBinder, @NotNull @Assisted("title") String title, @@ -83,6 +91,7 @@ public PopupLoaderImpl(LoaderPopupImplUiBinder uiBinder, this(uiBinder, title, description); if (widget != null) { + customWidget.clear(); customWidget.setVisible(true); customWidget.add(widget); playTimer.cancel(); @@ -115,6 +124,24 @@ public void setError() { titleLabel.setText(title); } + @Override + public void showDownloadButton() { + customWidget.setVisible(true); + downloadOutputs.setVisible(true); + } + + @Override + public void setDelegate(ActionDelegate actionDelegate) { + this.actionDelegate = actionDelegate; + } + + @UiHandler("downloadOutputs") + void downloadLogsClicked(ClickEvent e) { + if (actionDelegate != null) { + actionDelegate.onDownloadLogs(); + } + } + private Timer playTimer = new Timer() { @Override public void run() { diff --git a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderImpl.ui.xml b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderImpl.ui.xml index 042ab981578b..0c45590e6758 100644 --- a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderImpl.ui.xml +++ b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderImpl.ui.xml @@ -14,6 +14,8 @@ + + @eval popupLoaderBackgroundColor org.eclipse.che.ide.api.theme.Style.theme.popupLoaderBackgroundColor(); @@ -66,12 +68,25 @@ overflow: hidden; } + .hyperlink { + position: absolute; + top: 25px; + left: 15px; + } + + .hyperlink a { + font-size: 11px; + color: #94b6d4; + } + - + + + diff --git a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderMessages.java b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderMessages.java index e6ff4e4b580f..5a0e2e85fc30 100644 --- a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderMessages.java +++ b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/ui/loaders/PopupLoaderMessages.java @@ -55,4 +55,7 @@ public interface PopupLoaderMessages extends Messages { @Key("workspaceStopped.description") String workspaceStoppedDescription(); + @Key("downloadOutputs") + String downloadOutputs(); + } diff --git a/ide/commons-gwt/src/main/resources/org/eclipse/che/ide/ui/loaders/PopupLoaderMessages.properties b/ide/commons-gwt/src/main/resources/org/eclipse/che/ide/ui/loaders/PopupLoaderMessages.properties index b154e18f5504..93b9dbb0a4a2 100644 --- a/ide/commons-gwt/src/main/resources/org/eclipse/che/ide/ui/loaders/PopupLoaderMessages.properties +++ b/ide/commons-gwt/src/main/resources/org/eclipse/che/ide/ui/loaders/PopupLoaderMessages.properties @@ -21,3 +21,4 @@ snapshottingWorkspace.title = Snapshotting the workspace snapshottingWorkspace.description = Creating a snapshot of the current workspace workspaceStopped.title = Workspace is not running workspaceStopped.description = +downloadOutputs = Download outputs diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/outputconsole/GitOutputConsolePresenter.java b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/outputconsole/GitOutputConsolePresenter.java index 03d8c4e5dbe3..4baafb5928b9 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/outputconsole/GitOutputConsolePresenter.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/outputconsole/GitOutputConsolePresenter.java @@ -31,11 +31,12 @@ */ public class GitOutputConsolePresenter implements GitOutputPartView.ActionDelegate, GitOutputConsole { - private final GitOutputPartView view; - private final GitResources resources; - private final String title; - private final List outputListeners = new ArrayList<>(); + private final GitOutputPartView view; + private final GitResources resources; + private final String title; + + private final List actionDelegates = new ArrayList<>(); /** Construct empty Part */ @Inject @@ -77,8 +78,8 @@ public void print(String text) { } view.scrollBottom(); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } @@ -87,8 +88,8 @@ public void print(String text, String color) { view.print(text, color); view.scrollBottom(); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } @@ -134,12 +135,12 @@ public void stop() { @Override public void close() { - outputListeners.clear(); + actionDelegates.clear(); } @Override - public void addOutputListener(ConsoleOutputListener listener) { - outputListeners.add(listener); + public void addActionDelegate(ActionDelegate actionDelegate) { + actionDelegates.add(actionDelegate); } } diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineLocalizationConstant.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineLocalizationConstant.java index a6d49f62a6f8..44b9507cc256 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineLocalizationConstant.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineLocalizationConstant.java @@ -22,6 +22,12 @@ public interface MachineLocalizationConstant extends Messages { @Key("button.cancel") String cancelButton(); + @Key("button.download") + String downloadButton(); + + @Key("downloadOutputs") + String downloadOutputs(); + @Key("main.menu.machine") String mainMenuMachine(); diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/CommandOutputConsolePresenter.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/CommandOutputConsolePresenter.java index fb1e1cd5f7f9..ad043e3027a6 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/CommandOutputConsolePresenter.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/CommandOutputConsolePresenter.java @@ -76,7 +76,7 @@ public class CommandOutputConsolePresenter implements CommandOutputConsole, Outp /** Follow output when printing text */ private boolean followOutput = true; - private List outputListenes = new ArrayList<>(); + private final List actionDelegates = new ArrayList<>(); @Inject public CommandOutputConsolePresenter(final OutputConsoleView view, @@ -146,8 +146,8 @@ public void listenToOutput(String wsChannel) { protected void onMessageReceived(String result) { view.print(result, result.endsWith("\r")); - for (ConsoleOutputListener listener : outputListenes) { - listener.onConsoleOutput(CommandOutputConsolePresenter.this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(CommandOutputConsolePresenter.this); } } @@ -260,12 +260,12 @@ public void stop() { @Override public void close() { - outputListenes.clear(); + actionDelegates.clear(); } @Override - public void addOutputListener(ConsoleOutputListener listener) { - outputListenes.add(listener); + public void addActionDelegate(ActionDelegate actionDelegate) { + actionDelegates.add(actionDelegate); } @Override @@ -294,6 +294,13 @@ public void clearOutputsButtonClicked() { view.clearConsole(); } + @Override + public void downloadOutputsButtonClicked() { + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onDownloadOutput(this); + } + } + @Override public void wrapTextButtonClicked() { wrapText = !wrapText; @@ -315,4 +322,14 @@ public void onOutputScrolled(boolean bottomReached) { view.toggleScrollToEndButton(bottomReached); } + /** + * Returns the console text. + * + * @return + * console text + */ + public String getText() { + return view.getText(); + } + } diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/DefaultOutputConsole.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/DefaultOutputConsole.java index 987d6a31765b..f6ca2f97c52f 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/DefaultOutputConsole.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/DefaultOutputConsole.java @@ -32,7 +32,7 @@ public class DefaultOutputConsole implements OutputConsole, OutputConsoleView.Ac private final MachineResources resources; private String title; - private final List outputListeners; + private final List actionDelegates = new ArrayList<>(); private boolean wrapText; @@ -46,7 +46,6 @@ public DefaultOutputConsole(OutputConsoleView view, this.view = view; this.title = title; this.resources = resources; - outputListeners = new ArrayList<>(); view.setDelegate(this); @@ -65,8 +64,8 @@ public DefaultOutputConsole(OutputConsoleView view, public void printText(String text) { view.print(text, text.endsWith("\r")); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } @@ -81,11 +80,21 @@ public void printText(String text) { public void printText(String text, String color) { view.print(text, text.endsWith("\r"), color); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } + /** + * Returns the console text. + * + * @return + * console text + */ + public String getText() { + return view.getText(); + } + /** {@inheritDoc} */ @Override public void go(AcceptsOneWidget container) { @@ -116,12 +125,12 @@ public void stop() { @Override public void close() { - outputListeners.clear(); + actionDelegates.clear(); } @Override - public void addOutputListener(ConsoleOutputListener listener) { - outputListeners.add(listener); + public void addActionDelegate(ActionDelegate actionDelegate) { + actionDelegates.add(actionDelegate); } @Override @@ -137,6 +146,13 @@ public void clearOutputsButtonClicked() { view.clearConsole(); } + @Override + public void downloadOutputsButtonClicked() { + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onDownloadOutput(this); + } + } + @Override public void wrapTextButtonClicked() { wrapText = !wrapText; diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/OutputConsoleView.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/OutputConsoleView.java index a43a821b2590..1dfc0a7e397b 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/OutputConsoleView.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/OutputConsoleView.java @@ -59,6 +59,14 @@ public interface OutputConsoleView extends View nodes = consoleLines.getElement().getChildNodes(); + + for (int i = 0; i < nodes.getLength(); i++) { + Node node = nodes.getItem(i); + Element element = node.cast(); + text += element.getInnerText() + "\r\n"; + } + + return text; + } + @Override public void onScroll(ScrollEvent event) { // Do nothing if content height less scroll area height diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/OutputConsoleViewImpl.ui.xml b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/OutputConsoleViewImpl.ui.xml index 9dac4a1a0fd0..31357970c352 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/OutputConsoleViewImpl.ui.xml +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/outputspanel/console/OutputConsoleViewImpl.ui.xml @@ -195,6 +195,7 @@ + diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java index 8dcd28a5c08a..a2357edc5514 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java @@ -12,6 +12,7 @@ import com.google.common.base.Strings; import com.google.gwt.core.client.Scheduler; +import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.gwt.user.client.ui.IsWidget; import com.google.inject.Inject; @@ -54,12 +55,14 @@ import org.eclipse.che.ide.extension.machine.client.machine.MachineStateEvent; import org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandConsoleFactory; import org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole; +import org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsolePresenter; import org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole; import org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter; import org.eclipse.che.ide.extension.machine.client.processes.ProcessFinishedEvent; import org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode; import org.eclipse.che.ide.extension.machine.client.processes.actions.ConsoleTreeContextMenu; import org.eclipse.che.ide.extension.machine.client.processes.actions.ConsoleTreeContextMenuFactory; +import org.eclipse.che.ide.ui.loaders.DownloadWorkspaceOutputEvent; import org.eclipse.che.ide.ui.multisplitpanel.SubPanel; import org.eclipse.che.ide.util.loging.Log; import org.vectomatic.dom.svg.ui.SVGResource; @@ -67,6 +70,7 @@ import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -87,12 +91,13 @@ @Singleton public class ProcessesPanelPresenter extends BasePresenter implements ProcessesPanelView.ActionDelegate, ProcessFinishedEvent.Handler, - OutputConsole.ConsoleOutputListener, + OutputConsole.ActionDelegate, WorkspaceStartedEvent.Handler, WorkspaceStoppedEvent.Handler, MachineStateEvent.Handler, WsAgentStateHandler, - EnvironmentOutputEvent.Handler { + EnvironmentOutputEvent.Handler, + DownloadWorkspaceOutputEvent.Handler { public static final String SSH_PORT = "22"; private static final String DEFAULT_TERMINAL_NAME = "Terminal"; @@ -168,6 +173,7 @@ public ProcessesPanelPresenter(ProcessesPanelView view, eventBus.addHandler(WsAgentStateEvent.TYPE, this); eventBus.addHandler(MachineStateEvent.TYPE, this); eventBus.addHandler(EnvironmentOutputEvent.TYPE, this); + eventBus.addHandler(DownloadWorkspaceOutputEvent.TYPE, this); } @Override @@ -449,7 +455,7 @@ public void setWidget(final IsWidget widget) { } }); - outputConsole.addOutputListener(this); + outputConsole.addActionDelegate(this); } private void refreshStopButtonState(String selectedNodeId) { @@ -746,7 +752,7 @@ public void apply(List arg) throws OperationException { .withType(machineProcessDto.getType()); final CommandType type = commandTypeRegistry.getCommandTypeById(commandDto.getType()); - if (type != null ) { + if (type != null) { final CommandConfiguration configuration = type.getConfigurationFactory().createFromDto(commandDto); final CommandOutputConsole console = commandConsoleFactory.create(configuration, machine); console.listenToOutput(machineProcessDto.getOutputChannel()); @@ -801,6 +807,29 @@ public void printMachineOutput(String machineId, String text, String color) { } } + /** + * Returns the console text for the specified machine. + * + * @param machineId + * machine ID + * @return + * console text or NULL if there is no machine with specified ID + */ + public String getText(String machineId) { + OutputConsole console = consoles.get(machineId); + if (console == null) { + return null; + } + + if (console instanceof DefaultOutputConsole) { + return ((DefaultOutputConsole)console).getText(); + } else if (console instanceof CommandOutputConsolePresenter) { + return ((CommandOutputConsolePresenter)console).getText(); + } + + return null; + } + /** * Returns context selected tree node. * @@ -836,4 +865,69 @@ public void execute() { } }); } + + @Override + public void onDownloadWorkspaceOutput(DownloadWorkspaceOutputEvent event) { + Machine devMachine = null; + + for (ProcessTreeNode machineNode : machineNodes.values()) { + if (!(machineNode.getData() instanceof Machine)) { + continue; + } + + Machine machine = (Machine)machineNode.getData(); + if (!machine.getConfig().isDev()) { + continue; + } + + devMachine = machine; + break; + } + + if (devMachine == null) { + return; + } + + String fileName = appContext.getWorkspace().getNamespace() + "-" + appContext.getWorkspace().getConfig().getName() + + " " + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + + ".log"; + + download(fileName, getText(devMachine.getId())); + } + + private native void log(String msg) /*-{ + console.log(msg); + }-*/; + + @Override + public void onDownloadOutput(OutputConsole console) { + String id = consoleCommands.get(console); + + String fileName = appContext.getWorkspace().getNamespace() + "-" + appContext.getWorkspace().getConfig().getName() + + " " + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + + ".log"; + download(fileName, getText(id)); + } + + /** + * Invokes the browser to download a file. + * + * @param fileName + * file name + * @param text + * file content + */ + private native void download(String fileName, String text) /*-{ + var element = $doc.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); + element.setAttribute('download', fileName); + + element.style.display = 'none'; + $doc.body.appendChild(element); + + element.click(); + + $doc.body.removeChild(element); + }-*/; + } diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/resources/org/eclipse/che/ide/extension/machine/client/MachineLocalizationConstant.properties b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/resources/org/eclipse/che/ide/extension/machine/client/MachineLocalizationConstant.properties index 539217763acb..30c87bf2593c 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/resources/org/eclipse/che/ide/extension/machine/client/MachineLocalizationConstant.properties +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/resources/org/eclipse/che/ide/extension/machine/client/MachineLocalizationConstant.properties @@ -11,6 +11,9 @@ ##### Buttons ##### button.cancel = Cancel +button.download = Download + +downloadOutputs = Download outputs ##### Actions ##### main.menu.machine = Machine diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenterTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenterTest.java index 47b3fcb08084..f79f855fa88b 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenterTest.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenterTest.java @@ -188,7 +188,7 @@ public void shouldAddMachineWhenMachineCreating() throws Exception { MachineStateEvent machineStateEvent = mock(MachineStateEvent.class); when(machineStateEvent.getMachine()).thenReturn(machine); - verify(eventBus, times(6)).addHandler(anyObject(), machineStateHandlerCaptor.capture()); + verify(eventBus, times(7)).addHandler(anyObject(), machineStateHandlerCaptor.capture()); MachineStateEvent.Handler machineStateHandler = machineStateHandlerCaptor.getAllValues().get(0); machineStateHandler.onMachineCreating(machineStateEvent); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionOutputConsolePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionOutputConsolePresenter.java index 2b075f768365..0337208f5c11 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionOutputConsolePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionOutputConsolePresenter.java @@ -34,7 +34,7 @@ public class SubversionOutputConsolePresenter implements SubversionOutputConsole private final SubversionOutputConsoleView view; private final String title; - private final List outputListeners = new ArrayList<>(); + private final List actionDelegates = new ArrayList<>(); @Inject public SubversionOutputConsolePresenter(final SubversionExtensionLocalizationConstants constants, @@ -67,8 +67,8 @@ public void print(@NotNull final String text) { } view.scrollBottom(); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } @@ -84,8 +84,8 @@ public void print(@NotNull String text, @NotNull String color) { view.print(text, color); view.scrollBottom(); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } @@ -99,8 +99,8 @@ public void print(@NotNull String text, @NotNull String color) { public void printCommand(@NotNull String text) { view.printPredefinedStyle(text, "font-weight: bold; font-style: italic;"); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } @@ -130,7 +130,9 @@ public void onScrollClicked() { } @Override - public String getTitle() { return title; } + public String getTitle() { + return title; + } /** * Returns the title SVG image resource of this console. @@ -155,7 +157,6 @@ public boolean isFinished() { */ @Override public void stop() { - } /** @@ -163,16 +164,12 @@ public void stop() { */ @Override public void close() { - outputListeners.clear(); + actionDelegates.clear(); } - /** - * Adds an output listener. - * - * @param listener - */ @Override - public void addOutputListener(ConsoleOutputListener listener) { - outputListeners.add(listener); + public void addActionDelegate(ActionDelegate actionDelegate) { + actionDelegates.add(actionDelegate); } + } From b9ab511e7c19ae8af0f441d18874342c8c068101 Mon Sep 17 00:00:00 2001 From: Ilya Buziuk Date: Tue, 4 Oct 2016 19:46:02 +0200 Subject: [PATCH 11/33] Adding Node.js info to the 'Requirements' section of the README.MD (#2699) Signed-off-by: Ilya Buziuk --- dashboard/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dashboard/README.md b/dashboard/README.md index dfaa36e7ddf4..5844bb9a9dd7 100644 --- a/dashboard/README.md +++ b/dashboard/README.md @@ -5,8 +5,13 @@ Che Dashboard ============== #Requirements +- Node.js `v4.x.x` (`v5.x.x` / `v6.x.x` are currently not supported) +- npm +- Bower +- gulp + +Installation instructions for Node.js and npm can be found on the following [link](https://docs.npmjs.com/getting-started/installing-node). Bower and gulp are CLI utilities which are installed via npm: -This version is using bower and gulp as tools. ```sh $ npm install --global bower gulp ``` From 180c9501170ca0b2eafd8637360d2a60f60ae078 Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Tue, 4 Oct 2016 22:23:26 +0200 Subject: [PATCH 12/33] Improvements on DTO Typescript generator (#2637) - Add integration tests that test the TypeScript generated DTOs - Add toJson() method on DTO - Add support of constructor with empty object (like new MyDTOImpl().withName("hello")) - Integration tests can be disabled with -DskipIntegrationTests flag Change-Id: I3bcc2de6bb549ef8e29a266270ebcf0735e696d1 Signed-off-by: Florent BENOIT --- .../pom.xml | 102 +++++++ .../dto/TypeScriptDTOGeneratorMojoITest.java | 274 ++++++++++++++++++ .../src/it/resources/dto.spec.ts | 106 +++++++ .../src/it/resources/package.json | 20 ++ .../che/plugin/typescript/dto/DTOHelper.java | 2 +- .../dto/model/FieldAttributeModel.java | 24 ++ .../plugin/typescript/dto/typescript.template | 105 +++++-- .../plugin/typescript/dto/MyCustomDTO.java | 14 + .../che/plugin/typescript/dto/MyOtherDTO.java | 25 ++ .../plugin/typescript/dto/MySimpleDTO.java | 29 ++ .../che/plugin/typescript/dto/Status.java | 21 ++ .../src/test/projects/project/pom.xml | 2 +- 12 files changed, 696 insertions(+), 28 deletions(-) create mode 100644 core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java create mode 100644 core/che-core-typescript-dto-maven-plugin/src/it/resources/dto.spec.ts create mode 100644 core/che-core-typescript-dto-maven-plugin/src/it/resources/package.json create mode 100644 core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyOtherDTO.java create mode 100644 core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MySimpleDTO.java create mode 100644 core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/Status.java diff --git a/core/che-core-typescript-dto-maven-plugin/pom.xml b/core/che-core-typescript-dto-maven-plugin/pom.xml index 773a34857ce0..2bd4d247c925 100644 --- a/core/che-core-typescript-dto-maven-plugin/pom.xml +++ b/core/che-core-typescript-dto-maven-plugin/pom.xml @@ -98,14 +98,70 @@ plexus-utils test + + org.eclipse.che.core + che-core-api-core + test + org.mockito mockito-all test + + org.slf4j + slf4j-api + test + + + org.testng + testng + test + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-it-test-source + process-resources + + add-test-source + + + + src/it/java + + + + + add-it-test-resources + process-resources + + add-test-resource + + + + + src/it/resources + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*ITest.java + + + org.apache.maven.plugins maven-plugin-plugin @@ -123,4 +179,50 @@ + + + integration-tests + + + !skipIntegrationTests + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + integration-test + + test + + + + ${project.build.directory} + + + none + + + **/*ITest.java + + + + + + + **/*ITest.java + + + + + + + + + + diff --git a/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java b/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java new file mode 100644 index 000000000000..5a80b679e155 --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java @@ -0,0 +1,274 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.typescript.dto; + +import org.eclipse.che.api.core.util.SystemInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toList; + +/** + * Integration test of TypeScriptDTOGeneratorMojo + * It uses docker to launch TypeScript compiler and then launch JavaScript tests to ensure generator has worked correctly + * @author Florent Benoit + */ +public class TypeScriptDTOGeneratorMojoITest { + + /** + * Logger. + */ + private static final Logger LOG = LoggerFactory.getLogger(TypeScriptDTOGeneratorMojoITest.class); + + /** + * DTO Generated file + */ + private static final String GENERATED_DTO_NAME = "my-typescript-test-module.ts"; + + /** + * DTO new name + */ + private static final String DTO_FILENAME = "dto.ts"; + + /** + * DTO test name + */ + private static final String DTO_SPEC_FILENAME = "dto.spec.ts"; + + /** + * Target folder of maven. + */ + private Path buildDirectory; + + /** + * Path to the package.json file used to setup typescript compiler + */ + private Path dtoSpecJsonPath; + + /** + * Path to the package.json file used to setup typescript compiler + */ + private Path packageJsonPath; + + /** + * Root directory for our tests + */ + private Path rootPath; + + /** + * Linux uid. + */ + private String linuxUID; + + /** + * Linux gid. + */ + private String linuxGID; + + /** + * Init folders + */ + @BeforeClass + public void init() throws URISyntaxException, IOException, InterruptedException { + // setup packages + this.packageJsonPath = new File(TypeScriptDTOGeneratorMojoITest.class.getClassLoader().getResource("package.json").toURI()).toPath(); + + this.rootPath = this.packageJsonPath.getParent(); + + // target folder + String buildDirectoryProperty = System.getProperty("buildDirectory"); + if (buildDirectoryProperty != null) { + buildDirectory = new File(buildDirectoryProperty).toPath(); + } else { + buildDirectory = packageJsonPath.getParent().getParent(); + } + + LOG.info("Using building directory {0}", buildDirectory); + } + + /** + * Generates a docker exec command used to launch node commands + * @return list of command parameters + */ + protected List getDockerExec() { + // setup command line + List command = new ArrayList(); + command.add("docker"); + command.add("run"); + command.add("--rm"); + command.add("-v"); + command.add(rootPath.toString() + ":/usr/src/app"); + command.add("-w"); + command.add("/usr/src/app"); + command.add("node:6"); + command.add("/bin/sh"); + command.add("-c"); + + return command; + } + + /** + * Get UID of current user (used on Linux) + */ + protected String getUid() throws IOException, InterruptedException { + if (this.linuxUID == null) { + // grab user id + ProcessBuilder uidProcessBuilder = new ProcessBuilder("id", "-u"); + Process processId = uidProcessBuilder.start(); + int resultId = processId.waitFor(); + String uid = ""; + try (BufferedReader outReader = new BufferedReader(new InputStreamReader(processId.getInputStream()))) { + uid = String.join(System.lineSeparator(), outReader.lines().collect(toList())); + } catch (Exception error) { + throw new IllegalStateException("Unable to get uid" + uid); + } + + if (resultId != 0) { + throw new IllegalStateException("Unable to get uid" + uid); + } + + try { + Integer.valueOf(uid); + } catch (NumberFormatException e) { + throw new IllegalStateException("The uid is not a number" + uid); + } + this.linuxUID = uid; + } + + return this.linuxUID; + } + + /** + * Get GID of current user (used on Linux) + */ + protected String getGid() throws IOException, InterruptedException { + if (this.linuxGID == null) { + + ProcessBuilder gidProcessBuilder = new ProcessBuilder("id", "-g"); + Process processGid = gidProcessBuilder.start(); + int resultGid = processGid.waitFor(); + String gid = ""; + try (BufferedReader outReader = new BufferedReader(new InputStreamReader(processGid.getInputStream()))) { + gid = String.join(System.lineSeparator(), outReader.lines().collect(toList())); + } catch (Exception error) { + throw new IllegalStateException("Unable to get gid" + gid); + } + + if (resultGid != 0) { + throw new IllegalStateException("Unable to get gid" + gid); + } + + try { + Integer.valueOf(gid); + } catch (NumberFormatException e) { + throw new IllegalStateException("The uid is not a number" + gid); + } + + this.linuxGID = gid; + } + + return this.linuxGID; + } + + /** + * Setup typescript compiler by downloading the dependencies + * @throws IOException if unable to start process + * @throws InterruptedException if unable to wait the end of the process + */ + @Test(groups = {"tools"}) + protected void installTypeScriptCompiler() throws IOException, InterruptedException { + + // setup command line + List command = getDockerExec(); + + // avoid root permissions in generated files + if (SystemInfo.isLinux()) { + + command.add("groupadd -g " + getGid() + " user && useradd -u" + getUid() + " -g user user && (chown --silent -R user.user /usr/src/app || true) && cd /usr/src/app/ && npm install && (chown --silent -R user.user /usr/src/app || true)"); + } else { + command.add("npm install"); + } + // setup typescript compiler + ProcessBuilder processBuilder = new ProcessBuilder().command(command).directory(rootPath.toFile()).redirectErrorStream(true).inheritIO(); + Process process = processBuilder.start(); + + LOG.info("Installing TypeScript compiler in {0}", rootPath); + int resultProcess = process.waitFor(); + + if (resultProcess != 0) { + throw new IllegalStateException("Install of TypeScript has failed"); + } + LOG.info("TypeScript compiler installed."); + + } + + /** + * Starts tests by compiling first generated DTO from maven plugin + * @throws IOException if unable to start process + * @throws InterruptedException if unable to wait the end of the process + */ + @Test(dependsOnGroups = "tools") + public void compileDTOAndLaunchTests() throws IOException, InterruptedException { + + // search DTO + Path p = this.buildDirectory; + final int maxDepth = 10; + Stream matches = java.nio.file.Files.find(p, maxDepth, (path, basicFileAttributes) -> path.getFileName().toString().equals(GENERATED_DTO_NAME)); + + // take first + Optional optionalPath = matches.findFirst(); + if (!optionalPath.isPresent()) { + throw new IllegalStateException("Unable to find generated DTO file named '" + GENERATED_DTO_NAME + "'. Check it has been generated first"); + } + + Path generatedDtoPath = optionalPath.get(); + + //copy it in test resources folder where package.json is + java.nio.file.Files.copy(generatedDtoPath, this.rootPath.resolve(DTO_FILENAME), StandardCopyOption.REPLACE_EXISTING); + + // setup command line + List command = getDockerExec(); + + // avoid root permissions in generated files + if (SystemInfo.isLinux()) { + command.add("groupadd -g " + getGid() + " user && useradd -u" + getUid() + " -g user user && (chown --silent -R user.user /usr/src/app || true) && npm test && (chown --silent -R user.user /usr/src/app || true)"); + } else { + command.add("npm test"); + } + // setup typescript compiler + ProcessBuilder processBuilder = new ProcessBuilder().command(command).directory(rootPath.toFile()).redirectErrorStream(true).inheritIO(); + Process process = processBuilder.start(); + + LOG.info("Starting TypeScript tests..."); + int resultProcess = process.waitFor(); + + if (resultProcess != 0) { + throw new IllegalStateException("DTO has failed to compile"); + } + LOG.info("TypeScript tests OK"); + + } + +} diff --git a/core/che-core-typescript-dto-maven-plugin/src/it/resources/dto.spec.ts b/core/che-core-typescript-dto-maven-plugin/src/it/resources/dto.spec.ts new file mode 100644 index 000000000000..e9be9d6278b2 --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/it/resources/dto.spec.ts @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + */ +import {org} from './dto'; + +let expect = require('chai').expect; + +class DTOBuilder { + + static MY_CUSTOM_NAME : string = "myCustomName"; + static MY_CUSTOM_STATUS : string = "myCustomStatus"; + static MY_CUSTOM_MAP_ENTRY_NAME : string = "myEntry"; + + static MY_OTHER_NAME : string = "myOtherName"; + + static MY_SIMPLE_ID : number = 2503; + static MY_SIMPLE_BOOLEAN : boolean = true; + static MY_SIMPLE_DOUBLE : number = 19.79; + + + static buildSimpleDto() : org.eclipse.che.plugin.typescript.dto.MySimpleDTO { + let mySimpleDTO : org.eclipse.che.plugin.typescript.dto.MySimpleDTO = new org.eclipse.che.plugin.typescript.dto.MySimpleDTOImpl(); + mySimpleDTO.withId(DTOBuilder.MY_SIMPLE_ID).withBoolean(DTOBuilder.MY_SIMPLE_BOOLEAN).withDouble(DTOBuilder.MY_SIMPLE_DOUBLE); + return mySimpleDTO; + } + + static buildCustomDto() : org.eclipse.che.plugin.typescript.dto.MyCustomDTO { + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = new org.eclipse.che.plugin.typescript.dto.MyCustomDTOImpl(); + myCustomDTO.withName(DTOBuilder.MY_CUSTOM_NAME).withStatus(DTOBuilder.MY_CUSTOM_STATUS).withConfig(DTOBuilder.buildConfigDTO()); + myCustomDTO.getCustomMap().set(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME, DTOBuilder.buildConfigDTO()); + return myCustomDTO; + } + + static buildConfigDTO() : org.eclipse.che.plugin.typescript.dto.MyOtherDTO { + let configDTO : org.eclipse.che.plugin.typescript.dto.MyOtherDTO = new org.eclipse.che.plugin.typescript.dto.MyOtherDTOImpl(); + configDTO.withName(DTOBuilder.MY_OTHER_NAME); + return configDTO; + } + +} + +describe("DTO serialization tests", () => { + + + it("check simple DTO implementation", () => { + + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MySimpleDTO = DTOBuilder.buildSimpleDto(); + expect(myCustomDTO.getId()).to.eql(DTOBuilder.MY_SIMPLE_ID); + expect(myCustomDTO.getBoolean()).to.eql(DTOBuilder.MY_SIMPLE_BOOLEAN); + expect(myCustomDTO.getDouble()).to.eql(DTOBuilder.MY_SIMPLE_DOUBLE); + + }); + + + it("check build DTO implementation", () => { + + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = DTOBuilder.buildCustomDto(); + expect(myCustomDTO.getName()).to.eql(DTOBuilder.MY_CUSTOM_NAME); + expect(myCustomDTO.getStatus()).to.eql(DTOBuilder.MY_CUSTOM_STATUS); + expect(myCustomDTO.getConfig()).to.exist; + expect(myCustomDTO.getConfig().getName()).to.eql(DTOBuilder.MY_OTHER_NAME); + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME)).to.exist; + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME).getName()).to.eql(DTOBuilder.MY_OTHER_NAME); + + }); + + + it("check build DTO implementation", () => { + + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = DTOBuilder.buildCustomDto(); + expect(myCustomDTO.getName()).to.eql(DTOBuilder.MY_CUSTOM_NAME); + expect(myCustomDTO.getStatus()).to.eql(DTOBuilder.MY_CUSTOM_STATUS); + expect(myCustomDTO.getConfig()).to.exist; + expect(myCustomDTO.getConfig().getName()).to.eql(DTOBuilder.MY_OTHER_NAME); + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME)).to.exist; + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME).getName()).to.eql(DTOBuilder.MY_OTHER_NAME); + + }); + + + it("check build DTO implementation from source", () => { + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = DTOBuilder.buildCustomDto(); + + // build it from generated output + let myCustomDTOFromSource : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = new org.eclipse.che.plugin.typescript.dto.MyCustomDTOImpl(myCustomDTO.toJson()); + + expect(myCustomDTO.getName()).to.eql(myCustomDTOFromSource.getName()); + expect(myCustomDTOFromSource.getConfig()).to.exist; + expect(myCustomDTO.getConfig().getName()).to.eql(myCustomDTOFromSource.getConfig().getName()); + expect(myCustomDTOFromSource.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME)).to.exist; + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME).getName()).to.eql(myCustomDTOFromSource.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME).getName()); + + expect(myCustomDTO.toJson()).to.eql(myCustomDTOFromSource.toJson()); + }); + + + + +}); diff --git a/core/che-core-typescript-dto-maven-plugin/src/it/resources/package.json b/core/che-core-typescript-dto-maven-plugin/src/it/resources/package.json new file mode 100644 index 000000000000..240a81875831 --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/it/resources/package.json @@ -0,0 +1,20 @@ +{ + "name": "che-typescript-maven-generator-integration-test", + "version": "1.0.0", + "description": "TypeScript integration test", + "author": "Florent Benoit", + "license": "EPL-1.0", + "scripts": { + "pretest": "./node_modules/.bin/tsc --target ES6 --outDir lib --module commonjs *.ts", + "test": "./node_modules/.bin/mocha lib/*.spec.js" + }, + "devDependencies": { + "chai": "3.5.0", + "mocha": "3.0.2", + "typescript": "2.0.3" + }, + "dependencies": { + "@types/mocha": "2.2.32", + "@types/node": "6.0.41" + } +} diff --git a/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/DTOHelper.java b/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/DTOHelper.java index eff766e3225a..0ec511bb271f 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/DTOHelper.java +++ b/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/DTOHelper.java @@ -129,7 +129,7 @@ public static String convertType(Type type) { } else if (String.class.equals(type) || (type instanceof Class && ((Class)type).isEnum())) { // Maybe find a better enum type for typescript return "string"; - } else if (Integer.class.equals(type) || Integer.TYPE.equals(type) || Long.class.equals(type) || Long.TYPE.equals(type)) { + } else if (Integer.class.equals(type) || Integer.TYPE.equals(type) || Long.class.equals(type) || Long.TYPE.equals(type) || Double.class.equals(type) || Double.TYPE.equals(type)) { return "number"; } else if (Boolean.class.equals(type)) { return "boolean"; diff --git a/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/model/FieldAttributeModel.java b/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/model/FieldAttributeModel.java index 73a563f2eb17..8cc4f89ccffa 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/model/FieldAttributeModel.java +++ b/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/model/FieldAttributeModel.java @@ -68,6 +68,11 @@ public class FieldAttributeModel { */ private boolean isListOfDto; + /** + * This map type is a map of DTOs + */ + private boolean isMapOfDto; + /** * The type is a DTO or a list of DTO and then this value is the name of the DTO implementation */ @@ -78,6 +83,10 @@ public class FieldAttributeModel { */ private boolean isDto; + /** + * type is a Enum object. + */ + private boolean isEnum; /** * Build a new field model based on the name and Java type @@ -105,6 +114,8 @@ public FieldAttributeModel(String fieldName, Type type) { } else if (this.type instanceof Class && ((Class)this.type).isAnnotationPresent(DTO.class)) { this.isDto = true; dtoImpl = this.type.getTypeName() + "Impl"; + } else if (this.type instanceof Class && ((Class)this.type).isEnum()) { + this.isEnum = true; } } @@ -124,6 +135,11 @@ protected void analyzeParametrizedType(ParameterizedType parameterizedType, Type } } else if (Map.class.equals(rawType)) { isMap = true; + if (parameterizedType.getActualTypeArguments()[1] instanceof Class && + ((Class)parameterizedType.getActualTypeArguments()[1]).isAnnotationPresent(DTO.class)) { + isMapOfDto = true; + dtoImpl = convertType(parameterizedType.getActualTypeArguments()[1]) + "Impl"; + } } } @@ -155,6 +171,10 @@ public boolean isListOfDto() { return isListOfDto; } + public boolean isMapOfDto() { + return isMapOfDto; + } + public String getDtoImpl() { return dtoImpl; } @@ -167,6 +187,10 @@ public boolean isNeedInitialize() { return needInitialize; } + public boolean isEnum() { + return isEnum; + } + public String getName() { return this.fieldName; } diff --git a/core/che-core-typescript-dto-maven-plugin/src/main/resources/org/eclipse/che/plugin/typescript/dto/typescript.template b/core/che-core-typescript-dto-maven-plugin/src/main/resources/org/eclipse/che/plugin/typescript/dto/typescript.template index 6db19b19dd97..1a8686fa5c59 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/main/resources/org/eclipse/che/plugin/typescript/dto/typescript.template +++ b/core/che-core-typescript-dto-maven-plugin/src/main/resources/org/eclipse/che/plugin/typescript/dto/typescript.template @@ -12,6 +12,7 @@ export module { (,}>): ; }> + toJson() : any; \} \} @@ -37,30 +38,39 @@ export module { this. = new (); - if (__jsonObject.) { - - - __jsonObject..forEach((item) => { - - this..push(new (item)); - - this..push(item); + if (__jsonObject) { + if (__jsonObject.) { + + + __jsonObject..forEach((item) => { + + this..push(new (item)); + + this..push(item); + + \}); - \}); - - - - let tmp : Array\ = Object.keys(__jsonObject.); - tmp.forEach((key) => { - this..set(key, __jsonObject.[key]); - \}); - - - this. = __jsonObject.; - - - this. = new (__jsonObject.); - + + + let tmp : Array\ = Object.keys(__jsonObject.); + tmp.forEach((key) => { + + this..set(key, new (__jsonObject.[key])); + + this..set(key, __jsonObject.[key]); + + \}); + + + this. = __jsonObject.; + + + this. = __jsonObject.; + + + this. = new (__jsonObject.); + + \} \} }> \} @@ -76,18 +86,61 @@ export module { ( : ) : void { - this. = this.; + this. = ; \} ( : ) : { - this. = this.; + this. = ; return this; \} }> - \} + + toJson() : any { + let json : any = {\}; + + ) { + + + let listArray = []; + this..forEach((item) => { + + listArray.push((item as ).toJson()); + + listArray.push(item); + + json. = listArray; + \}); + + + + let tmpMap : any = {\}; + for (const [key, value] of this..entries()) { + + tmpMap[key] = (value as ).toJson(); + + tmpMap[key] = value; + + \} + json. = tmpMap; + + + json. = this.; + + + json. = this.; + + + json. = (this. as ).toJson(); + + \} + }> + return json; + \} + \} \} }> diff --git a/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyCustomDTO.java b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyCustomDTO.java index 7f1b1bca53cb..caf219174d93 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyCustomDTO.java +++ b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyCustomDTO.java @@ -12,6 +12,8 @@ import org.eclipse.che.dto.shared.DTO; +import java.util.Map; + /** * @author Florent Benoit */ @@ -22,4 +24,16 @@ public interface MyCustomDTO { void setName(String name); MyCustomDTO withName(String name); + MyOtherDTO getConfig(); + MyCustomDTO withConfig(MyOtherDTO otherDTO); + void setConfig(MyOtherDTO otherDTO); + + void setStatus(Status status); + MyCustomDTO withStatus(Status status); + Status getStatus(); + + Map getCustomMap(); + void setCustomMap(Map map); + MyCustomDTO withCustomMap(Map map); + } diff --git a/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyOtherDTO.java b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyOtherDTO.java new file mode 100644 index 000000000000..eb5a0780b891 --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyOtherDTO.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.typescript.dto; + +import org.eclipse.che.dto.shared.DTO; + +/** + * @author Florent Benoit + */ +@DTO +public interface MyOtherDTO { + + String getName(); + void setName(String name); + MyOtherDTO withName(String name); + +} diff --git a/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MySimpleDTO.java b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MySimpleDTO.java new file mode 100644 index 000000000000..13443e53b4da --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MySimpleDTO.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.typescript.dto; + +import org.eclipse.che.dto.shared.DTO; + +/** + * @author Florent Benoit + */ +@DTO +public interface MySimpleDTO { + + int getId(); + MySimpleDTO withId(int id); + + boolean getBoolean(); + MySimpleDTO withBoolean(boolean bool); + + double getDouble(); + MySimpleDTO withDouble(double d); +} diff --git a/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/Status.java b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/Status.java new file mode 100644 index 000000000000..dbea6b60e27f --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/Status.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.typescript.dto; + +/** + * @author Florent Benoit + */ +public enum Status { + + SHUTDOWN, + + ALIVE +} diff --git a/core/che-core-typescript-dto-maven-plugin/src/test/projects/project/pom.xml b/core/che-core-typescript-dto-maven-plugin/src/test/projects/project/pom.xml index 19b4abadf54a..1315d9fd4382 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/test/projects/project/pom.xml +++ b/core/che-core-typescript-dto-maven-plugin/src/test/projects/project/pom.xml @@ -16,7 +16,7 @@ 4.0.0 org.eclipse.che.test - my-typescript-test-moddule + my-typescript-test-module 1.0-SNAPSHOT pom Test of Eclipse Che TypeScript plugin From ca9ec4f64d80dba28402c9930029189d05f69eec Mon Sep 17 00:00:00 2001 From: Vitaliy Guliy Date: Wed, 5 Oct 2016 10:03:09 +0300 Subject: [PATCH 13/33] CHE-642 When browser is resized, the content of the IDE terminal is missing partly (#2697) Signed-off-by: Vitaliy Guliy --- .../panel/SubPanelViewImpl.java | 20 +++++++++++++++++-- .../panel/ProcessesPanelPresenter.java | 4 ---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/multisplitpanel/panel/SubPanelViewImpl.java b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/multisplitpanel/panel/SubPanelViewImpl.java index dddd04df60a9..b6919d86d7d6 100644 --- a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/multisplitpanel/panel/SubPanelViewImpl.java +++ b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/multisplitpanel/panel/SubPanelViewImpl.java @@ -19,6 +19,7 @@ import com.google.gwt.user.client.ui.DockLayoutPanel; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.IsWidget; +import com.google.gwt.user.client.ui.RequiresResize; import com.google.gwt.user.client.ui.SplitLayoutPanel; import com.google.gwt.user.client.ui.Widget; import com.google.inject.Inject; @@ -53,7 +54,8 @@ */ public class SubPanelViewImpl extends Composite implements SubPanelView, Menu.ActionDelegate, - Tab.ActionDelegate { + Tab.ActionDelegate, + RequiresResize { private final TabItemFactory tabItemFactory; private final Menu menu; @@ -133,6 +135,8 @@ public void splitHorizontally(SubPanelView subPanelView) { splitLayoutPanel.remove(mainPanel); splitLayoutPanel.addSouth(subPanelView, height); splitLayoutPanel.add(mainPanel); + + onResize(); } @Override @@ -144,6 +148,8 @@ public void splitVertically(SubPanelView subPanelView) { splitLayoutPanel.remove(mainPanel); splitLayoutPanel.addEast(subPanelView, width); splitLayoutPanel.add(mainPanel); + + onResize(); } @Override @@ -300,7 +306,7 @@ public void onMenuItemSelected(MenuItem menuItem) { public void onMenuItemClosing(MenuItem menuItem) { Object data = menuItem.getData(); if (data instanceof Tab) { - closeTab((Tab)data); + closeTab((Tab) data); } } @@ -326,6 +332,16 @@ public void onTabClosing(Tab tab) { closeTab(tab); } + @Override + public void onResize() { + for (WidgetToShow widgetToShow : widgets2Tabs.keySet()) { + if (widgetToShow.getWidget() instanceof RequiresResize) { + ((RequiresResize)widgetToShow.getWidget()).onResize(); + } + } + } + interface SubPanelViewImplUiBinder extends UiBinder { } + } diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java index a2357edc5514..37462c1ff652 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java @@ -895,10 +895,6 @@ public void onDownloadWorkspaceOutput(DownloadWorkspaceOutputEvent event) { download(fileName, getText(devMachine.getId())); } - private native void log(String msg) /*-{ - console.log(msg); - }-*/; - @Override public void onDownloadOutput(OutputConsole console) { String id = consoleCommands.get(console); From 67f78d7711795f54e5e13ef47f4925ef74fb9a4d Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Wed, 5 Oct 2016 09:58:58 +0200 Subject: [PATCH 14/33] Fix scope to be compliant as well with #2610 issue (#2696) -Dmaven.test.skip=true should work Fix #2610 Change-Id: I27294cb9d2f161d30174d2d7cceb0cf758f6be50 Signed-off-by: Florent BENOIT --- .../plugin-gdb/che-plugin-gdb-server/pom.xml | 9 ++++--- .../plugin-git/che-plugin-git-ext-git/pom.xml | 9 ++++--- .../che-plugin-github-ide/pom.xml | 9 ++++--- .../che-plugin-java-ext-lang-client/pom.xml | 9 ++++--- .../che-plugin-java-ext-lang-server/pom.xml | 18 +++++++------ .../che-plugin-java-plain-server/pom.xml | 27 ++++++++++--------- .../che-plugin-machine-ext-client/pom.xml | 9 ++++--- .../che-plugin-maven-server/pom.xml | 27 ++++++++++--------- .../plugin-svn/che-plugin-svn-ext-ide/pom.xml | 9 ++++--- wsmaster/che-core-api-factory/pom.xml | 18 +++++++------ wsmaster/che-core-api-ssh/pom.xml | 9 ++++--- wsmaster/wsmaster-local/pom.xml | 9 ++++--- 12 files changed, 90 insertions(+), 72 deletions(-) diff --git a/plugins/plugin-gdb/che-plugin-gdb-server/pom.xml b/plugins/plugin-gdb/che-plugin-gdb-server/pom.xml index 1bfa3ac3dd91..0417b12cc86b 100644 --- a/plugins/plugin-gdb/che-plugin-gdb-server/pom.xml +++ b/plugins/plugin-gdb/che-plugin-gdb-server/pom.xml @@ -22,10 +22,6 @@ jar Che Plugin :: GDB :: GDB Server - - com.google.guava - guava - com.google.inject guice @@ -58,6 +54,11 @@ org.slf4j slf4j-api + + com.google.guava + guava + test + org.mockito mockito-all diff --git a/plugins/plugin-git/che-plugin-git-ext-git/pom.xml b/plugins/plugin-git/che-plugin-git-ext-git/pom.xml index 875add1c6eae..0398bb1dd0df 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/pom.xml +++ b/plugins/plugin-git/che-plugin-git-ext-git/pom.xml @@ -65,10 +65,6 @@ org.eclipse.che.core che-core-api-project-shared - - org.eclipse.che.core - che-core-api-workspace-shared - org.eclipse.che.core che-core-commons-annotations @@ -117,6 +113,11 @@ guice provided + + org.eclipse.che.core + che-core-api-workspace-shared + provided + org.vectomatic lib-gwt-svg diff --git a/plugins/plugin-github/che-plugin-github-ide/pom.xml b/plugins/plugin-github/che-plugin-github-ide/pom.xml index 72f3d2ae2789..a5fc77ec5dbc 100644 --- a/plugins/plugin-github/che-plugin-github-ide/pom.xml +++ b/plugins/plugin-github/che-plugin-github-ide/pom.xml @@ -49,10 +49,6 @@ org.eclipse.che.core che-core-api-model - - org.eclipse.che.core - che-core-api-project-shared - org.eclipse.che.core che-core-api-ssh-shared @@ -110,6 +106,11 @@ junit test + + org.eclipse.che.core + che-core-api-project-shared + test + org.hamcrest hamcrest-core 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 bede1e5733cd..b7c7604abd4e 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 @@ -54,10 +54,6 @@ org.eclipse.che.core che-core-api-machine-shared - - org.eclipse.che.core - che-core-api-workspace-shared - org.eclipse.che.core che-core-commons-annotations @@ -107,6 +103,11 @@ gwt-user provided + + org.eclipse.che.core + che-core-api-workspace-shared + provided + ch.qos.logback logback-classic diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-server/pom.xml b/plugins/plugin-java/che-plugin-java-ext-lang-server/pom.xml index 2e8650e58ecc..400724c0f008 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-server/pom.xml +++ b/plugins/plugin-java/che-plugin-java-ext-lang-server/pom.xml @@ -140,14 +140,6 @@ org.eclipse.che.plugin org.eclipse.search - - org.eclipse.che.plugin - org.eclipse.ui.ide - - - org.eclipse.equinox - preferences - org.eclipse.search org.eclipse.search @@ -176,6 +168,16 @@ fest-assert test + + org.eclipse.che.plugin + org.eclipse.ui.ide + test + + + org.eclipse.equinox + preferences + test + org.hamcrest hamcrest-core diff --git a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/pom.xml b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/pom.xml index b9bb1006e3e2..fdb0e1cd34cc 100644 --- a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/pom.xml +++ b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/pom.xml @@ -41,26 +41,14 @@ org.eclipse.che.core che-core-api-core - - org.eclipse.che.core - che-core-api-model - org.eclipse.che.core che-core-api-project - - org.eclipse.che.core - che-core-api-workspace-shared - org.eclipse.che.core che-core-commons-inject - - org.eclipse.che.core - che-core-commons-lang - org.eclipse.che.lib org-eclipse-jdt-core-repack @@ -95,6 +83,11 @@ org.slf4j slf4j-api + + org.eclipse.che.core + che-core-api-model + provided + junit junit @@ -105,6 +98,16 @@ fest-assert test + + org.eclipse.che.core + che-core-api-workspace-shared + test + + + org.eclipse.che.core + che-core-commons-lang + test + org.hamcrest hamcrest-core diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/pom.xml b/plugins/plugin-machine/che-plugin-machine-ext-client/pom.xml index 7bf0de3e59ca..766dd50ccd1f 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/pom.xml +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/pom.xml @@ -53,10 +53,6 @@ org.eclipse.che.core che-core-api-core - - org.eclipse.che.core - che-core-api-dto - org.eclipse.che.core che-core-api-machine-shared @@ -133,6 +129,11 @@ junit test + + org.eclipse.che.core + che-core-api-dto + test + org.eclipse.che.core che-core-api-project-shared diff --git a/plugins/plugin-maven/che-plugin-maven-server/pom.xml b/plugins/plugin-maven/che-plugin-maven-server/pom.xml index 2d296abb8ecf..af5ede67a2e8 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/pom.xml +++ b/plugins/plugin-maven/che-plugin-maven-server/pom.xml @@ -66,10 +66,6 @@ org.eclipse.che.core che-core-api-dto - - org.eclipse.che.core - che-core-api-model - org.eclipse.che.core che-core-api-project @@ -78,10 +74,6 @@ org.eclipse.che.core che-core-api-project-shared - - org.eclipse.che.core - che-core-api-workspace-shared - org.eclipse.che.core che-core-commons-inject @@ -132,10 +124,6 @@ org.eclipse.che.plugin maven-server-api - - org.eclipse.che.plugin - org.eclipse.core.filebuffers - org.eclipse.che.plugin org.eclipse.core.resources @@ -165,6 +153,16 @@ javax.websocket-api provided + + org.eclipse.che.core + che-core-api-model + provided + + + org.eclipse.che.core + che-core-api-workspace-shared + provided + ch.qos.logback logback-classic @@ -185,6 +183,11 @@ che-core-commons-test test + + org.eclipse.che.plugin + org.eclipse.core.filebuffers + test + org.hamcrest hamcrest-core diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/pom.xml b/plugins/plugin-svn/che-plugin-svn-ext-ide/pom.xml index e421a30f126d..498533901e8f 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/pom.xml +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/pom.xml @@ -46,10 +46,6 @@ javax.validation validation-api - - org.eclipse.che.core - che-core-api-project-shared - org.eclipse.che.core che-core-commons-annotations @@ -112,6 +108,11 @@ junit test + + org.eclipse.che.core + che-core-api-project-shared + test + org.hamcrest hamcrest-core diff --git a/wsmaster/che-core-api-factory/pom.xml b/wsmaster/che-core-api-factory/pom.xml index 83655cd1d6e2..25049a95dae1 100644 --- a/wsmaster/che-core-api-factory/pom.xml +++ b/wsmaster/che-core-api-factory/pom.xml @@ -69,14 +69,6 @@ org.eclipse.che.core che-core-api-factory-shared - - org.eclipse.che.core - che-core-api-machine - - - org.eclipse.che.core - che-core-api-machine-shared - org.eclipse.che.core che-core-api-model @@ -125,6 +117,16 @@ che-core-api-jdbc provided + + org.eclipse.che.core + che-core-api-machine + provided + + + org.eclipse.che.core + che-core-api-machine-shared + provided + org.eclipse.persistence javax.persistence diff --git a/wsmaster/che-core-api-ssh/pom.xml b/wsmaster/che-core-api-ssh/pom.xml index 1af872b68853..ec3581a33602 100644 --- a/wsmaster/che-core-api-ssh/pom.xml +++ b/wsmaster/che-core-api-ssh/pom.xml @@ -90,10 +90,6 @@ org.eclipse.che.core che-core-commons-annotations - - org.eclipse.che.core - che-core-commons-lang - org.eclipse.che.core che-core-commons-test @@ -126,6 +122,11 @@ che-core-api-jdbc-vendor-h2 test + + org.eclipse.che.core + che-core-commons-lang + test + org.eclipse.persistence eclipselink diff --git a/wsmaster/wsmaster-local/pom.xml b/wsmaster/wsmaster-local/pom.xml index db1404743413..a73da3eb719d 100644 --- a/wsmaster/wsmaster-local/pom.xml +++ b/wsmaster/wsmaster-local/pom.xml @@ -120,10 +120,6 @@ org.eclipse.che.core che-core-api-workspace - - org.eclipse.che.core - che-core-api-workspace-shared - org.eclipse.che.core che-core-commons-annotations @@ -157,6 +153,11 @@ javax.servlet-api provided + + org.eclipse.che.core + che-core-api-workspace-shared + provided + ch.qos.logback logback-classic From 3615479be522e9f78cf42c7c64061f830927d1b0 Mon Sep 17 00:00:00 2001 From: Kaloyan Raev Date: Wed, 5 Oct 2016 11:03:46 +0300 Subject: [PATCH 15/33] Zend stack and project sample (#2700) ### What does this PR do? Adds a stack with [Zend Server](http://www.zend.com/en/products/zend_server), based on the [official docker image](https://hub.docker.com/r/_/php-zendserver/). Zend Server is a professional and certified PHP distribution. The docker image includes a free trial Developer license. Also adds a project sample of the [Astro Splash](https://github.com/kaloyan-raev/AstroSplash) application, which is a demo app based on the [Zend Expressive](https://zendframework.github.io/zend-expressive/) framework. After creating a workspace with these stack and template the user must: 1. Execute the `configure` command. 2. Execute the `restart zend server` command. 3. Click on the preview link generated by the `restart zend server` command. ### What issues does this PR fix or reference? - PHP support #2590 ### New behavior - New stack with Zend Server. - New project sample: Astro Splash demo app, based on Zend Expressive. --- .../src/main/resources/images/type-zend.svg | 70 +++++++++++++++ .../src/main/resources/stacks.json | 87 +++++++++++++++++++ .../src/main/resources/samples.json | 51 +++++++++++ 3 files changed, 208 insertions(+) create mode 100644 ide/che-core-ide-stacks/src/main/resources/images/type-zend.svg diff --git a/ide/che-core-ide-stacks/src/main/resources/images/type-zend.svg b/ide/che-core-ide-stacks/src/main/resources/images/type-zend.svg new file mode 100644 index 000000000000..3ce9e2bcbf68 --- /dev/null +++ b/ide/che-core-ide-stacks/src/main/resources/images/type-zend.svg @@ -0,0 +1,70 @@ + + + + Zend logo + + + + + + image/svg+xml + + Zend logo + + + + + + + diff --git a/ide/che-core-ide-stacks/src/main/resources/stacks.json b/ide/che-core-ide-stacks/src/main/resources/stacks.json index 6bb75dc668b3..9b38f56ed437 100644 --- a/ide/che-core-ide-stacks/src/main/resources/stacks.json +++ b/ide/che-core-ide-stacks/src/main/resources/stacks.json @@ -1928,5 +1928,92 @@ "name": "type-bitnami.svg", "mediaType": "image/svg+xml" } + }, + { + "id": "zend", + "creator": "ide", + "name": "Zend", + "description": "Zend stack with PHP 7, Zend Server 9 and Z-Ray.", + "scope": "advanced", + "tags": [ + "PHP", + "Zend", + "Z-Ray", + "Composer", + "Ubuntu", + "Git" + ], + "components": [ + { + "name": "PHP", + "version": "7.0.6" + }, + { + "name": "Zend Server", + "version": "9.0.0" + }, + { + "name": "Composer", + "version": "---" + } + ], + "source": { + "type": "image", + "origin": "kaloyanraev/che-zendserver" + }, + "workspaceConfig": { + "environments": { + "default": { + "machines": { + "dev-machine": { + "agents": [ + "org.eclipse.che.terminal", "org.eclipse.che.ws-agent", "org.eclipse.che.ssh", "org.eclipse.che.ls.php", "org.eclipse.che.ls.json" + ], + "servers": {}, + "attributes" : { + "memoryLimitBytes": "2147483648" + } + } + }, + "recipe": { + "location": "kaloyanraev/che-zendserver", + "type": "dockerimage" + } + } + }, + "name": "default", + "defaultEnv": "default", + "description": null, + "commands": [ + { + "name": "restart zend server", + "type": "custom", + "commandLine": "sudo sed -i 's#zray.zendserver_ui_url=.*#zray.zendserver_ui_url=http://${server.port.10081}/ZendServer#g' /usr/local/zend/etc/conf.d/zray.ini && sudo /usr/local/zend/bin/zendctl.sh restart", + "attributes": { + "previewUrl": "http://${server.port.80}" + } + }, + { + "name": "stop zend server", + "type": "custom", + "commandLine": "sudo /usr/local/zend/bin/zendctl.sh stop", + "attributes": { + "previewUrl": "" + } + }, + { + "name": "show admin password", + "type": "custom", + "commandLine": "echo \"Zend Server admin password is `sudo cat /root/zend-password`\"", + "attributes": { + "previewUrl": "http://${server.port.10081}" + } + } + ] + }, + "stackIcon": { + "name": "type-zend.svg", + "mediaType": "image/svg+xml" + } } ] diff --git a/ide/che-core-ide-templates/src/main/resources/samples.json b/ide/che-core-ide-templates/src/main/resources/samples.json index e7a0423123b6..d362d74a783f 100644 --- a/ide/che-core-ide-templates/src/main/resources/samples.json +++ b/ide/che-core-ide-templates/src/main/resources/samples.json @@ -1260,5 +1260,56 @@ "tags": [ "Play" ] + }, + { + "name": "astro-splash", + "displayName": "astro-splash", + "path": "/astro-splash", + "description": "An app that uses the Astronomy Picture of the Day API provided by NASA and the Zend Expressive framework.", + "projectType": "php", + "mixins": [], + "attributes": { + "language": [ + "php" + ] + }, + "modules": [], + "problems": [], + "source": { + "type": "git", + "location": "https://github.com/kaloyan-raev/AstroSplash.git", + "parameters": {} + }, + "commands": [ + { + "name": "configure", + "type": "custom", + "commandLine": "chmod 777 ${current.project.path}/data; echo -e \"\n DocumentRoot ${current.project.path}/public\n SetEnv APPLICATION_ENV 'development'\n \n DirectoryIndex index.php\n AllowOverride All\n Require all granted\n \n\" | sudo tee /etc/apache2/sites-available/000-default.conf; composer --working-dir=${current.project.path} install && cp /usr/local/zend/etc/php.ini /tmp/update-php.ini && grep -q 'extension=pcntl.so' /tmp/update-php.ini || echo -e \"\nextension=pcntl.so\" | sudo tee -a /tmp/update-php.ini && php -c /tmp/update-php.ini ${current.project.path}/bin/update.php && rm /tmp/update-php.ini", + "attributes": { + "previewUrl": "" + } + }, + { + "name": "update images", + "type": "custom", + "commandLine": "cp /usr/local/zend/etc/php.ini /tmp/update-php.ini && grep -q 'extension=pcntl.so' /tmp/update-php.ini || echo -e \"\nextension=pcntl.so\" | sudo tee -a /tmp/update-php.ini && php -c /tmp/update-php.ini ${current.project.path}/bin/update.php && rm /tmp/update-php.ini", + "attributes": { + "previewUrl": "" + } + }, + { + "name": "clean doctrine cache", + "type": "custom", + "commandLine": "sudo rm -rf ${current.project.path}/data/doctrine-cache", + "attributes": { + "previewUrl": "" + } + } + ], + "links": [], + "category": "Samples", + "tags": [ + "Zend" + ] } ] From 1123da1c7f7658bf7b77b1d458e79d49fc8b7b96 Mon Sep 17 00:00:00 2001 From: Kaloyan Raev Date: Wed, 5 Oct 2016 12:18:55 +0300 Subject: [PATCH 16/33] Exclude type-zend.svg from license header check (#2703) Signed-off-by: Kaloyan Raev --- ide/che-core-ide-stacks/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/ide/che-core-ide-stacks/pom.xml b/ide/che-core-ide-stacks/pom.xml index fb77b26e0b4c..df41537c9446 100644 --- a/ide/che-core-ide-stacks/pom.xml +++ b/ide/che-core-ide-stacks/pom.xml @@ -30,6 +30,7 @@ **/type-bitnami.svg + **/type-zend.svg From 11036470a03e3af875cc977f424cb0019ec76db5 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Wed, 5 Oct 2016 14:06:35 +0300 Subject: [PATCH 17/33] =?UTF-8?q?CODENVY-687:=20=D0=A1ache=20svn=20credent?= =?UTF-8?q?ials=20instead=20of=20storing=20them=20in=20credentials=20provi?= =?UTF-8?q?der=20(#2672)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/eclipse/che/api/core/ErrorCodes.java | 1 + .../che/ide/api/subversion/Credentials.java | 54 ++++++ .../SubversionCredentialsDialog.java | 26 +-- .../projectimport/wizard/ProjectImporter.java | 34 ++++ .../wizard/ProjectImporterTest.java | 1 + .../svn/ide/SubversionClientService.java | 76 +++++--- .../svn/ide/SubversionClientServiceImpl.java | 80 +++++--- .../plugin/svn/ide/SubversionExtension.java | 5 - ...versionExtensionLocalizationConstants.java | 31 +-- .../ide/action/ChangeCredentialsAction.java | 60 ------ .../che/plugin/svn/ide/add/AddPresenter.java | 4 +- .../AskCredentialsPresenter.java | 90 --------- .../askcredentials/AskCredentialsView.java | 40 ---- .../AskCredentialsViewImpl.java | 135 -------------- .../AskCredentialsViewImpl.ui.xml | 83 --------- .../svn/ide/cleanup/CleanupPresenter.java | 4 +- .../svn/ide/commit/CommitPresenter.java | 54 ++++-- .../ide/commit/diff/DiffViewerPresenter.java | 8 +- .../ide/common/SubversionActionPresenter.java | 119 +++++++++--- .../plugin/svn/ide/copy/CopyPresenter.java | 31 ++- .../SubversionCredentialsDialogImpl.java | 69 +++++++ .../SubversionCredentialsDialogView.java | 53 ++++++ .../SubversionCredentialsDialogViewImpl.java | 120 ++++++++++++ ...SubversionCredentialsDialogViewImpl.ui.xml | 36 ++++ .../plugin/svn/ide/diff/DiffPresenter.java | 16 +- .../svn/ide/export/ExportPresenter.java | 4 +- .../SubversionProjectImporterPresenter.java | 12 -- .../SubversionProjectImporterView.java | 12 -- .../SubversionProjectImporterViewImpl.java | 30 --- .../SubversionProjectImporterViewImpl.ui.xml | 14 -- .../svn/ide/inject/SubversionGinModule.java | 8 +- .../ide/lockunlock/LockUnlockPresenter.java | 20 +- .../plugin/svn/ide/log/ShowLogPresenter.java | 17 +- .../plugin/svn/ide/merge/MergePresenter.java | 148 ++++++++------- .../plugin/svn/ide/move/MovePresenter.java | 30 ++- .../ide/property/PropertyEditorPresenter.java | 4 +- .../svn/ide/remove/RemovePresenter.java | 4 +- .../svn/ide/resolve/ResolvePresenter.java | 4 +- .../svn/ide/revert/RevertPresenter.java | 4 +- .../svn/ide/status/StatusPresenter.java | 4 +- .../svn/ide/update/UpdatePresenter.java | 64 ++++--- .../ide/update/UpdateToRevisionPresenter.java | 4 +- ...nExtensionLocalizationConstants.properties | 8 + .../che/plugin/svn/server/SubversionApi.java | 176 ++++++++++-------- .../plugin/svn/server/SubversionModule.java | 6 - .../svn/server/SubversionProjectImporter.java | 54 +----- .../credentials/CredentialsProvider.java | 41 ---- .../CurrentUserPreferencesAccess.java | 19 -- .../CurrentUserPreferencesAccessImpl.java | 68 ------- .../PreferencesAccessException.java | 31 --- .../PreferencesCredentialsProvider.java | 163 ---------------- .../svn/server/rest/SubversionService.java | 20 -- .../plugin/svn/server/SubversionApiITest.java | 5 +- .../server/SubversionProjectImporterTest.java | 5 - .../plugin/svn/server/utils/TestUtils.java | 13 +- .../che-plugin-svn-ext-shared/pom.xml | 4 + .../plugin/svn/shared/CheckoutRequest.java | 20 ++ .../che/plugin/svn/shared/CopyRequest.java | 19 ++ .../che/plugin/svn/shared/InfoRequest.java | 19 ++ .../che/plugin/svn/shared/LockRequest.java | 19 ++ .../che/plugin/svn/shared/MoveRequest.java | 19 ++ .../svn/shared/SaveCredentialsRequest.java | 29 --- .../plugin/svn/shared/ShowDiffRequest.java | 19 ++ .../che/plugin/svn/shared/UpdateRequest.java | 19 ++ .../che/api/git/GitProjectImporter.java | 4 +- 65 files changed, 1135 insertions(+), 1258 deletions(-) create mode 100644 ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/subversion/Credentials.java rename plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsException.java => ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/subversion/SubversionCredentialsDialog.java (51%) delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/action/ChangeCredentialsAction.java delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsPresenter.java delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsView.java delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.java delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.ui.xml create mode 100644 plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogImpl.java create mode 100644 plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogView.java create mode 100644 plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.java create mode 100644 plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.ui.xml delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsProvider.java delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccess.java delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccessImpl.java delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesAccessException.java delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesCredentialsProvider.java delete mode 100644 plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/SaveCredentialsRequest.java diff --git a/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/ErrorCodes.java b/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/ErrorCodes.java index 9f3460432796..c8d5177595fc 100644 --- a/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/ErrorCodes.java +++ b/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/ErrorCodes.java @@ -23,6 +23,7 @@ private ErrorCodes() { public static final int NO_COMMITTER_NAME_OR_EMAIL_DEFINED = 15216; public static final int UNABLE_GET_PRIVATE_SSH_KEY = 32068; public static final int UNAUTHORIZED_GIT_OPERATION = 32080; + public static final int UNAUTHORIZED_SVN_OPERATION = 32090; public static final int MERGE_CONFLICT = 32062; public static final int FAILED_CHECKOUT = 32063; public static final int FAILED_CHECKOUT_WITH_START_POINT = 32064; diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/subversion/Credentials.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/subversion/Credentials.java new file mode 100644 index 000000000000..ee58997c6b24 --- /dev/null +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/subversion/Credentials.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.ide.api.subversion; + +/** + * Credentials object for subversion operations. + * + * @author Igor Vinokur + */ +public class Credentials { + private String username; + private String password; + + public Credentials(String username, String password) { + this.username = username; + this.password = password; + } + + /** + * Returns user name for authentication. + */ + public String getUsername() { + return username; + } + + /** + * Set user name for authentication. + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Returns password for authentication. + */ + public String getPassword() { + return password; + } + + /** + * Set password for authentication. + */ + public void setPassword(String password) { + this.password = password; + } +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsException.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/subversion/SubversionCredentialsDialog.java similarity index 51% rename from plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsException.java rename to ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/subversion/SubversionCredentialsDialog.java index 7e54c4d0411d..8cbe9bf4125a 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsException.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/subversion/SubversionCredentialsDialog.java @@ -8,18 +8,22 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; +//TODO This is used in wizard/ProjectImporter, find a solution to move it to plugin-svn. +package org.eclipse.che.ide.api.subversion; -public class CredentialsException extends Exception { +import org.eclipse.che.api.promises.client.Promise; - private static final long serialVersionUID = 1L; - - public CredentialsException(final Throwable e) { - super(e); - } - - public CredentialsException(final String message) { - super(message); - } +/** + * Dialog for retrieving credentials for SVN operations. + * + * @author Igor Vinokur + */ +public interface SubversionCredentialsDialog { + /** + * Returns credentials from dialog. + * + * @return {@link Credentials} that contains user name and password + */ + Promise askCredentials(); } diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporter.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporter.java index f9380dcec520..43262c61e8c4 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporter.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporter.java @@ -29,6 +29,8 @@ import org.eclipse.che.ide.api.oauth.OAuth2Authenticator; import org.eclipse.che.ide.api.oauth.OAuth2AuthenticatorRegistry; import org.eclipse.che.ide.api.oauth.OAuth2AuthenticatorUrlProvider; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.api.project.MutableProjectConfig; import org.eclipse.che.ide.api.project.wizard.ImportProjectNotificationSubscriberFactory; import org.eclipse.che.ide.api.project.wizard.ProjectNotificationSubscriber; @@ -45,6 +47,7 @@ import static com.google.common.base.Strings.isNullOrEmpty; import static org.eclipse.che.api.core.ErrorCodes.UNABLE_GET_PRIVATE_SSH_KEY; import static org.eclipse.che.api.core.ErrorCodes.UNAUTHORIZED_GIT_OPERATION; +import static org.eclipse.che.api.core.ErrorCodes.UNAUTHORIZED_SVN_OPERATION; import static org.eclipse.che.api.git.shared.ProviderInfo.AUTHENTICATE_URL; import static org.eclipse.che.api.git.shared.ProviderInfo.PROVIDER_NAME; import static org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest; @@ -60,6 +63,7 @@ public class ProjectImporter extends AbstractImporter { private final CoreLocalizationConstant localizationConstant; private final ProjectResolver projectResolver; private final String restContext; + private final SubversionCredentialsDialog credentialsDialog; private final OAuth2AuthenticatorRegistry oAuth2AuthenticatorRegistry; @@ -69,11 +73,13 @@ public ProjectImporter(CoreLocalizationConstant localizationConstant, AppContext appContext, ProjectResolver projectResolver, @RestContext String restContext, + SubversionCredentialsDialog credentialsDialog, OAuth2AuthenticatorRegistry oAuth2AuthenticatorRegistry) { super(appContext, subscriberFactory); this.localizationConstant = localizationConstant; this.projectResolver = projectResolver; this.restContext = restContext; + this.credentialsDialog = credentialsDialog; this.oAuth2AuthenticatorRegistry = oAuth2AuthenticatorRegistry; } @@ -136,6 +142,8 @@ public Promise apply(PromiseError exception) throws FunctionException { switch (getErrorCode(exception.getCause())) { case UNABLE_GET_PRIVATE_SSH_KEY: throw new IllegalStateException(localizationConstant.importProjectMessageUnableGetSshKey()); + case UNAUTHORIZED_SVN_OPERATION: + return recallImportWithCredentials(sourceStorage, path); case UNAUTHORIZED_GIT_OPERATION: final Map attributes = ExceptionUtils.getAttributes(exception.getCause()); final String providerName = attributes.get(PROVIDER_NAME); @@ -156,6 +164,32 @@ public Promise apply(PromiseError exception) throws FunctionException { }); } + private Promise recallImportWithCredentials(final SourceStorage sourceStorage, final Path path) { + return createFromAsyncRequest(new RequestCall() { + @Override + public void makeCall(final AsyncCallback callback) { + credentialsDialog.askCredentials().then(new Operation() { + @Override + public void apply(Credentials credentials) throws OperationException { + sourceStorage.getParameters().put("username", credentials.getUsername()); + sourceStorage.getParameters().put("password", credentials.getPassword()); + doImport(path, sourceStorage).then(new Operation() { + @Override + public void apply(Project project) throws OperationException { + callback.onSuccess(project); + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError error) throws OperationException { + callback.onFailure(error.getCause()); + } + }); + } + }); + } + }); + } + private Promise authUserAndRecallImport(final String providerName, final String authenticateUrl, final Path path, diff --git a/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporterTest.java b/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporterTest.java index f06506d9b11a..1e338ebcce0f 100644 --- a/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporterTest.java +++ b/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporterTest.java @@ -95,6 +95,7 @@ public void setUp() { appContext, resolver, null, + null, null); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientService.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientService.java index b267cd92b74b..80366fa6d61c 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientService.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientService.java @@ -11,6 +11,8 @@ package org.eclipse.che.plugin.svn.ide; import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.commons.annotation.Nullable; +import org.eclipse.che.ide.api.subversion.Credentials; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.plugin.svn.shared.CLIOutputResponse; import org.eclipse.che.plugin.svn.shared.CLIOutputResponseList; @@ -84,18 +86,24 @@ Promise add(Path project, * source item path * @param destination * destination path + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise copy(Path project, Path source, Path destination, String comment); + Promise copy(Path project, + Path source, + Path destination, + String comment, + @Nullable Credentials credentials); /** * Merge specified URL with target. * * @param project - * project path + * project path * @param target - * target directory + * target directory * @param sourceUrl - * source URL to merge + * source URL to merge */ Promise merge(Path project, Path target, Path sourceUrl); @@ -103,15 +111,16 @@ Promise add(Path project, * Retrieves the information about repository item. * * @param project - * relative path to the project in local workspace + * relative path to the project in local workspace * @param target - * target to operate + * target to operate * @param revision - * revision, use HEAD to specify latest revision - * @param children - * whether list children or not + * revision, use HEAD to specify latest revision + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise info(Path project, Path target, String revision, boolean children); + Promise info(Path project, Path target, String revision, boolean children, @Nullable Credentials credentials); + Promise info(Path project, String target, String revision, boolean children); /** @@ -161,12 +170,20 @@ Promise status(Path project, * whether or not to ignore externals (--ignore-externals) * @param accept * the accept argument (--accept) + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise update(Path project, Path[] paths, String revision, String depth, boolean ignoreExternals, String accept); + Promise update(Path project, + Path[] paths, + String revision, + String depth, + boolean ignoreExternals, + String accept, + @Nullable Credentials credentials); Promise showLog(Path project, Path[] paths, String revision); - Promise showDiff(Path project, Path[] paths, String revision); + Promise showDiff(Path project, Path[] paths, String revision, @Nullable Credentials credentials); /** * Locks the given paths. @@ -178,8 +195,10 @@ Promise status(Path project, * @param force * if false, will warn if another user already has a lock on a target, leave this target unchanged, and continue.
* if true, will steal the lock from the previous owner instead + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise lock(Path project, Path[] paths, boolean force); + Promise lock(Path project, Path[] paths, boolean force, @Nullable Credentials credentials); /** * Unocks the given paths. @@ -191,8 +210,10 @@ Promise status(Path project, * @param force * if false, will warn if another user already has a lock on a target, leave this target unchanged, and continue.
* if true, will unlock anyway + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise unlock(Path project, Path[] paths, boolean force); + Promise unlock(Path project, Path[] paths, boolean force, @Nullable Credentials credentials); /** * Commits the changes in the repository. @@ -224,8 +245,6 @@ Promise status(Path project, Promise resolve(Path project, Map resolutions, String depth); - Promise saveCredentials(String repositoryUrl, String username, String password); - /** * Move provided path. * @@ -233,10 +252,14 @@ Promise status(Path project, * the project path * @param source * source item path - * @param destination - * destination path + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise move(Path project, Path source, Path destination, String comment); + Promise move(Path project, + Path source, + Path destination, + String comment, + @Nullable Credentials credentials); /** * Set specified property to a path or a target. @@ -259,17 +282,22 @@ Promise status(Path project, /** * Get specified property for a path or a target. * - * @param project the project path - * @param propertyName the property name - * @param path path to which property get + * @param project + * the project path + * @param propertyName + * the property name + * @param path + * path to which property get */ Promise propertyGet(Path project, String propertyName, Path path); /** * Get properties set for a path or a target. * - * @param project the project path - * @param path path to which property get + * @param project + * the project path + * @param path + * path to which property get */ Promise propertyList(Path project, Path path); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java index 5a61ce24eef1..da4e960a186f 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java @@ -15,6 +15,7 @@ import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.subversion.Credentials; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.rest.AsyncRequestFactory; @@ -44,7 +45,6 @@ import org.eclipse.che.plugin.svn.shared.RemoveRequest; import org.eclipse.che.plugin.svn.shared.ResolveRequest; import org.eclipse.che.plugin.svn.shared.RevertRequest; -import org.eclipse.che.plugin.svn.shared.SaveCredentialsRequest; import org.eclipse.che.plugin.svn.shared.ShowDiffRequest; import org.eclipse.che.plugin.svn.shared.ShowLogRequest; import org.eclipse.che.plugin.svn.shared.StatusRequest; @@ -105,7 +105,7 @@ public Promise add(Path project, Path[] path, String depth, b .send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputResponse.class)); } - @Override + @Override public Promise revert(Path project, Path[] paths, String depth) { final RevertRequest request = dtoFactory.createDto(RevertRequest.class) .withProjectPath(project.toString()) @@ -117,12 +117,16 @@ public Promise revert(Path project, Path[] paths, String dept } @Override - public Promise copy(Path project, Path source, Path destination, String comment) { + public Promise copy(Path project, Path source, Path destination, String comment, Credentials credentials) { final CopyRequest request = dtoFactory.createDto(CopyRequest.class) .withProjectPath(project.toString()) .withSource(source.toString()) .withDestination(destination.toString()) .withComment(comment); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } return asyncRequestFactory.createPostRequest(getBaseUrl() + "/copy", request) .loader(loader) @@ -153,25 +157,21 @@ public Promise merge(Path project, Path target, Path sourceUr } @Override - public Promise info(Path project, Path target, String revision, boolean children) { - final InfoRequest request = dtoFactory.createDto(InfoRequest.class) - .withProjectPath(project.toString()) - .withTarget(target.toString()) - .withRevision(revision) - .withChildren(children); - - return asyncRequestFactory.createPostRequest(getBaseUrl() + "/info", request) - .loader(loader) - .send(dtoUnmarshallerFactory.newUnmarshaller(InfoResponse.class)); + public Promise info(Path project, String target, String revision, boolean children) { + return info(project, Path.valueOf(target), revision, children, dtoFactory.createDto(Credentials.class)); } @Override - public Promise info(Path project, String target, String revision, boolean children) { + public Promise info(Path project, Path target, String revision, boolean children, Credentials credentials) { final InfoRequest request = dtoFactory.createDto(InfoRequest.class) .withProjectPath(project.toString()) - .withTarget(target) + .withTarget(target.toString()) .withRevision(revision) .withChildren(children); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } return asyncRequestFactory.createPostRequest(getBaseUrl() + "/info", request) .loader(loader) @@ -198,8 +198,13 @@ public Promise status(Path project, Path[] paths, String dept } @Override - public Promise update(Path project, Path[] paths, String revision, String depth, boolean ignoreExternals, - String accept) { + public Promise update(Path project, + Path[] paths, + String revision, + String depth, + boolean ignoreExternals, + String accept, + Credentials credentials) { final UpdateRequest request = dtoFactory.createDto(UpdateRequest.class) .withProjectPath(project.toString()) @@ -208,6 +213,10 @@ public Promise update(Path project, Path[] paths, .withDepth(depth) .withIgnoreExternals(ignoreExternals) .withAccept(accept); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } return asyncRequestFactory.createPostRequest(getBaseUrl() + "/update", request) .loader(loader) @@ -227,36 +236,51 @@ public Promise showLog(Path project, Path[] paths, String rev } @Override - public Promise lock(Path project, Path[] paths, boolean force) { + public Promise lock(Path project, Path[] paths, boolean force, Credentials credentials) { final String url = getBaseUrl() + "/lock"; final LockRequest request = dtoFactory.createDto(LockRequest.class) .withProjectPath(project.toString()) .withTargets(toList(paths)) .withForce(force); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } + return asyncRequestFactory.createPostRequest(url, request) .loader(loader) .send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputResponse.class)); } @Override - public Promise unlock(Path project, Path[] paths, boolean force) { + public Promise unlock(Path project, Path[] paths, boolean force, Credentials credentials) { final String url = getBaseUrl() + "/unlock"; final LockRequest request = dtoFactory.createDto(LockRequest.class) .withProjectPath(project.toString()) .withTargets(toList(paths)) .withForce(force); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } + return asyncRequestFactory.createPostRequest(url, request) .loader(loader) .send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputResponse.class)); } @Override - public Promise showDiff(Path project, Path[] paths, String revision) { + public Promise showDiff(Path project, Path[] paths, String revision, Credentials credentials) { final String url = getBaseUrl() + "/showdiff"; final ShowDiffRequest request = dtoFactory.createDto(ShowDiffRequest.class) .withProjectPath(project.toString()) .withPaths(toList(paths)) .withRevision(revision); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } + return asyncRequestFactory.createPostRequest(url, request) .loader(loader) .send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputResponse.class)); @@ -320,23 +344,17 @@ public Promise resolve(Path project, Map } @Override - public Promise saveCredentials(String repositoryUrl, String username, String password) { - final String url = getBaseUrl() + "/saveCredentials"; - final SaveCredentialsRequest request = dtoFactory.createDto(SaveCredentialsRequest.class) - .withUsername(username) - .withPassword(password) - .withRepositoryUrl(repositoryUrl); - return asyncRequestFactory.createPostRequest(url, request).loader(loader).send(); - } - - @Override - public Promise move(Path project, Path source, Path destination, String comment) { + public Promise move(Path project, Path source, Path destination, String comment, Credentials credentials) { final MoveRequest request = dtoFactory.createDto(MoveRequest.class) .withProjectPath(project.toString()) .withSource(Collections.singletonList(source.toString())) .withDestination(destination.toString()) .withComment(comment); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } return asyncRequestFactory.createPostRequest(getBaseUrl() + "/move", request) .loader(loader) diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java index 5501dc93afb4..e3b1591fe2f3 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java @@ -20,7 +20,6 @@ import org.eclipse.che.ide.api.constraints.Constraints; import org.eclipse.che.ide.api.extension.Extension; import org.eclipse.che.plugin.svn.ide.action.AddAction; -import org.eclipse.che.plugin.svn.ide.action.ChangeCredentialsAction; import org.eclipse.che.plugin.svn.ide.action.CleanupAction; import org.eclipse.che.plugin.svn.ide.action.CommitAction; import org.eclipse.che.plugin.svn.ide.action.CopyAction; @@ -60,7 +59,6 @@ public class SubversionExtension { @Inject public SubversionExtension(final ActionManager actionManager, final AddAction addAction, - final ChangeCredentialsAction changeCredentialsAction, final CleanupAction cleanupAction, final CommitAction commitAction, final DiffAction diffAction, @@ -175,9 +173,6 @@ public SubversionExtension(final ActionManager actionManager, actionManager.registerAction("SvnCleanup", cleanupAction); addCommandGroup.add(cleanupAction); - actionManager.registerAction("SvnChangeCredentials", changeCredentialsAction); - credentialsCommandGroup.add(changeCredentialsAction); - //context menu DefaultActionGroup contextGroup = new DefaultActionGroup("Subversion", true, actionManager); contextGroup.getTemplatePresentation().setDescription("Subversion operation..."); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.java index 8a8159472b47..2b135385efa4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.java @@ -81,6 +81,9 @@ public interface SubversionExtensionLocalizationConstants extends Messages { @Key("action.not.implemented") String actionNotImplemented(); + @Key("waiting.credentials") + String waitingCredentials(); + @Key("add.description") String addDescription(); @@ -497,18 +500,6 @@ public interface SubversionExtensionLocalizationConstants extends Messages { @Key("error.unlock.directory.dialog.title") String dialogTitleUnlockDirectory(); - - // save credentials - - @Key("save.credentials.started") - String notificationSavingCredentials(String repositoryUrl); - - @Key("save.credentials.finished") - String notificationCredentialsSaved(String repositoryUrl); - - @Key("save.credentials.failed") - String notificationCredentialsFailed(String repositoryUrl); - /* Export dialog */ @Key("download.title") @@ -581,6 +572,22 @@ public interface SubversionExtensionLocalizationConstants extends Messages { @Key("move.item.child.detect") String moveItemChildDetected(); + /* Credentials dialog */ + @Key("credentials.dialog.title") + String credentialsDialogTitle(); + + @Key("credentials.dialog.username") + String credentialsDialogUsername(); + + @Key("credentials.dialog.password") + String credentialsDialogPassword(); + + @Key("credentials.dialog.authenticate.button") + String credentialsDialogAuthenticateButton(); + + @Key("credentials.dialog.cancel.button") + String credentialsDialogCancelButton(); + /** Property */ @Key("property.modify.start") String propertyModifyStart(); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/action/ChangeCredentialsAction.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/action/ChangeCredentialsAction.java deleted file mode 100644 index adf2f3d3f32e..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/action/ChangeCredentialsAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.ide.action; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.resources.Project; -import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; -import org.eclipse.che.plugin.svn.ide.SubversionExtensionResources; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsPresenter; - -import java.util.List; - -import static com.google.common.base.Preconditions.checkState; -import static org.eclipse.che.plugin.svn.shared.SubversionTypeConstant.SUBVERSION_ATTRIBUTE_REPOSITORY_URL; - -/** - * Extension of {@link SubversionAction} for changing username/password. - */ -@Singleton -public class ChangeCredentialsAction extends SubversionAction { - - private final AskCredentialsPresenter presenter; - - @Inject - public ChangeCredentialsAction(AppContext appContext, - SubversionExtensionLocalizationConstants constants, - SubversionExtensionResources resources, - AskCredentialsPresenter presenter) { - super(constants.changeCredentialsTitle(), constants.changeCredentialsDescription(), resources.add(), appContext, constants, - resources); - - this.presenter = presenter; - } - - @Override - public void actionPerformed(final ActionEvent e) { - final Project project = appContext.getRootProject(); - - checkState(project != null, "Null project occurred"); - checkState(project.getAttributes().containsKey(SUBVERSION_ATTRIBUTE_REPOSITORY_URL), "Project doesn't have svn url property"); - - final List values = project.getAttributes().get(SUBVERSION_ATTRIBUTE_REPOSITORY_URL); - - checkState(!values.isEmpty(), "Project doesn't have any bound svn url"); - - presenter.askCredentials(values.get(0)); - } -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/add/AddPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/add/AddPresenter.java index e38e34fd14ac..9140bc242357 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/add/AddPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/add/AddPresenter.java @@ -21,6 +21,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -51,10 +52,11 @@ protected AddPresenter(AppContext appContext, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, SubversionClientService service, ProcessesPanelPresenter processesPanelPresenter, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsPresenter.java deleted file mode 100644 index 4eaeec9be868..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsPresenter.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.ide.askcredentials; - -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.api.notification.NotificationManager; -import org.eclipse.che.ide.api.notification.StatusNotification; -import org.eclipse.che.plugin.svn.ide.SubversionClientService; -import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsView.AskCredentialsDelegate; - -import javax.inject.Inject; - -import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE; -import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL; -import static org.eclipse.che.ide.api.notification.StatusNotification.Status.PROGRESS; -import static org.eclipse.che.ide.api.notification.StatusNotification.Status.SUCCESS; - -public class AskCredentialsPresenter implements AskCredentialsDelegate { - - private final AskCredentialsView view; - private final NotificationManager notificationManager; - private final SubversionExtensionLocalizationConstants constants; - private final SubversionClientService clientService; - private String repositoryUrl; - - @Inject - public AskCredentialsPresenter(AskCredentialsView view, - NotificationManager notificationManager, - SubversionExtensionLocalizationConstants constants, - SubversionClientService clientService) { - this.notificationManager = notificationManager; - this.constants = constants; - this.view = view; - this.view.setDelegate(this); - this.clientService = clientService; - } - - @Override - public void onSaveClicked() { - saveCredentials(view.getUsername(), view.getPassword()); - view.clearUsername(); - view.clearPassword(); - view.close(); - } - - @Override - public void onCancelClicked() { - view.clearUsername(); - view.clearPassword(); - view.close(); - } - - public void askCredentials(String repositoryUrl) { - view.clearUsername(); - view.clearPassword(); - view.setRepositoryUrl(repositoryUrl); - this.repositoryUrl = repositoryUrl; - view.showDialog(); - } - - private void saveCredentials(String username, String password) { - final StatusNotification notification = - new StatusNotification(constants.notificationSavingCredentials(repositoryUrl), PROGRESS, FLOAT_MODE); - notificationManager.notify(notification); - clientService.saveCredentials(repositoryUrl, username, password).then(new Operation() { - @Override - public void apply(Void arg) throws OperationException { - notification.setTitle(constants.notificationCredentialsSaved(repositoryUrl)); - notification.setStatus(SUCCESS); - } - }).catchError(new Operation() { - @Override - public void apply(PromiseError arg) throws OperationException { - notification.setTitle(constants.notificationCredentialsFailed(repositoryUrl)); - notification.setStatus(FAIL); - } - }); - } -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsView.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsView.java deleted file mode 100644 index 24cefac529c8..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsView.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.ide.askcredentials; - -public interface AskCredentialsView { - - public interface AskCredentialsDelegate { - - void onSaveClicked(); - - void onCancelClicked(); - - } - - void setDelegate(AskCredentialsDelegate delegate); - - void showDialog(); - - void close(); - - void focusInUserNameField(); - - void setRepositoryUrl(String url); - - void clearUsername(); - - void clearPassword(); - - String getUsername(); - - String getPassword(); -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.java deleted file mode 100644 index b2d46976fd5e..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.ide.askcredentials; - -import javax.inject.Inject; - -import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; -import org.eclipse.che.plugin.svn.ide.SubversionExtensionResources; -import org.eclipse.che.ide.ui.window.Window; - -import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.uibinder.client.UiTemplate; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.PasswordTextBox; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; - -public class AskCredentialsViewImpl extends Window implements AskCredentialsView { - - private AskCredentialsDelegate delegate; - - @UiField(provided = true) - SubversionExtensionLocalizationConstants locale; - - @UiField(provided = true) - SubversionExtensionResources res; - - @UiField - Element repositoryUrl; - - @UiField - TextBox username; - - @UiField - PasswordTextBox password; - - private final Button btnCancel; - private final Button btnSave; - - @UiTemplate(value = "AskCredentialsViewImpl.ui.xml") - interface AskCredentialsViewImplUiBinder extends UiBinder {} - - @Inject - public AskCredentialsViewImpl(final AskCredentialsViewImplUiBinder uibinder, - final SubversionExtensionLocalizationConstants constants, - final SubversionExtensionResources resources, - final Window.Resources windowResources) { - super(true); - this.locale = constants; - this.res = resources; - final Widget widget = uibinder.createAndBindUi(this); - - this.setTitle(locale.askCredentialsTitle()); - this.setWidget(widget); - - btnCancel = createButton(locale.askCredentialsCancel(), "svn-askcred-cancel", new ClickHandler() { - @Override - public void onClick(final ClickEvent event) { - delegate.onCancelClicked(); - } - }); - btnSave = createButton(locale.askCredentialsValidate(), "svn-askcred-save", new ClickHandler() { - @Override - public void onClick(final ClickEvent event) { - delegate.onSaveClicked(); - } - }); - btnSave.addStyleName(windowResources.windowCss().button()); - - addButtonToFooter(btnSave); - addButtonToFooter(btnCancel); - } - - @Override - protected void onClose() { - } - - @Override - public void setDelegate(final AskCredentialsDelegate delegate) { - this.delegate = delegate; - } - - @Override - public void close() { - this.hide(); - } - - @Override - public void showDialog() { - this.show(); - } - - @Override - public void focusInUserNameField() { - this.username.setFocus(true); - } - - @Override - public void setRepositoryUrl(final String url) { - this.repositoryUrl.setInnerText(url); - } - - @Override - public void clearUsername() { - this.username.setValue(""); - } - - @Override - public void clearPassword() { - this.password.setValue(""); - } - - @Override - public String getUsername() { - return this.username.getValue(); - } - - @Override - public String getPassword() { - return this.password.getValue(); - } - -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.ui.xml b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.ui.xml deleted file mode 100644 index a589e17f6b35..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.ui.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - .spacing { - margin-bottom: 10px; - } - - .mainPanel { - min-width: 20px; - min-height: 120px; - } - - .emptyBorder { - margin: 6px; - } - - .space { - margin-right: 5px; - } - - .field { - display: -webkit-flex; - display: flex; - -webkit-flex-direction: column; - flex-direction: column; - -webkit-align-items: flex-start; - align-items: flex-start; - margin-bottom: 3px; - } - .spaceBelow { - margin-bottom: 3em; - } - - .box { - width: 15em; - margin-left: 3px; - } - - .label { - display: -webkit-flex; - display: flex; - -webkit-flex-direction: row; - flex-direction: row; - justify-content: flex-end; - -webkit-justify-content: flex-end; - width: 20em; - text-align: left; - } - - - - -

-
- -
-
- -
- - - diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/cleanup/CleanupPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/cleanup/CleanupPresenter.java index 5e903beb03bd..2949a16c1013 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/cleanup/CleanupPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/cleanup/CleanupPresenter.java @@ -20,6 +20,7 @@ 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.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -47,11 +48,12 @@ public class CleanupPresenter extends SubversionActionPresenter { protected CleanupPresenter(AppContext appContext, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog credentialsDialog, ProcessesPanelPresenter processesPanelPresenter, SubversionExtensionLocalizationConstants constants, SubversionClientService service, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/CommitPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/CommitPresenter.java index 53ed86f26fd4..ff937c5572ec 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/CommitPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/CommitPresenter.java @@ -15,12 +15,15 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; @@ -57,7 +60,8 @@ public class CommitPresenter extends SubversionActionPresenter implements Action private final SubversionClientService service; private final CommitView view; - private DiffViewerPresenter diffViewerPresenter; + private final SubversionCredentialsDialog subversionCredentialsDialog; + private final DiffViewerPresenter diffViewerPresenter; private final NotificationManager notificationManager; private final SubversionExtensionLocalizationConstants constants; @@ -75,12 +79,14 @@ public CommitPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, SubversionExtensionLocalizationConstants constants, SubversionClientService service, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, DiffViewerPresenter diffViewerPresenter, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.service = service; this.view = view; + this.subversionCredentialsDialog = subversionCredentialsDialog; this.diffViewerPresenter = diffViewerPresenter; this.view.setDelegate(this); this.notificationManager = notificationManager; @@ -98,24 +104,24 @@ private void loadAllChanges() { service.status(project.getLocation(), new Path[0], null, false, false, false, true, false, null) .then(new Operation() { - @Override - public void apply(CLIOutputResponse response) throws OperationException { - List statusItems = parseChangesList(response); - view.setChangesList(statusItems); - view.onShow(); - - cache.put(Changes.ALL, statusItems); - } - }) - .catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - Log.error(CommitPresenter.class, error.getMessage()); - } - }); + @Override + public void apply(CLIOutputResponse response) throws OperationException { + List statusItems = parseChangesList(response); + view.setChangesList(statusItems); + view.onShow(); + + cache.put(Changes.ALL, statusItems); + } + }) + .catchError(new Operation() { + @Override + public void apply(PromiseError error) throws OperationException { + Log.error(CommitPresenter.class, error.getMessage()); + } + }); } - private List parseChangesList(CLIOutputResponse response) { + private List parseChangesList(CLIOutputResponse response) { return CLIOutputParser.parseFilesStatus(response.getOutput()); } @@ -183,12 +189,20 @@ public void onCommitClicked() { /** {@inheritDoc} */ @Override - public void showDiff(String path) { + public void showDiff(final String path) { final Project project = appContext.getRootProject(); checkState(project != null); - service.showDiff(project.getLocation(), new Path[]{valueOf(path)}, "HEAD").then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.showDiff(project.getLocation(), + new Path[]{valueOf(path)}, + "HEAD", + credentials); + } + }, null).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { String content = Joiner.on('\n').join(response.getOutput()); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/diff/DiffViewerPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/diff/DiffViewerPresenter.java index c9975643bb0a..1e0db801c027 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/diff/DiffViewerPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/diff/DiffViewerPresenter.java @@ -14,7 +14,10 @@ import com.google.inject.Singleton; import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; +import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; import org.eclipse.che.plugin.svn.ide.common.StatusColors; import org.eclipse.che.plugin.svn.ide.common.SubversionActionPresenter; import org.eclipse.che.plugin.svn.ide.common.SubversionOutputConsoleFactory; @@ -32,10 +35,13 @@ public class DiffViewerPresenter extends SubversionActionPresenter implements Di @Inject protected DiffViewerPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog credentialsDialog, + SubversionExtensionLocalizationConstants constants, + NotificationManager notificationManager, ProcessesPanelPresenter processesPanelPresenter, DiffViewerView view, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.view = view; this.view.setDelegate(this); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionActionPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionActionPresenter.java index 94de995328b5..e52f7da77803 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionActionPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionActionPresenter.java @@ -10,35 +10,61 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.ide.common; +import org.eclipse.che.api.core.ErrorCodes; +import org.eclipse.che.api.promises.client.Function; +import org.eclipse.che.api.promises.client.FunctionException; +import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.api.promises.client.PromiseError; +import org.eclipse.che.api.promises.client.js.Promises; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Container; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; +import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; import org.eclipse.che.plugin.svn.ide.action.SubversionAction; import java.util.List; +import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE; +import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL; +import static org.eclipse.che.ide.api.notification.StatusNotification.Status.PROGRESS; +import static org.eclipse.che.ide.util.ExceptionUtils.getErrorCode; + /** * Presenter to be extended by all {@link SubversionAction} presenters. */ public class SubversionActionPresenter { - protected final AppContext appContext; - private final SubversionOutputConsoleFactory consoleFactory; - private final ProcessesPanelPresenter consolesPanelPresenter; - private final StatusColors statusColors; + protected final AppContext appContext; + private final SubversionOutputConsoleFactory consoleFactory; + private final ProcessesPanelPresenter consolesPanelPresenter; + private final StatusColors statusColors; + private final SubversionExtensionLocalizationConstants locale; + private final NotificationManager notificationManager; + private final SubversionCredentialsDialog credentialsDialog; protected SubversionActionPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, ProcessesPanelPresenter processesPanelPresenter, - StatusColors statusColors) { + StatusColors statusColors, + SubversionExtensionLocalizationConstants locale, + NotificationManager notificationManager, + SubversionCredentialsDialog credentialsDialog) { this.appContext = appContext; this.consoleFactory = consoleFactory; this.consolesPanelPresenter = processesPanelPresenter; this.statusColors = statusColors; + this.locale = locale; + this.notificationManager = notificationManager; + this.credentialsDialog = credentialsDialog; } protected Path[] toRelative(Container project, Resource[] paths) { @@ -68,8 +94,10 @@ protected Path toRelative(Container project, Resource path) { /** * Prints errors output in console. * - * @param errors the error output - * @param consoleTitle the title of the console to use + * @param errors + * the error output + * @param consoleTitle + * the title of the console to use */ protected void printErrors(final List errors, final String consoleTitle) { final SubversionOutputConsole console = consoleFactory.create(consoleTitle); @@ -82,10 +110,14 @@ protected void printErrors(final List errors, final String consoleTitle) /** * Colorizes and prints response outputs in console. * - * @param command the SVN command that was executed - * @param output the command output - * @param errors the error output - * @param consoleTitle the title of the console to use + * @param command + * the SVN command that was executed + * @param output + * the command output + * @param errors + * the error output + * @param consoleTitle + * the title of the console to use */ protected void printResponse(final String command, final List output, final List errors, final String consoleTitle) { final SubversionOutputConsole console = consoleFactory.create(consoleTitle); @@ -107,11 +139,54 @@ protected void printResponse(final String command, final List output, fi consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console); } + /** + * Performs subversion operation. If this operations fails with authorization error + * the operation will be recalled with requested credentials + * + * @param notification + * progress notification to set operation status + */ + protected Promise performOperationWithCredentialsRequestIfNeeded(final RemoteSubversionOperation operation, + @Nullable final StatusNotification notification) { + return operation.perform(null) + .catchErrorPromise(new Function>() { + @Override + public Promise apply(PromiseError error) throws FunctionException { + if (getErrorCode(error.getCause()) == ErrorCodes.UNAUTHORIZED_SVN_OPERATION) { + if (notification != null) { + notification.setTitle(locale.waitingCredentials()); + notification.setStatus(PROGRESS); + } else { + notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); + } + + return credentialsDialog.askCredentials() + .thenPromise(new Function>() { + @Override + public Promise apply(Credentials credentials) throws FunctionException { + return operation.perform(credentials); + } + }); + } + return Promises.reject(error); + } + }); + } + + /** + * Remote Subversion operation that can require credentials. + */ + protected interface RemoteSubversionOperation { + Promise perform(Credentials credentials); + } + /** * Prints an executed command line in given console. * - * @param command the SVN command that was executed - * @param console the console to use to print + * @param command + * the SVN command that was executed + * @param console + * the console to use to print */ private void printCommand(String command, final SubversionOutputConsole console) { if (command.startsWith("'") || command.startsWith("\"")) { @@ -125,8 +200,10 @@ private void printCommand(String command, final SubversionOutputConsole console) /** * Prints output in given console. * - * @param output the command output - * @param console the console to use to print + * @param output + * the command output + * @param console + * the console to use to print */ private void printOutput(List output, SubversionOutputConsole console) { for (final String line : output) { @@ -135,14 +212,14 @@ private void printOutput(List output, SubversionOutputConsole console) { String prefix = trimLine.substring(0, 1); final String color = statusColors.getStatusColor(prefix); - if (color != null) { - // TODO: Turn the file paths into links (where appropriate) - console.print(line, color); - } else { - console.print(line); - } + if (color != null) { + // TODO: Turn the file paths into links (where appropriate) + console.print(line, color); + } else { + console.print(line); } } + } console.print(""); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/copy/CopyPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/copy/CopyPresenter.java index 49080d2e7ff5..3079fb663613 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/copy/CopyPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/copy/CopyPresenter.java @@ -17,12 +17,15 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.RegExpUtils; @@ -47,25 +50,27 @@ @Singleton public class CopyPresenter extends SubversionActionPresenter implements CopyView.ActionDelegate { - private CopyView view; - private NotificationManager notificationManager; - private SubversionClientService service; - private SubversionExtensionLocalizationConstants constants; - private Resource sourceNode; + private final CopyView view; + private final NotificationManager notificationManager; + private final SubversionClientService service; + private final SubversionExtensionLocalizationConstants constants; private RegExp urlRegExp = RegExp.compile("^(https?|ftp)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"); + + private Resource sourceNode; private Resource target; @Inject protected CopyPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, CopyView view, NotificationManager notificationManager, SubversionClientService service, SubversionExtensionLocalizationConstants constants, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.view = view; this.notificationManager = notificationManager; this.service = service; @@ -112,12 +117,22 @@ public void onCopyClicked() { 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); + final StatusNotification notification = new StatusNotification(constants.copyNotificationStarted(src.toString()), + PROGRESS, + FLOAT_MODE); notificationManager.notify(notification); view.hide(); - service.copy(project.getLocation(), src, target, comment).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise 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() { @Override public void apply(CLIOutputResponse response) throws OperationException { printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandCopy()); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogImpl.java new file mode 100644 index 000000000000..f249aa35757b --- /dev/null +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogImpl.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.svn.ide.credentialsdialog; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.inject.Inject; + +import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.RequestCall; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; + +import static org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest; +import static org.eclipse.che.ide.util.StringUtils.isNullOrEmpty; + +/** + * Implementation of {@link SubversionCredentialsDialog}. + * + * @author Igor Vinokur + */ +public class SubversionCredentialsDialogImpl implements SubversionCredentialsDialog, SubversionCredentialsDialogViewImpl.ActionDelegate { + + private final SubversionCredentialsDialogView view; + + private AsyncCallback callback; + + @Inject + public SubversionCredentialsDialogImpl(SubversionCredentialsDialogView view) { + this.view = view; + this.view.setDelegate(this); + } + + @Override + public Promise askCredentials() { + view.cleanCredentials(); + view.showDialog(); + return createFromAsyncRequest(new RequestCall() { + @Override + public void makeCall(final AsyncCallback callback) { + SubversionCredentialsDialogImpl.this.callback = callback; + } + }); + } + + @Override + public void onCancelClicked() { + callback.onFailure(new Exception("Authorization request rejected by user.")); + view.closeDialog(); + } + + @Override + public void onAuthenticateClicked() { + callback.onSuccess(new Credentials(view.getUsername(), view.getPassword())); + view.closeDialog(); + } + + @Override + public void onCredentialsChanged() { + view.setEnabledAuthenticateButton(!isNullOrEmpty(view.getUsername()) && !isNullOrEmpty(view.getPassword())); + } +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogView.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogView.java new file mode 100644 index 000000000000..738337475e3f --- /dev/null +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogView.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.svn.ide.credentialsdialog; + +import com.google.inject.ImplementedBy; + +import org.eclipse.che.ide.api.mvp.View; + +/** + * The view of {@link SubversionCredentialsDialogImpl}. + * + * @author Igor Vinokur + */ +@ImplementedBy(SubversionCredentialsDialogViewImpl.class) +interface SubversionCredentialsDialogView extends View { + + interface ActionDelegate { + /** Performs any actions appropriate in response to the user clicks cancel button. */ + void onCancelClicked(); + + /** Performs any actions appropriate in response to the user clicks Authenticate button. */ + void onAuthenticateClicked(); + + /** Performs any actions appropriate in response to the user having changed the user name or password */ + void onCredentialsChanged(); + } + + /** @return username */ + String getUsername(); + + /** @return password */ + String getPassword(); + + /** Clean username and password fields. */ + void cleanCredentials(); + + /** Enable or disable Authenticate button. */ + void setEnabledAuthenticateButton(boolean enabled); + + /** Show dialog. */ + void showDialog(); + + /** Close dialog. */ + void closeDialog(); +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.java new file mode 100644 index 000000000000..70c0ee902256 --- /dev/null +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.svn.ide.credentialsdialog; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.KeyUpEvent; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.UiHandler; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.TextBox; +import com.google.gwt.user.client.ui.Widget; +import com.google.inject.Inject; + +import org.eclipse.che.ide.ui.window.Window; +import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; + +/** + * Implementation of {@link SubversionCredentialsDialogView} + * + * @author Igor Vinokur + */ +public class SubversionCredentialsDialogViewImpl extends Window implements SubversionCredentialsDialogView { + + @UiField(provided = true) + final SubversionExtensionLocalizationConstants locale; + + interface SubversionAuthenticatorImplUiBinder extends UiBinder { + } + + private static SubversionAuthenticatorImplUiBinder uiBinder = GWT.create(SubversionAuthenticatorImplUiBinder.class); + + private ActionDelegate delegate; + + @UiField + TextBox usernameTextBox; + @UiField + TextBox passwordTextBox; + + private final Button authenticateButton; + + @Inject + public SubversionCredentialsDialogViewImpl(SubversionExtensionLocalizationConstants locale) { + this.locale = locale; + this.setWidget(uiBinder.createAndBindUi(this)); + this.setTitle(locale.credentialsDialogTitle()); + + authenticateButton = createPrimaryButton(locale.credentialsDialogAuthenticateButton(), + "svn-authentication-username", + new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + delegate.onAuthenticateClicked(); + } + }); + Button cancelButton = createButton(locale.credentialsDialogCancelButton(), + "svn-authentication-password", + new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + delegate.onCancelClicked(); + } + }); + + addButtonToFooter(authenticateButton); + addButtonToFooter(cancelButton); + } + + @Override + public void showDialog() { + super.show(); + } + + @Override + public void closeDialog() { + super.hide(); + } + + @Override + public String getUsername() { + return usernameTextBox.getText(); + } + + @Override + public String getPassword() { + return passwordTextBox.getText(); + } + + @Override + public void cleanCredentials() { + usernameTextBox.setText(""); + passwordTextBox.setText(""); + setEnabledAuthenticateButton(false); + } + + @UiHandler({"usernameTextBox", "passwordTextBox"}) + void credentialChangeHandler(KeyUpEvent event) { + delegate.onCredentialsChanged(); + } + + @Override + public void setEnabledAuthenticateButton(boolean enabled) { + authenticateButton.setEnabled(enabled); + } + + @Override + public void setDelegate(ActionDelegate delegate) { + this.delegate = delegate; + } +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.ui.xml b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.ui.xml new file mode 100644 index 000000000000..aeb2df5a1490 --- /dev/null +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.ui.xml @@ -0,0 +1,36 @@ + + + + + + .emptyBorder { + margin: 6px; + } + + + + + + + + + + + + + + + + diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/diff/DiffPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/diff/DiffPresenter.java index ad125ca7a7c3..9f66dde7742b 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/diff/DiffPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/diff/DiffPresenter.java @@ -15,11 +15,14 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; 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.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -47,11 +50,12 @@ public class DiffPresenter extends SubversionActionPresenter { protected DiffPresenter(final AppContext appContext, final NotificationManager notificationManager, final SubversionOutputConsoleFactory consoleFactory, + final SubversionCredentialsDialog subversionCredentialsDialog, final ProcessesPanelPresenter processesPanelPresenter, final SubversionClientService service, final SubversionExtensionLocalizationConstants constants, final StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.service = service; this.notificationManager = notificationManager; @@ -67,10 +71,15 @@ public void showDiff() { checkState(!Arrays.isNullOrEmpty(resources)); - service.showDiff(project.getLocation(), toRelative(project, resources), "HEAD").then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.showDiff(project.getLocation(), toRelative(project, resources), "HEAD", credentials); + } + }, null).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { - printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandDiff()); + printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandDiff());; } }).catchError(new Operation() { @Override @@ -79,5 +88,4 @@ public void apply(PromiseError error) throws OperationException { } }); } - } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/export/ExportPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/export/ExportPresenter.java index 21cb0e99ee97..9d2637f70e2f 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/export/ExportPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/export/ExportPresenter.java @@ -22,6 +22,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; @@ -58,13 +59,14 @@ public class ExportPresenter extends SubversionActionPresenter implements Export @Inject public ExportPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog credentialsDialog, ProcessesPanelPresenter processesPanelPresenter, ExportView view, SubversionClientService service, NotificationManager notificationManager, SubversionExtensionLocalizationConstants constants, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.appContext = appContext; this.view = view; this.service = service; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterPresenter.java index 91c572e2a0aa..410a3f12ff92 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterPresenter.java @@ -17,11 +17,9 @@ import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.inject.Inject; -import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; import org.eclipse.che.ide.api.project.MutableProjectConfig; import org.eclipse.che.ide.api.wizard.AbstractWizardPage; import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; -import org.eclipse.che.plugin.svn.shared.ImportParameterKeys; import org.eclipse.che.ide.util.NameUtils; import static com.google.common.base.Strings.isNullOrEmpty; @@ -74,9 +72,6 @@ public void go(AcceptsOneWidget container) { view.setProjectDescription(dataObject.getDescription()); view.setProjectUrl(dataObject.getSource().getLocation()); - view.cleanCredentials(); - onCredentialsChanged(); - container.setWidget(view); view.setInputsEnableState(true); @@ -141,13 +136,6 @@ public void onProjectDescriptionChanged(final String projectDescription) { dataObject.setDescription(projectDescription); } - /** {@inheritDoc} */ - @Override - public void onCredentialsChanged() { - dataObject.getSource().getParameters().put(ImportParameterKeys.PARAMETER_USERNAME, view.getUserName()); - dataObject.getSource().getParameters().put(ImportParameterKeys.PARAMETER_PASSWORD, view.getPassword()); - } - private boolean isSubversionUrlCorrect(final String url) { return !isNullOrEmpty(url) && SUBVERSION_REPOSITORY_REGEX.test(url); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterView.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterView.java index b25a237987a8..ab6eaad3fe75 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterView.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterView.java @@ -32,8 +32,6 @@ public interface ActionDelegate { /** Performs any actions appropriate in response to the user having changed the relative path in the project. */ void onProjectRelativePathChanged(String relativePath); - - void onCredentialsChanged(); } /** Set error marker on project name field. */ @@ -68,16 +66,6 @@ public interface ActionDelegate { /** Return custom relative project path. */ String getProjectRelativePath(); - - /** Return user name. */ - String getUserName(); - - /** Return user password. */ - String getPassword(); - - /** Clean username and password fields */ - void cleanCredentials(); - /** * Set the enable state of the inputs. * diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.java index 010c8166f0fb..40b1809b9521 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.java @@ -50,10 +50,6 @@ interface SubversionProjectImporterViewImplUiBinder @UiField TextBox projectRelativePath; @UiField - TextBox username; - @UiField - TextBox password; - @UiField TextBox projectName; @UiField TextArea projectDescription; @@ -163,27 +159,6 @@ public void setInputsEnableState(boolean isEnabled) { } } - /** {@inheritDoc} */ - @Override - public String getUserName() { - return username.getText(); - } - - /** {@inheritDoc} */ - @Override - public String getPassword() { - return password.getText(); - } - - /** - * Clean username and password fields - */ - @Override - public void cleanCredentials() { - username.setText(""); - password.setText(""); - } - @UiHandler("projectUrl") void onProjectUrlChanged(KeyUpEvent event) { delegate.onProjectUrlChanged(projectUrl.getValue()); @@ -197,11 +172,6 @@ void onProjectRelativePathChanged(final KeyUpEvent event) { delegate.onProjectRelativePathChanged(projectRelativePath.getValue()); } - @UiHandler({"username", "password"}) - void credentialChangeHandler(final ValueChangeEvent event) { - delegate.onCredentialsChanged(); - } - @UiHandler("projectName") void onProjectNameChanged(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.ui.xml b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.ui.xml index 68b5e7e89a18..984dc1dd1c9e 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.ui.xml +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.ui.xml @@ -34,20 +34,6 @@ debugId="file-importProject-relativePath" text="{locale.importerDefaultRelativePath}"/> - - - - - - - - - - diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/inject/SubversionGinModule.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/inject/SubversionGinModule.java index 2f9c9dd3245f..86742a177cf4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/inject/SubversionGinModule.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/inject/SubversionGinModule.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.ide.inject; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; +import org.eclipse.che.plugin.svn.ide.credentialsdialog.SubversionCredentialsDialogImpl; import org.eclipse.che.plugin.svn.ide.commit.diff.DiffViewerView; import org.eclipse.che.plugin.svn.ide.commit.diff.DiffViewerViewImpl; import org.eclipse.che.plugin.svn.ide.common.SubversionOutputConsole; @@ -27,9 +29,6 @@ import org.eclipse.che.plugin.svn.ide.resolve.ResolveViewImpl; import org.eclipse.che.plugin.svn.ide.SubversionClientService; import org.eclipse.che.plugin.svn.ide.SubversionClientServiceImpl; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsPresenter; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsView; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsViewImpl; import org.eclipse.che.plugin.svn.ide.commit.CommitView; import org.eclipse.che.plugin.svn.ide.commit.CommitViewImpl; import org.eclipse.che.plugin.svn.ide.common.threechoices.ChoiceDialog; @@ -80,8 +79,7 @@ protected void configure() { bind(CommitView.class).to(CommitViewImpl.class).in(Singleton.class); bind(DiffViewerView.class).to(DiffViewerViewImpl.class).in(Singleton.class); - bind(AskCredentialsPresenter.class); - bind(AskCredentialsView.class).to(AskCredentialsViewImpl.class); + bind(SubversionCredentialsDialog.class).to(SubversionCredentialsDialogImpl.class); install(new GinFactoryModuleBuilder().implement(ChoiceDialog.class, ChoiceDialogPresenter.class) .build(ChoiceDialogFactory.class)); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/lockunlock/LockUnlockPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/lockunlock/LockUnlockPresenter.java index 656840fb739c..2d4364a4be81 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/lockunlock/LockUnlockPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/lockunlock/LockUnlockPresenter.java @@ -14,12 +14,15 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.dialogs.ConfirmCallback; 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.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; @@ -53,11 +56,12 @@ protected LockUnlockPresenter(AppContext appContext, ChoiceDialogFactory choiceDialogFactory, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, SubversionExtensionLocalizationConstants constants, SubversionClientService service, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.service = service; this.notificationManager = notificationManager; @@ -155,7 +159,12 @@ private void doLockAction(final boolean force, final Path[] paths) { checkState(project != null); - service.lock(project.getLocation(), paths, force).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.lock(project.getLocation(), paths, force, credentials); + } + }, null).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandLock()); @@ -174,7 +183,12 @@ private void doUnlockAction(final boolean force, final Path[] paths) { checkState(project != null); - service.unlock(project.getLocation(), paths, force).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.unlock(project.getLocation(), paths, force, credentials); + } + }, null).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandUnlock()); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/log/ShowLogPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/log/ShowLogPresenter.java index 1283008eceba..1e0137f45a3f 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/log/ShowLogPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/log/ShowLogPresenter.java @@ -14,11 +14,14 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; 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.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -51,14 +54,14 @@ public class ShowLogPresenter extends SubversionActionPresenter { @Inject protected ShowLogPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, SubversionClientService service, NotificationManager notificationManager, SubversionExtensionLocalizationConstants constants, ShowLogsView view, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); - + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.service = service; this.notificationManager = notificationManager; this.constants = constants; @@ -94,7 +97,12 @@ public void showLog() { checkState(!Arrays.isNullOrEmpty(resources)); checkState(resources.length == 1); - service.info(project.getLocation(), toRelative(project, resources[0]), "HEAD", false).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.info(project.getLocation(), toRelative(project, resources[0]), "HEAD", false, credentials); + } + }, null).then(new Operation() { @Override public void apply(InfoResponse response) throws OperationException { if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { @@ -119,7 +127,8 @@ public void apply(PromiseError error) throws OperationException { /** * Fetches and displays commit log messages for specified range. * - * @param range range to be logged + * @param range + * range to be logged */ private void showLogs(String range) { final Project project = appContext.getRootProject(); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/merge/MergePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/merge/MergePresenter.java index fe28281635ed..0e42c2c4177a 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/merge/MergePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/merge/MergePresenter.java @@ -26,6 +26,8 @@ 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.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -70,11 +72,12 @@ public MergePresenter(MergeView view, SubversionClientService service, AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, NotificationManager notificationManager, SubversionExtensionLocalizationConstants constants, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.view = view; this.service = service; @@ -99,7 +102,12 @@ public void merge() { checkState(resources != null && resources.length == 1); - service.info(project.getLocation(), toRelative(project, resources[0]), "HEAD", false).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.info(project.getLocation(), toRelative(project, resources[0]), "HEAD", false, credentials); + } + }, null).then(new Operation() { @Override public void apply(InfoResponse response) throws OperationException { if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { @@ -115,39 +123,39 @@ public void apply(InfoResponse response) throws OperationException { service.info(project.getLocation(), repositoryRoot, "HEAD", true) .then(new Operation() { - @Override - public void apply(InfoResponse response) throws OperationException { - if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { - printErrors(response.getErrorOutput(), constants.commandInfo()); - notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE); - return; - } - - sourceURL = response.getItems().get(0).getURL(); - SubversionItemNode subversionTreeNode = new SubversionItemNode(response.getItems().get(0)); - - List children = new ArrayList<>(); - if (response.getItems().size() > 1) { - for (int i = 1; i < response.getItems().size(); i++) { - SubversionItem item = response.getItems().get(i); - if (!"file".equals(item.getNodeKind())) { - children.add(new SubversionItemNode(item)); - } - } - } - - subversionTreeNode.setChildren(children); - view.setRootNode(subversionTreeNode); - view.show(); - validateSourceURL(); - } - }) + @Override + public void apply(InfoResponse response) throws OperationException { + if (!response.getErrorOutput().isEmpty()) { + printErrors(response.getErrorOutput(), constants.commandInfo()); + notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE); + return; + } + + sourceURL = response.getItems().get(0).getURL(); + SubversionItemNode subversionTreeNode = new SubversionItemNode(response.getItems().get(0)); + + List children = new ArrayList<>(); + if (response.getItems().size() > 1) { + for (int i = 1; i < response.getItems().size(); i++) { + SubversionItem item = response.getItems().get(i); + if (!"file".equals(item.getNodeKind())) { + children.add(new SubversionItemNode(item)); + } + } + } + + subversionTreeNode.setChildren(children); + view.setRootNode(subversionTreeNode); + view.show(); + validateSourceURL(); + } + }) .catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); - } - }); + @Override + public void apply(PromiseError error) throws OperationException { + notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); + } + }); } }).catchError(new Operation() { @Override @@ -174,17 +182,17 @@ public void mergeClicked() { service.merge(project.getLocation(), resources[0].getLocation(), Path.valueOf(sourceURL)) .then(new Operation() { - @Override - public void apply(CLIOutputResponse response) throws OperationException { - printResponse(response.getCommand(), response.getOutput(), null, constants.commandMerge()); - } - }) + @Override + public void apply(CLIOutputResponse response) throws OperationException { + printResponse(response.getCommand(), response.getOutput(), null, constants.commandMerge()); + } + }) .catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); - } - }); + @Override + public void apply(PromiseError error) throws OperationException { + notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); + } + }); } /** @@ -255,32 +263,32 @@ protected Promise> getChildrenImpl() { return service.info(project.getLocation(), getData().getURL(), "HEAD", true) .then(new Function>() { - @Override - public List apply(InfoResponse response) throws FunctionException { - if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { - printErrors(response.getErrorOutput(), constants.commandInfo()); - notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE); - return Collections.emptyList(); - } - - List children = new ArrayList<>(); - if (response.getItems().size() > 1) { - for (int i = 1; i < response.getItems().size(); i++) { - SubversionItem item = response.getItems().get(i); - if (!"file".equals(item.getNodeKind())) { - children.add(new SubversionItemNode(item)); - } - } - } - - return children; - } - }).catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); - } - }); + @Override + public List apply(InfoResponse response) throws FunctionException { + if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { + printErrors(response.getErrorOutput(), constants.commandInfo()); + notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE); + return Collections.emptyList(); + } + + List children = new ArrayList<>(); + if (response.getItems().size() > 1) { + for (int i = 1; i < response.getItems().size(); i++) { + SubversionItem item = response.getItems().get(i); + if (!"file".equals(item.getNodeKind())) { + children.add(new SubversionItemNode(item)); + } + } + } + + return children; + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError error) throws OperationException { + notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); + } + }); } @Override diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/move/MovePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/move/MovePresenter.java index 3bbfb56ceafe..c54b176135f4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/move/MovePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/move/MovePresenter.java @@ -16,12 +16,15 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; @@ -46,23 +49,25 @@ @Singleton public class MovePresenter extends SubversionActionPresenter implements MoveView.ActionDelegate { - private MoveView view; - private SubversionExtensionLocalizationConstants locale; - private NotificationManager notificationManager; - private SubversionClientService service; - private Project project; - private Resource source; + private final MoveView view; + private final SubversionExtensionLocalizationConstants locale; + private final NotificationManager notificationManager; + private final SubversionClientService service; + + private Project project; + private Resource source; @Inject public MovePresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, MoveView view, NotificationManager notificationManager, SubversionClientService service, SubversionExtensionLocalizationConstants locale, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, locale, notificationManager, subversionCredentialsDialog); this.notificationManager = notificationManager; this.service = service; @@ -98,14 +103,21 @@ public void onMoveClicked() { checkState(project != null); final Path source = getSource(); - final Path target = getTarget(); final String comment = view.isURLSelected() ? view.getComment() : null; final StatusNotification notification = new StatusNotification(locale.moveNotificationStarted(source.toString()), PROGRESS, FLOAT_MODE); notificationManager.notify(notification); - service.move(project.getLocation(), source, target, comment).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise 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() { @Override public void apply(CLIOutputResponse response) throws OperationException { notification.setTitle(locale.moveNotificationSuccessful()); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/property/PropertyEditorPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/property/PropertyEditorPresenter.java index edc7d22d51ab..eb7d9a6a89a7 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/property/PropertyEditorPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/property/PropertyEditorPresenter.java @@ -21,6 +21,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -60,10 +61,11 @@ protected PropertyEditorPresenter(AppContext appContext, ProcessesPanelPresenter processesPanelPresenter, PropertyEditorView view, SubversionClientService service, + SubversionCredentialsDialog credentialsDialog, NotificationManager notificationManager, SubversionExtensionLocalizationConstants constants, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.view = view; this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/remove/RemovePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/remove/RemovePresenter.java index e24216b744b9..b6e9e9ace348 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/remove/RemovePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/remove/RemovePresenter.java @@ -21,6 +21,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -51,10 +52,11 @@ protected RemovePresenter(AppContext appContext, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, SubversionClientService service, ProcessesPanelPresenter processesPanelPresenter, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/resolve/ResolvePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/resolve/ResolvePresenter.java index cdda0a04b48c..b03a1fd58735 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/resolve/ResolvePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/resolve/ResolvePresenter.java @@ -20,6 +20,7 @@ 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.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -54,12 +55,13 @@ protected ResolvePresenter(ProcessesPanelPresenter processesPanelPresenter, SubversionOutputConsoleFactory consoleFactory, AppContext appContext, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, NotificationManager notificationManager, DialogFactory dialogFactory, SubversionClientService service, ResolveView view, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/revert/RevertPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/revert/RevertPresenter.java index 672b0e0e4c48..ac613fe6c247 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/revert/RevertPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/revert/RevertPresenter.java @@ -24,6 +24,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -54,10 +55,11 @@ protected RevertPresenter(AppContext appContext, ProcessesPanelPresenter processesPanelPresenter, SubversionClientService service, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, NotificationManager notificationManager, DialogFactory dialogFactory, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.constants = constants; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/status/StatusPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/status/StatusPresenter.java index 5af9c9d27279..ff977ec18159 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/status/StatusPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/status/StatusPresenter.java @@ -20,6 +20,7 @@ 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.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -49,9 +50,10 @@ protected StatusPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, SubversionClientService service, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, ProcessesPanelPresenter processesPanelPresenter, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdatePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdatePresenter.java index b82864f514b1..9d66cb0b915a 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdatePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdatePresenter.java @@ -15,10 +15,13 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; @@ -50,11 +53,12 @@ public class UpdatePresenter extends SubversionActionPresenter { public UpdatePresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, SubversionClientService service, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, SubversionExtensionLocalizationConstants constants, NotificationManager notificationManager, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.constants = constants; this.notificationManager = notificationManager; @@ -79,28 +83,40 @@ protected void doUpdate(final String revision, final String depth, final boolean final StatusNotification notification = new StatusNotification(constants.updateToRevisionStarted(revision), PROGRESS, FLOAT_MODE); notificationManager.notify(notification); - service.update(project.getLocation(), toRelative(project, resources), revision, depth, ignoreExternals, "postpone") - .then(new Operation() { - @Override - public void apply(CLIOutputWithRevisionResponse response) throws OperationException { - printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), - constants.commandUpdate()); - - notification.setTitle(constants.updateSuccessful(Long.toString(response.getRevision()))); - notification.setStatus(SUCCESS); - - if (view != null) { - view.close(); - } - } - }) - .catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - notification.setTitle(constants.updateFailed()); - notification.setStatus(FAIL); - } - }); + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + + notification.setStatus(PROGRESS); + notification.setTitle(constants.updateToRevisionStarted(revision)); + + return service.update(project.getLocation(), + toRelative(project, resources), + revision, + depth, + ignoreExternals, + "postpone", + credentials); + } + }, notification).then(new Operation() { + @Override + public void apply(CLIOutputWithRevisionResponse response) throws OperationException { + printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), + constants.commandUpdate()); + + notification.setTitle(constants.updateSuccessful(Long.toString(response.getRevision()))); + notification.setStatus(SUCCESS); + + if (view != null) { + view.close(); + } + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError error) throws OperationException { + notification.setTitle(constants.updateFailed()); + notification.setStatus(FAIL); + } + }); } - } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdateToRevisionPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdateToRevisionPresenter.java index c60cd9bec67f..fd7a92371c11 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdateToRevisionPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdateToRevisionPresenter.java @@ -15,6 +15,7 @@ import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.plugin.svn.ide.SubversionClientService; import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; @@ -34,11 +35,12 @@ public UpdateToRevisionPresenter(AppContext appContext, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, SubversionClientService service, + SubversionCredentialsDialog credentialsDialog, SubversionExtensionLocalizationConstants constants, ProcessesPanelPresenter processesPanelPresenter, UpdateToRevisionView view, StatusColors statusColors) { - super(appContext, consoleFactory, service, processesPanelPresenter, constants, notificationManager, statusColors); + super(appContext, consoleFactory, service, credentialsDialog, processesPanelPresenter, constants, notificationManager, statusColors); this.view = view; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/resources/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.properties b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/resources/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.properties index 8e87c013db71..9ab19cfb6837 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/resources/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.properties +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/resources/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.properties @@ -33,6 +33,7 @@ command.update=svn update # Action Constants action.not.implemented=Action not implemented! +waiting.credentials=Waiting for credentials add.description=Add path to version control add.failed=Adding path(s) failed add.started=Adding {0} path(s) @@ -213,6 +214,13 @@ move.item.child.detect=Target directory cannot be a child of moved directory # Log gialog button.log=Log +# Authentication dialog +credentials.dialog.title=SVN Authentication +credentials.dialog.username=User Name: +credentials.dialog.password=Password: +credentials.dialog.authenticate.button=Authenticate +credentials.dialog.cancel.button=Cancel + # Properties property.modify.start=Property modification started property.modify.finished=Property modified diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionApi.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionApi.java index ff87f21acf2a..59f1d7b64474 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionApi.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionApi.java @@ -16,16 +16,15 @@ import com.google.common.net.MediaType; import com.google.inject.Singleton; +import org.eclipse.che.api.core.ErrorCodes; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.core.UnauthorizedException; import org.eclipse.che.api.core.util.LineConsumerFactory; import org.eclipse.che.api.vfs.util.DeleteOnCloseFileInputStream; import org.eclipse.che.commons.lang.IoUtil; import org.eclipse.che.commons.lang.ZipUtils; import org.eclipse.che.dto.server.DtoFactory; import org.eclipse.che.plugin.ssh.key.script.SshScriptProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider.Credentials; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.upstream.CommandLineResult; import org.eclipse.che.plugin.svn.server.upstream.UpstreamUtils; @@ -90,16 +89,13 @@ public class SubversionApi { private static Logger LOG = LoggerFactory.getLogger(SubversionApi.class); - private final CredentialsProvider credentialsProvider; private final RepositoryUrlProvider repositoryUrlProvider; private final SshScriptProvider sshScriptProvider; protected LineConsumerFactory svnOutputPublisherFactory; @Inject - public SubversionApi(CredentialsProvider credentialsProvider, - RepositoryUrlProvider repositoryUrlProvider, + public SubversionApi(RepositoryUrlProvider repositoryUrlProvider, SshScriptProvider sshScriptProvider) { - this.credentialsProvider = credentialsProvider; this.repositoryUrlProvider = repositoryUrlProvider; this.sshScriptProvider = sshScriptProvider; } @@ -125,7 +121,7 @@ public void setOutputLineConsumerFactory(LineConsumerFactory svnOutputPublisherF * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse add(final AddRequest request) throws IOException, SubversionException { + public CLIOutputResponse add(final AddRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List args = defaultArgs(); @@ -171,7 +167,7 @@ public CLIOutputResponse add(final AddRequest request) throws IOException, Subve * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse revert(RevertRequest request) throws IOException, SubversionException { + public CLIOutputResponse revert(RevertRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -200,7 +196,7 @@ public CLIOutputResponse revert(RevertRequest request) throws IOException, Subve * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse copy(final CopyRequest request) throws IOException, SubversionException { + public CLIOutputResponse copy(final CopyRequest request) throws IOException, SubversionException, UnauthorizedException { //for security reason we should forbid file protocol if (request.getSource().startsWith("file://") || request.getDestination().startsWith("file://")) { @@ -218,8 +214,12 @@ public CLIOutputResponse copy(final CopyRequest request) throws IOException, Sub // Command Name cliArgs.add("copy"); - final CommandLineResult result = - runCommand(null, cliArgs, projectPath, Arrays.asList(request.getSource(), request.getDestination())); + final CommandLineResult result = runCommand(null, + cliArgs, + projectPath, + Arrays.asList(request.getSource(), request.getDestination()), + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance() .createDto(CLIOutputResponse.class) @@ -240,12 +240,7 @@ public CLIOutputResponse copy(final CopyRequest request) throws IOException, Sub * if there is a Subversion issue */ public CLIOutputWithRevisionResponse checkout(final CheckoutRequest request) - throws IOException, SubversionException { - return checkout(request, null); - } - - public CLIOutputWithRevisionResponse checkout(final CheckoutRequest request, final String[] credentials) - throws IOException, SubversionException { + throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -263,7 +258,13 @@ public CLIOutputWithRevisionResponse checkout(final CheckoutRequest request, fin cliArgs.add(request.getUrl()); cliArgs.add(projectPath.getAbsolutePath()); - CommandLineResult result = runCommand(null, cliArgs, projectPath, request.getPaths(), credentials, request.getUrl()); + CommandLineResult result = runCommand(null, + cliArgs, + projectPath, + request.getPaths(), + request.getUsername(), + request.getPassword(), + request.getUrl()); return DtoFactory.getInstance().createDto(CLIOutputWithRevisionResponse.class) .withCommand(result.getCommandLine().toString()) @@ -284,7 +285,7 @@ public CLIOutputWithRevisionResponse checkout(final CheckoutRequest request, fin * if there is a Subversion issue */ public CLIOutputWithRevisionResponse commit(final CommitRequest request) - throws IOException, SubversionException { + throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -322,7 +323,7 @@ public CLIOutputWithRevisionResponse commit(final CommitRequest request) * if there is a Subversion issue */ public CLIOutputResponse remove(final RemoveRequest request) - throws IOException, SubversionException { + throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -349,7 +350,7 @@ public CLIOutputResponse remove(final RemoveRequest request) * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse status(final StatusRequest request) throws IOException, SubversionException { + public CLIOutputResponse status(final StatusRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -389,7 +390,7 @@ public CLIOutputResponse status(final StatusRequest request) throws IOException, * if there is a Subversion issue */ public CLIOutputWithRevisionResponse update(final UpdateRequest request) - throws IOException, SubversionException { + throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -404,8 +405,12 @@ public CLIOutputWithRevisionResponse update(final UpdateRequest request) // Command Name uArgs.add("update"); - final CommandLineResult result = runCommand(null, uArgs, projectPath, - addWorkingCopyPathIfNecessary(request.getPaths())); + final CommandLineResult result = runCommand(null, + uArgs, + projectPath, + addWorkingCopyPathIfNecessary(request.getPaths()), + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance().createDto(CLIOutputWithRevisionResponse.class) .withCommand(result.getCommandLine().toString()) @@ -425,7 +430,7 @@ public CLIOutputWithRevisionResponse update(final UpdateRequest request) * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse showLog(final ShowLogRequest request) throws IOException, SubversionException { + public CLIOutputResponse showLog(final ShowLogRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -441,7 +446,9 @@ public CLIOutputResponse showLog(final ShowLogRequest request) throws IOExceptio .withErrOutput(result.getStderr()); } - public CLIOutputResponse lockUnlock(final LockRequest request, final boolean lock) throws IOException, SubversionException { + public CLIOutputResponse lockUnlock(final LockRequest request, final boolean lock) throws IOException, + SubversionException, + UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List args = defaultArgs(); @@ -455,7 +462,12 @@ public CLIOutputResponse lockUnlock(final LockRequest request, final boolean loc args.add("unlock"); } - final CommandLineResult result = runCommand(null, args, projectPath, request.getTargets()); + final CommandLineResult result = runCommand(null, + args, + projectPath, + request.getTargets(), + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance() .createDto(CLIOutputResponse.class) @@ -475,7 +487,7 @@ public CLIOutputResponse lockUnlock(final LockRequest request, final boolean loc * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse showDiff(final ShowDiffRequest request) throws IOException, SubversionException { + public CLIOutputResponse showDiff(final ShowDiffRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -483,7 +495,12 @@ public CLIOutputResponse showDiff(final ShowDiffRequest request) throws IOExcept addOption(uArgs, "--revision", request.getRevision()); uArgs.add("diff"); - final CommandLineResult result = runCommand(null, uArgs, projectPath, request.getPaths()); + final CommandLineResult result = runCommand(null, + uArgs, + projectPath, + request.getPaths(), + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance().createDto(CLIOutputResponse.class) .withCommand(result.getCommandLine().toString()) @@ -496,7 +513,7 @@ public CLIOutputResponse showDiff(final ShowDiffRequest request) throws IOExcept * * @return the response containing target children */ - public ListResponse list(final ListRequest request) throws IOException, SubversionException { + public ListResponse list(final ListRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List args = defaultArgs(); @@ -524,7 +541,7 @@ public ListResponse list(final ListRequest request) throws IOException, Subversi * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponseList resolve(final ResolveRequest request) throws IOException, SubversionException { + public CLIOutputResponseList resolve(final ResolveRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); Map resolutions = request.getConflictResolutions(); @@ -566,7 +583,7 @@ public CLIOutputResponseList resolve(final ResolveRequest request) throws IOExce * if there is an exporting issue */ public Response exportPath(@NotNull final String projectPath, @NotNull final String path, String revision) - throws IOException, ServerException { + throws IOException, ServerException, UnauthorizedException { final File project = new File(projectPath); @@ -618,7 +635,7 @@ public Response exportPath(@NotNull final String projectPath, @NotNull final Str * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse move(final MoveRequest request) throws IOException, SubversionException { + public CLIOutputResponse move(final MoveRequest request) throws IOException, SubversionException, UnauthorizedException { Predicate sourcePredicate = new Predicate() { @Override @@ -647,7 +664,12 @@ public boolean apply(String input) { paths.addAll(request.getSource()); paths.add(request.getDestination()); - final CommandLineResult result = runCommand(null, cliArgs, projectPath, paths); + final CommandLineResult result = runCommand(null, + cliArgs, + projectPath, + paths, + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance().createDto(CLIOutputResponse.class) .withCommand(result.getCommandLine().toString()) @@ -666,7 +688,7 @@ public boolean apply(String input) { * @throws ServerException * if there is a Subversion issue */ - public CLIOutputResponse propset(final PropertySetRequest request) throws IOException, ServerException { + public CLIOutputResponse propset(final PropertySetRequest request) throws IOException, ServerException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -714,7 +736,7 @@ public CLIOutputResponse propset(final PropertySetRequest request) throws IOExce * @throws ServerException * if there is a Subversion issue */ - public CLIOutputResponse propdel(final PropertyDeleteRequest request) throws IOException, ServerException { + public CLIOutputResponse propdel(final PropertyDeleteRequest request) throws IOException, ServerException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -743,7 +765,7 @@ public CLIOutputResponse propdel(final PropertyDeleteRequest request) throws IOE * @throws ServerException * if there is a Subversion issue */ - public CLIOutputResponse propget(final PropertyGetRequest request) throws IOException, ServerException { + public CLIOutputResponse propget(final PropertyGetRequest request) throws IOException, ServerException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -770,7 +792,7 @@ public CLIOutputResponse propget(final PropertyGetRequest request) throws IOExce * @throws ServerException * if there is a Subversion issue */ - public CLIOutputResponse proplist(final PropertyListRequest request) throws IOException, ServerException { + public CLIOutputResponse proplist(final PropertyListRequest request) throws IOException, ServerException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -830,9 +852,8 @@ private void addOptionList(final List args, final String optName, final * @return list of arguments */ private List defaultArgs() { - List args = new ArrayList(); + List args = new ArrayList<>(); - args.add("--no-auth-cache"); args.add("--non-interactive"); args.add("--trust-server-cert"); @@ -855,18 +876,28 @@ private List addWorkingCopyPathIfNecessary(List paths) { private CommandLineResult runCommand(Map env, List args, File projectPath, - List paths) throws IOException, SubversionException { - String[] credentials = getCredentialArgs(projectPath.getAbsolutePath()); + List paths) throws IOException, SubversionException, UnauthorizedException { + String repoUrl = getRepositoryUrl(projectPath.getAbsolutePath()); + return runCommand(env, args, projectPath, paths, null, null, repoUrl); + } + + private CommandLineResult runCommand(Map env, + List args, + File projectPath, + List paths, + String username, + String password) throws IOException, SubversionException, UnauthorizedException { String repoUrl = getRepositoryUrl(projectPath.getAbsolutePath()); - return runCommand(env, args, projectPath, paths, credentials, repoUrl); + return runCommand(env, args, projectPath, paths, username, password, repoUrl); } private CommandLineResult runCommand(Map env, List args, File projectPath, List paths, - String[] credentials, - String repoUrl) throws IOException, SubversionException { + String username, + String password, + String repoUrl) throws IOException, SubversionException, UnauthorizedException { final List lines = new ArrayList<>(); final CommandLineResult result; final StringBuffer buffer; @@ -878,8 +909,8 @@ private CommandLineResult runCommand(Map env, } String[] credentialsArgs; - if (credentials != null && credentials.length == 2) { - credentialsArgs = new String[]{"--username", credentials[0], "--password", credentials[1]}; + if (!isNullOrEmpty(username) && !isNullOrEmpty(password)) { + credentialsArgs = new String[]{"--username", username, "--password", password}; } else { credentialsArgs = null; } @@ -924,27 +955,18 @@ private CommandLineResult runCommand(Map env, } if (!isWarning) { - throw new SubversionException(buffer.toString()); + String errorMessage = buffer.toString(); + if (errorMessage.endsWith("Authentication failed\n")) { + throw new UnauthorizedException("Authentication failed", ErrorCodes.UNAUTHORIZED_SVN_OPERATION); + } else { + throw new SubversionException(errorMessage); + } } } return result; } - private String[] getCredentialArgs(final String projectPath) throws SubversionException, IOException { - Credentials credentials; - try { - credentials = this.credentialsProvider.getCredentials(getRepositoryUrl(projectPath)); - } catch (final CredentialsException e) { - credentials = null; - } - if (credentials != null) { - return new String[]{credentials.getUsername(), credentials.getPassword()}; - } else { - return null; - } - } - public String getRepositoryUrl(final String projectPath) throws SubversionException, IOException { return this.repositoryUrlProvider.getRepositoryUrl(projectPath); } @@ -958,7 +980,7 @@ public String getRepositoryUrl(final String projectPath) throws SubversionExcept * @throws SubversionException * @throws IOException */ - public InfoResponse info(final InfoRequest request) throws SubversionException, IOException { + public InfoResponse info(final InfoRequest request) throws SubversionException, IOException, UnauthorizedException { final List args = defaultArgs(); if (request.getRevision() != null && !request.getRevision().trim().isEmpty()) { @@ -971,10 +993,14 @@ public InfoResponse info(final InfoRequest request) throws SubversionException, args.add("info"); - List paths = new ArrayList(); + List paths = new ArrayList<>(); paths.add(request.getTarget()); - final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), - addWorkingCopyPathIfNecessary(paths)); + final CommandLineResult result = runCommand(null, + args, + new File(request.getProjectPath()), + addWorkingCopyPathIfNecessary(paths), + request.getUsername(), + request.getPassword()); final InfoResponse response = DtoFactory.getInstance().createDto(InfoResponse.class) .withCommand(result.getCommandLine().toString()) @@ -982,11 +1008,11 @@ public InfoResponse info(final InfoRequest request) throws SubversionException, .withErrorOutput(result.getStderr()); if (result.getExitCode() == 0) { - List items = new ArrayList(); + List items = new ArrayList<>(); response.withItems(items); Iterator iterator = result.getStdout().iterator(); - List itemProperties = new ArrayList(); + List itemProperties = new ArrayList<>(); while (iterator.hasNext()) { String propertyLine = iterator.next(); @@ -1031,7 +1057,7 @@ public InfoResponse info(final InfoRequest request) throws SubversionException, * @throws IOException * @throws SubversionException */ - public CLIOutputResponse merge(final MergeRequest request) throws IOException, SubversionException { + public CLIOutputResponse merge(final MergeRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -1052,7 +1078,7 @@ public CLIOutputResponse merge(final MergeRequest request) throws IOException, S .withErrOutput(result.getStderr()); } - public CLIOutputResponse cleanup(final CleanupRequest request) throws SubversionException, IOException { + public CLIOutputResponse cleanup(final CleanupRequest request) throws SubversionException, IOException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -1067,7 +1093,7 @@ public CLIOutputResponse cleanup(final CleanupRequest request) throws Subversion .withOutput(result.getStdout()); } - public GetRevisionsResponse getRevisions(GetRevisionsRequest request) throws IOException, SubversionException { + public GetRevisionsResponse getRevisions(GetRevisionsRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -1078,9 +1104,9 @@ public GetRevisionsResponse getRevisions(GetRevisionsRequest request) throws IOE final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(request.getPath())); final GetRevisionsResponse response = DtoFactory.getInstance().createDto(GetRevisionsResponse.class) - .withCommand(result.getCommandLine().toString()) - .withOutput(result.getStdout()) - .withErrOutput(result.getStderr()); + .withCommand(result.getCommandLine().toString()) + .withOutput(result.getStdout()) + .withErrOutput(result.getStderr()); if (result.getExitCode() == 0) { List revisions = result.getStdout().parallelStream() diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionModule.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionModule.java index 016b5d9e1bf1..0bca6f4a9aae 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionModule.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionModule.java @@ -17,10 +17,6 @@ import org.eclipse.che.api.project.server.type.ProjectTypeDef; import org.eclipse.che.api.project.server.type.ValueProviderFactory; import org.eclipse.che.inject.DynaModule; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; -import org.eclipse.che.plugin.svn.server.credentials.CurrentUserPreferencesAccess; -import org.eclipse.che.plugin.svn.server.credentials.CurrentUserPreferencesAccessImpl; -import org.eclipse.che.plugin.svn.server.credentials.PreferencesCredentialsProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProviderImpl; import org.eclipse.che.plugin.svn.server.rest.SubversionService; @@ -40,9 +36,7 @@ protected void configure() { Multibinder.newSetBinder(binder(), ValueProviderFactory.class).addBinding().to(SubversionValueProviderFactory.class); bind(SubversionService.class); - bind(CredentialsProvider.class).to(PreferencesCredentialsProvider.class); bind(RepositoryUrlProvider.class).to(RepositoryUrlProviderImpl.class); - bind(CurrentUserPreferencesAccess.class).to(CurrentUserPreferencesAccessImpl.class); bind(SubversionConfigurationChecker.class).asEagerSingleton(); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporter.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporter.java index ab5c96def4cb..09ff3476ea71 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporter.java @@ -18,20 +18,15 @@ import org.eclipse.che.api.core.util.LineConsumerFactory; import org.eclipse.che.api.project.server.FolderEntry; import org.eclipse.che.api.project.server.importer.ProjectImporter; -import org.eclipse.che.dto.server.DtoFactory; + import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; -import java.util.Map; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; import org.eclipse.che.plugin.svn.shared.CheckoutRequest; -import org.eclipse.che.plugin.svn.shared.ImportParameterKeys; -import org.slf4j.LoggerFactory; -import static com.google.common.base.Strings.isNullOrEmpty; +import static org.eclipse.che.dto.server.DtoFactory.newDto; /** * Implementation of {@link ProjectImporter} for Subversion. @@ -43,13 +38,9 @@ public class SubversionProjectImporter implements ProjectImporter { private final SubversionApi subversionApi; - private final CredentialsProvider credentialsProvider; - @Inject - public SubversionProjectImporter(final CredentialsProvider credentialsProvider, - final SubversionApi subversionApi) { + public SubversionProjectImporter(final SubversionApi subversionApi) { this.subversionApi = subversionApi; - this.credentialsProvider = credentialsProvider; } @Override @@ -81,41 +72,12 @@ public void importSources(FolderEntry baseFolder, SourceStorage sourceStorage, L + "It is not a folder."); } - final String location = sourceStorage.getLocation(); - final Map parameters = sourceStorage.getParameters(); - - String[] credentials = null; - - if (parameters != null) { - String paramUsername = parameters.get(ImportParameterKeys.PARAMETER_USERNAME); - String paramPassword = parameters.get(ImportParameterKeys.PARAMETER_PASSWORD); - - if (!isNullOrEmpty(paramUsername) && !isNullOrEmpty(paramPassword)) { - credentials = new String[] {paramUsername, paramPassword}; - try { - this.credentialsProvider.storeCredential(location, new CredentialsProvider.Credentials(paramUsername, paramPassword)); - } catch (final CredentialsException e) { - LoggerFactory.getLogger(SubversionProjectImporter.class.getName()) - .warn("Could not store credentials - try to continue anyway." + e.getMessage()); - } - } - } - this.subversionApi.setOutputLineConsumerFactory(lineConsumerFactory); - - // Perform checkout - if (credentials != null) { - this.subversionApi.checkout(DtoFactory.getInstance() - .createDto(CheckoutRequest.class) - .withProjectPath(baseFolder.getVirtualFile().toIoFile().getAbsolutePath()) - .withUrl(location), - credentials); - } else { - this.subversionApi.checkout(DtoFactory.getInstance() - .createDto(CheckoutRequest.class) - .withProjectPath(baseFolder.getVirtualFile().toIoFile().getAbsolutePath()) - .withUrl(location)); - } + subversionApi.checkout(newDto(CheckoutRequest.class) + .withProjectPath(baseFolder.getVirtualFile().toIoFile().getAbsolutePath()) + .withUrl(sourceStorage.getLocation()) + .withUsername(sourceStorage.getParameters().remove("username")) + .withPassword(sourceStorage.getParameters().remove("password"))); } @Override diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsProvider.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsProvider.java deleted file mode 100644 index ee76f19c2f78..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; - -import org.eclipse.che.commons.annotation.Nullable; - -public interface CredentialsProvider { - - @Nullable - Credentials getCredentials(String repositoryUrl) throws CredentialsException; - - void storeCredential(String repositoryUrl, Credentials credentials) throws CredentialsException; - - public class Credentials { - - private final String username; - private final String password; - - public Credentials(final String username, final String password) { - this.username = username; - this.password = password; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - } - -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccess.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccess.java deleted file mode 100644 index f03158bdba31..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccess.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; - - -public interface CurrentUserPreferencesAccess { - - void updatePreference(String key, String content) throws PreferencesAccessException; - - String getPreference(String key) throws PreferencesAccessException; -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccessImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccessImpl.java deleted file mode 100644 index 71db6d51770b..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccessImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; - -import org.eclipse.che.api.core.ServerException; -import org.eclipse.che.api.user.server.spi.PreferenceDao; -import org.eclipse.che.commons.env.EnvironmentContext; -import org.eclipse.che.commons.subject.Subject; - -import javax.inject.Inject; -import java.text.MessageFormat; -import java.util.Map; - -/** - * Provides access to the current user's preferences.
- * Mostly necessary to allow easier mocking. - */ -public class CurrentUserPreferencesAccessImpl implements CurrentUserPreferencesAccess { - - private final PreferenceDao preferencesDao; - - @Inject - public CurrentUserPreferencesAccessImpl(final PreferenceDao preferencesDao) { - this.preferencesDao = preferencesDao; - } - - @Override - public void updatePreference(final String key, final String value) throws PreferencesAccessException { - final Subject currentSubject = getCurrentSubject(); - Map content; - try { - content = this.preferencesDao.getPreferences(currentSubject.getUserId()); - } catch (final ServerException e) { - throw new PreferencesAccessException(e); - } - content.put(key, value); - try { - this.preferencesDao.setPreferences(currentSubject.getUserId(), content); - } catch (final ServerException e) { - throw new PreferencesAccessException(e); - } - } - - @Override - public String getPreference(final String key) throws PreferencesAccessException { - final Subject currentSubject = getCurrentSubject(); - final String pattern = MessageFormat.format("^{0}$", key); - Map response; - try { - response = this.preferencesDao.getPreferences(currentSubject.getUserId(), pattern); - } catch (final ServerException e) { - throw new PreferencesAccessException(e); - } - return response.get(key); - } - - private Subject getCurrentSubject() { - return EnvironmentContext.getCurrent().getSubject(); - } -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesAccessException.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesAccessException.java deleted file mode 100644 index 2c9b6b05fa1c..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesAccessException.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; - -public class PreferencesAccessException extends Exception { - - private static final long serialVersionUID = 1L; - - public PreferencesAccessException() { - } - - public PreferencesAccessException(String message) { - super(message); - } - - public PreferencesAccessException(Throwable cause) { - super(cause); - } - - public PreferencesAccessException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesCredentialsProvider.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesCredentialsProvider.java deleted file mode 100644 index bd80eee23dab..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesCredentialsProvider.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.che.api.crypt.server.EncryptException; -import org.eclipse.che.api.crypt.server.EncryptTextModule; -import org.eclipse.che.api.crypt.server.EncryptTextService; -import org.eclipse.che.api.crypt.server.EncryptTextServiceRegistry; -import org.eclipse.che.api.crypt.shared.EncryptResult; -import org.eclipse.che.dto.server.DtoFactory; -import org.eclipse.che.plugin.svn.shared.credentials.RepositoryCredentials; -import org.eclipse.che.plugin.svn.shared.credentials.UserCredentialStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PreferencesCredentialsProvider implements CredentialsProvider { - - private static final Logger LOG = LoggerFactory.getLogger(PreferencesCredentialsProvider.class); - - private static final String SVN_CREDENTIALS = "svn_credentials"; - - private final EncryptTextServiceRegistry encryptTextServiceRegistry; - - private final CurrentUserPreferencesAccess preferencesAccess; - - @Inject - public PreferencesCredentialsProvider(final CurrentUserPreferencesAccess preferencesAccess, - final EncryptTextServiceRegistry encryptTextServiceRegistry) { - this.encryptTextServiceRegistry = encryptTextServiceRegistry; - this.preferencesAccess = preferencesAccess; - } - - @Override - public Credentials getCredentials(final String repositoryUrl) throws CredentialsException { - LOG.debug("getCredentials called for " + repositoryUrl); - String serializedCredentials; - try { - serializedCredentials = this.preferencesAccess.getPreference(SVN_CREDENTIALS); - } catch (final PreferencesAccessException e) { - throw new CredentialsException(e); - } - LOG.debug("getCredentials - {} read: {}", SVN_CREDENTIALS, serializedCredentials); - if (serializedCredentials == null) { - return null; - } - final DtoFactory dtoFactory = DtoFactory.getInstance(); - final UserCredentialStore userCredentials = dtoFactory.createDtoFromJson(serializedCredentials, UserCredentialStore.class); - if (userCredentials == null || userCredentials.getRepositoriesCredentials() == null) { - return null; - } - LOG.debug("getCredentials - user credentials found with keys:{}", - Arrays.toString(userCredentials.getRepositoriesCredentials().keySet().toArray())); - final RepositoryCredentials repositoryCreds = userCredentials.getRepositoriesCredentials().get(repositoryUrl); - if (repositoryCreds == null) { - LOG.debug("getCredentials - no credentials found for " + repositoryUrl); - return null; - } - LOG.debug("getCredentials - repository credentials found for " + repositoryUrl); - String username = ""; - if (repositoryCreds.getUsername() != null) { - username = repositoryCreds.getUsername(); - } - LOG.debug("getCredentials - got username:" + username); - final int schemeVersion = repositoryCreds.getEncryptionSchemeVersion(); - final EncryptTextService encryptService = this.encryptTextServiceRegistry.getService(schemeVersion); - if (encryptService == null) { - throw new CredentialsException("No encryption service matches the specified one"); - } - final String encryptedPassword = repositoryCreds.getEncryptedPassword(); - if (encryptedPassword == null || encryptedPassword.isEmpty()) { - LOG.debug("getCredentials - got empty password"); - return new Credentials(username, encryptedPassword); - } - final EncryptResult toDecrypt = new EncryptResult(encryptedPassword, repositoryCreds.getInitVector()); - String password; - try { - password = encryptService.decryptText(toDecrypt); - } catch (final EncryptException e) { - LOG.warn("getCredentials - decrypt password failed"); - throw new CredentialsException(e); - } - LOG.debug("getCredentials: found {}, ####", username); - return new Credentials(username, password); - } - - @Override - public void storeCredential(final String repositoryUrl, final Credentials credentials) throws CredentialsException { - LOG.debug("storeCredentials called for " + repositoryUrl); - if (credentials == null) { - return; - } - - final DtoFactory dtoFactory = DtoFactory.getInstance(); - - String oldSerializedCredentials; - try { - oldSerializedCredentials = this.preferencesAccess.getPreference(SVN_CREDENTIALS); - } catch (final PreferencesAccessException e) { - throw new CredentialsException(e); - } - - // analyze the structure and build what's missing - UserCredentialStore userCredentials; - if (oldSerializedCredentials != null) { - userCredentials = dtoFactory.createDtoFromJson(oldSerializedCredentials, UserCredentialStore.class); - } else { - userCredentials = dtoFactory.createDto(UserCredentialStore.class); - } - Map repositoriesCredentials = userCredentials.getRepositoriesCredentials(); - if (repositoriesCredentials == null) { - repositoriesCredentials = new HashMap<>(); - userCredentials.setRepositoriesCredentials(repositoriesCredentials); - } - RepositoryCredentials repositoryCreds = repositoriesCredentials.get(repositoryUrl); - if (repositoryCreds == null) { - repositoryCreds = dtoFactory.createDto(RepositoryCredentials.class); - repositoriesCredentials.put(repositoryUrl, repositoryCreds); - } - - // set the values - repositoryCreds.setUsername(credentials.getUsername()); - - final EncryptTextService encryptService = this.encryptTextServiceRegistry.getPreferredService(); - if (encryptService == null) { - throw new CredentialsException("No encryption service matches the specified one"); - } - EncryptResult encryptResult; - try { - encryptResult = encryptService.encryptText(credentials.getPassword()); - } catch (final EncryptException e) { - throw new CredentialsException(e); - } - repositoryCreds.setEncryptedPassword(encryptResult.getCipherText()); - repositoryCreds.setInitVector(encryptResult.getInitVector()); - repositoryCreds.setEncryptionSchemeVersion(encryptService.getSchemeVersion()); - - // store the new version in the preferences - final String newSerializedCredentials = dtoFactory.toJson(userCredentials); - - try { - this.preferencesAccess.updatePreference(SVN_CREDENTIALS, newSerializedCredentials); - LOG.debug("storeCredentials done " + newSerializedCredentials); - } catch (final PreferencesAccessException e) { - throw new CredentialsException(e); - } - } - -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java index 489eae74be50..7fa26ceef423 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java @@ -19,9 +19,6 @@ import org.eclipse.che.dto.server.DtoFactory; import org.eclipse.che.plugin.svn.server.SubversionApi; import org.eclipse.che.plugin.svn.server.SubversionException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider.Credentials; import org.eclipse.che.plugin.svn.shared.AddRequest; import org.eclipse.che.plugin.svn.shared.CLIOutputResponse; import org.eclipse.che.plugin.svn.shared.CLIOutputResponseList; @@ -45,7 +42,6 @@ import org.eclipse.che.plugin.svn.shared.RemoveRequest; import org.eclipse.che.plugin.svn.shared.ResolveRequest; import org.eclipse.che.plugin.svn.shared.RevertRequest; -import org.eclipse.che.plugin.svn.shared.SaveCredentialsRequest; import org.eclipse.che.plugin.svn.shared.ShowDiffRequest; import org.eclipse.che.plugin.svn.shared.ShowLogRequest; import org.eclipse.che.plugin.svn.shared.StatusRequest; @@ -78,9 +74,6 @@ public class SubversionService extends Service { @Inject private SubversionApi subversionApi; - @Inject - private CredentialsProvider credentialsProvider; - /** * Add the selected paths to version control. @@ -371,19 +364,6 @@ public CLIOutputResponse unlock(final LockRequest request) throws ApiException, return this.subversionApi.lockUnlock(request, false); } - @Path("saveCredentials") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) - public void saveCredentials(final SaveCredentialsRequest request) throws ServerException, IOException { - try { - this.credentialsProvider.storeCredential(request.getRepositoryUrl(), - new Credentials(request.getUsername(), request.getPassword())); - } catch (final CredentialsException e) { - throw new ServerException(e.getMessage()); - } - } - @Path("export/{projectPath:.*}") @GET @Produces(MediaType.APPLICATION_JSON) diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionApiITest.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionApiITest.java index d1ad624cfa35..15e86cea8554 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionApiITest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionApiITest.java @@ -14,7 +14,6 @@ import org.eclipse.che.dto.server.DtoFactory; import org.eclipse.che.plugin.ssh.key.script.SshKeyProvider; import org.eclipse.che.plugin.ssh.key.script.SshScriptProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.utils.TestUtils; import org.eclipse.che.plugin.svn.shared.CLIOutputResponse; @@ -51,8 +50,6 @@ @RunWith(MockitoJUnitRunner.class) public class SubversionApiITest { - @Mock - private CredentialsProvider credentialsProvider; @Mock private RepositoryUrlProvider repositoryUrlProvider; @Mock @@ -72,7 +69,7 @@ public void setUp() throws Exception { tmpAbsolutePath = tmpDir.toFile().getAbsolutePath(); tmpDir.toFile().deleteOnExit(); - this.subversionApi = new SubversionApi(credentialsProvider, repositoryUrlProvider, new SshScriptProvider(sshKeyProvider)); + this.subversionApi = new SubversionApi(repositoryUrlProvider, new SshScriptProvider(sshKeyProvider)); } /** diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporterTest.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporterTest.java index 4b18ad594a1e..c226a7200795 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporterTest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporterTest.java @@ -25,7 +25,6 @@ import org.eclipse.che.api.vfs.VirtualFileSystem; import org.eclipse.che.commons.lang.NameGenerator; import org.eclipse.che.plugin.ssh.key.script.SshKeyProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.utils.TestUtils; import org.junit.Before; @@ -48,9 +47,6 @@ public class SubversionProjectImporterTest { @Mock private ProfileDao userProfileDao; - - @Mock - private CredentialsProvider credentialsProvider; @Mock private RepositoryUrlProvider repositoryUrlProvider; @Mock @@ -75,7 +71,6 @@ protected void configure() { bind(SshKeyProvider.class).toInstance(sshKeyProvider); bind(ProfileDao.class).toInstance(userProfileDao); - bind(CredentialsProvider.class).toInstance(credentialsProvider); bind(RepositoryUrlProvider.class).toInstance(repositoryUrlProvider); } }); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/utils/TestUtils.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/utils/TestUtils.java index 1eed582ac9d4..264668e9695a 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/utils/TestUtils.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/utils/TestUtils.java @@ -25,8 +25,6 @@ import org.eclipse.che.dto.server.DtoFactory; import org.eclipse.che.plugin.svn.server.SubversionApi; import org.eclipse.che.plugin.svn.server.SubversionException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.upstream.CommandLineResult; import org.eclipse.che.plugin.svn.server.upstream.UpstreamUtils; @@ -61,16 +59,7 @@ public class TestUtils { private static DtoFactory dtoFactory = DtoFactory.getInstance(); - private static SubversionApi subversionApi = new SubversionApi(new CredentialsProvider() { - @Override - public Credentials getCredentials(final String repositoryUrl) { - return null; - } - - @Override - public void storeCredential(final String repositoryUrl, final Credentials credentials) throws CredentialsException { - } - }, new RepositoryUrlProvider() { + private static SubversionApi subversionApi = new SubversionApi(new RepositoryUrlProvider() { @Override public String getRepositoryUrl(final String projectPath) throws IOException { return ""; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/pom.xml b/plugins/plugin-svn/che-plugin-svn-ext-shared/pom.xml index 77a9077b2772..61abdf1f480c 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/pom.xml +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/pom.xml @@ -42,6 +42,10 @@ org.eclipse.che.core che-core-api-dto + + org.eclipse.che.core + che-core-commons-annotations + org.eclipse.che.core che-core-commons-gwt diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CheckoutRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CheckoutRequest.java index ad890a8d9c92..993c57b027a4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CheckoutRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CheckoutRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -121,4 +122,23 @@ public interface CheckoutRequest { */ CheckoutRequest withRevision(@NotNull final String revision); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + CheckoutRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + CheckoutRequest withPassword(@Nullable final String password); + } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CopyRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CopyRequest.java index e14555002089..08a005e63154 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CopyRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CopyRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -94,4 +95,22 @@ public interface CopyRequest { * commentary */ CopyRequest withComment(String comment); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + CopyRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + CopyRequest withPassword(@Nullable final String password); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/InfoRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/InfoRequest.java index 6498a7661354..5c91e397d43c 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/InfoRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/InfoRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -65,4 +66,22 @@ public interface InfoRequest { InfoRequest withChildren(@NotNull final boolean children); + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + InfoRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + InfoRequest withPassword(@Nullable final String password); + } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/LockRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/LockRequest.java index 2b387e7911b5..15dd9fee75b4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/LockRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/LockRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import java.util.List; @@ -53,4 +54,22 @@ public interface LockRequest { LockRequest withForce(boolean force); void setForce(boolean force); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + LockRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + LockRequest withPassword(@Nullable final String password); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/MoveRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/MoveRequest.java index 096c4d3e63ed..d6b22c9f05fc 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/MoveRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/MoveRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -93,4 +94,22 @@ public interface MoveRequest { * commentary */ MoveRequest withComment(String comment); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + MoveRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + MoveRequest withPassword(@Nullable final String password); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/SaveCredentialsRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/SaveCredentialsRequest.java deleted file mode 100644 index 38b13436a06a..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/SaveCredentialsRequest.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * 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: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.shared; - -import org.eclipse.che.dto.shared.DTO; - -@DTO -public interface SaveCredentialsRequest { - - String getUsername(); - - SaveCredentialsRequest withUsername(String username); - - String getPassword(); - - SaveCredentialsRequest withPassword(String password); - - String getRepositoryUrl(); - - SaveCredentialsRequest withRepositoryUrl(String repositoryUrl); -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/ShowDiffRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/ShowDiffRequest.java index 1b70e1e5a6be..60cd0570b71e 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/ShowDiffRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/ShowDiffRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -81,4 +82,22 @@ public interface ShowDiffRequest { * @return the request */ ShowDiffRequest withDepth(@NotNull final String depth); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + ShowDiffRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + ShowDiffRequest withPassword(@Nullable final String password); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/UpdateRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/UpdateRequest.java index 2b2a00d2c474..4add6a384b0d 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/UpdateRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/UpdateRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -119,4 +120,22 @@ public interface UpdateRequest { */ UpdateRequest withRevision(@NotNull final String revision); + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + UpdateRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + UpdateRequest withPassword(@Nullable final String password); + } diff --git a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectImporter.java b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectImporter.java index 01abcbd17d0a..144029adbaa6 100644 --- a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectImporter.java +++ b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectImporter.java @@ -140,8 +140,8 @@ public void importSources(FolderEntry baseFolder, recursiveEnabled = true; } branchMerge = parameters.get("branchMerge"); - final String user = parameters.get("userName"); - final String pass = parameters.get("password"); + final String user = storage.getParameters().remove("username"); + final String pass = storage.getParameters().remove("password"); if (user != null && pass != null) { credentialsHaveBeenSet = true; setCurrentCredentials(user, pass); From 56e8ae547f7e8406298daeea3aef72d158e6dc04 Mon Sep 17 00:00:00 2001 From: Kaloyan Raev Date: Wed, 5 Oct 2016 15:29:32 +0300 Subject: [PATCH 18/33] Add some files generated by m2e to .gitignore (#2705) * Add some files generated by m2e to .gitignore Signed-off-by: Kaloyan Raev * Ignore all .launch files Signed-off-by: Kaloyan Raev * Ignore all *.launch files Signed-off-by: Kaloyan Raev --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 40ea8854bbce..d48899072c0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,14 @@ # Eclipse # ################### +*.launch .classpath .project .settings/ target/ bin/ test-output/ +maven-eclipse.xml # Idea # ################## From 7e653b57c97160c47d3cf743d744c7b4314245d1 Mon Sep 17 00:00:00 2001 From: Vitaliy Guliy Date: Wed, 5 Oct 2016 16:18:02 +0300 Subject: [PATCH 19/33] CHE-2477 Move Git and Subversion menus to the left (#2708) Signed-off-by: Vitaliy Guliy --- .../java/org/eclipse/che/ide/ext/git/client/GitExtension.java | 4 ++-- .../org/eclipse/che/plugin/svn/ide/SubversionExtension.java | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/GitExtension.java b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/GitExtension.java index 58cad2448643..79b003bfe2ac 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/GitExtension.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/GitExtension.java @@ -40,8 +40,8 @@ import org.eclipse.che.ide.ext.git.client.action.ShowRemoteAction; import org.eclipse.che.ide.ext.git.client.action.ShowStatusAction; -import static org.eclipse.che.ide.api.action.IdeActions.GROUP_HELP; import static org.eclipse.che.ide.api.action.IdeActions.GROUP_MAIN_MENU; +import static org.eclipse.che.ide.api.action.IdeActions.GROUP_PROFILE; import static org.eclipse.che.ide.api.constraints.Anchor.BEFORE; /** @@ -89,7 +89,7 @@ public GitExtension(GitResources resources, DefaultActionGroup git = new DefaultActionGroup(GIT_GROUP_MAIN_MENU, true, actionManager); actionManager.registerAction("git", git); - mainMenu.add(git, new Constraints(BEFORE, GROUP_HELP)); + mainMenu.add(git, new Constraints(BEFORE, GROUP_PROFILE)); DefaultActionGroup commandGroup = new DefaultActionGroup(COMMAND_GROUP_MAIN_MENU, false, actionManager); actionManager.registerAction("gitCommandGroup", commandGroup); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java index e3b1591fe2f3..252aef7528b5 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java @@ -80,7 +80,6 @@ public SubversionExtension(final ActionManager actionManager, final SubversionExtensionResources resources) { SVN_GROUP_MAIN_MENU = constants.subversionLabel(); - final Constraints beforeWindow = new Constraints(Anchor.BEFORE, IdeActions.GROUP_HELP); final DefaultActionGroup addCommandGroup = new DefaultActionGroup(ADD_COMMAND_GROUP, false, actionManager); final DefaultActionGroup mainMenu = (DefaultActionGroup)actionManager.getAction(IdeActions.GROUP_MAIN_MENU); final DefaultActionGroup fileCommandGroup = new DefaultActionGroup(FILE_COMMAND_GROUP, false, actionManager); @@ -98,7 +97,7 @@ public SubversionExtension(final ActionManager actionManager, // Register action groups actionManager.registerAction(SVN_GROUP_MAIN_MENU, svnMenu); - mainMenu.add(svnMenu, beforeWindow); + mainMenu.add(svnMenu, new Constraints(Anchor.BEFORE, IdeActions.GROUP_PROFILE)); actionManager.registerAction(REMOTE_COMMAND_GROUP, remoteCommandGroup); svnMenu.add(remoteCommandGroup); From f29badd970f06a859362f0bedc8c775c69b69bef Mon Sep 17 00:00:00 2001 From: Vitalii Parfonov Date: Wed, 5 Oct 2016 16:39:15 +0300 Subject: [PATCH 20/33] Add default content for PHP project (#2710) * Add default content for PHP project Signed-off-by: Vitalii Parfonov --- .../che-plugin-php-lang-server/pom.xml | 4 ++ .../che/plugin/php/inject/PhpModule.java | 7 ++++ .../php/projecttype/PhpProjectGenerator.java | 39 +++++++++++++++++++ .../main/resources/files/default_php_content | 5 +++ 4 files changed, 55 insertions(+) create mode 100644 plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/projecttype/PhpProjectGenerator.java create mode 100644 plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content diff --git a/plugins/plugin-php/che-plugin-php-lang-server/pom.xml b/plugins/plugin-php/che-plugin-php-lang-server/pom.xml index 9b14b175c4a1..76fec0de652e 100644 --- a/plugins/plugin-php/che-plugin-php-lang-server/pom.xml +++ b/plugins/plugin-php/che-plugin-php-lang-server/pom.xml @@ -36,6 +36,10 @@ io.typefox.lsapi io.typefox.lsapi.services + + org.eclipse.che.core + che-core-api-core + org.eclipse.che.core che-core-api-languageserver diff --git a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java index 85dda46ba784..018d0e76b0c9 100644 --- a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java @@ -14,11 +14,15 @@ import com.google.inject.multibindings.Multibinder; import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.project.server.handlers.ProjectHandler; import org.eclipse.che.api.project.server.type.ProjectTypeDef; import org.eclipse.che.inject.DynaModule; import org.eclipse.che.plugin.php.languageserver.PhpLanguageServerLauncher; +import org.eclipse.che.plugin.php.projecttype.PhpProjectGenerator; import org.eclipse.che.plugin.php.projecttype.PhpProjectType; +import static com.google.inject.multibindings.Multibinder.newSetBinder; + /** * @author Kaloyan Raev */ @@ -29,6 +33,9 @@ protected void configure() { Multibinder projectTypeMultibinder = Multibinder.newSetBinder(binder(), ProjectTypeDef.class); projectTypeMultibinder.addBinding().to(PhpProjectType.class); + Multibinder projectHandlerMultibinder = newSetBinder(binder(), ProjectHandler.class); + projectHandlerMultibinder.addBinding().to(PhpProjectGenerator.class); + Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(PhpLanguageServerLauncher.class); } } diff --git a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/projecttype/PhpProjectGenerator.java b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/projecttype/PhpProjectGenerator.java new file mode 100644 index 000000000000..fbbfc7936944 --- /dev/null +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/projecttype/PhpProjectGenerator.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ + +package org.eclipse.che.plugin.php.projecttype; + +import org.eclipse.che.api.core.ConflictException; +import org.eclipse.che.api.core.ForbiddenException; +import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.project.server.FolderEntry; +import org.eclipse.che.api.project.server.handlers.CreateProjectHandler; +import org.eclipse.che.api.project.server.type.AttributeValue; +import org.eclipse.che.plugin.php.shared.Constants; + +import java.util.Map; + +public class PhpProjectGenerator implements CreateProjectHandler { + + private static final String FILE_NAME = "hello.php"; + + @Override + public void onCreateProject(FolderEntry baseFolder, + Map attributes, + Map options) throws ForbiddenException, ConflictException, ServerException { + baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_php_content")); + } + + @Override + public String getProjectType() { + return Constants.PHP_PROJECT_TYPE_ID; + } +} diff --git a/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content b/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content new file mode 100644 index 000000000000..9a4d9faa3640 --- /dev/null +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content @@ -0,0 +1,5 @@ +// Hello World program + + From 4de711114722501fb4ad47f49b041bae2ade3dde Mon Sep 17 00:00:00 2001 From: Yevhenii Voevodin Date: Wed, 5 Oct 2016 16:40:11 +0300 Subject: [PATCH 21/33] Use eager fetch type for workspace entities (#2709) --- .../che/api/machine/server/model/impl/CommandImpl.java | 3 ++- .../api/workspace/server/model/impl/EnvironmentImpl.java | 3 ++- .../workspace/server/model/impl/ExtendedMachineImpl.java | 7 ++++--- .../api/workspace/server/model/impl/ProjectConfigImpl.java | 7 ++++--- .../api/workspace/server/model/impl/ServerConf2Impl.java | 3 ++- .../api/workspace/server/model/impl/SourceStorageImpl.java | 3 ++- .../workspace/server/model/impl/WorkspaceConfigImpl.java | 7 ++++--- .../che/api/workspace/server/model/impl/WorkspaceImpl.java | 2 +- 8 files changed, 21 insertions(+), 14 deletions(-) diff --git a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/model/impl/CommandImpl.java b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/model/impl/CommandImpl.java index 0216e3d780bd..af74959ae80d 100644 --- a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/model/impl/CommandImpl.java +++ b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/model/impl/CommandImpl.java @@ -15,6 +15,7 @@ import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.MapKeyColumn; @@ -43,7 +44,7 @@ public class CommandImpl implements Command { @Column(nullable = false) private String type; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) @MapKeyColumn(name = "name") @Column(name = "value", columnDefinition = "TEXT") private Map attributes; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/EnvironmentImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/EnvironmentImpl.java index 31e46ae8e4d9..ecdecf2a8cb7 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/EnvironmentImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/EnvironmentImpl.java @@ -17,6 +17,7 @@ import javax.persistence.CascadeType; import javax.persistence.Embedded; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -40,7 +41,7 @@ public class EnvironmentImpl implements Environment { @Embedded private EnvironmentRecipeImpl recipe; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private Map machines; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ExtendedMachineImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ExtendedMachineImpl.java index 926157890a43..c79ad3abff37 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ExtendedMachineImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ExtendedMachineImpl.java @@ -16,6 +16,7 @@ import javax.persistence.CascadeType; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -37,13 +38,13 @@ public class ExtendedMachineImpl implements ExtendedMachine { @GeneratedValue private Long id; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private List agents; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private Map attributes; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private Map servers; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java index a74cc8fde892..0a2466c907ef 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java @@ -19,6 +19,7 @@ import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -63,10 +64,10 @@ public class ProjectConfigImpl implements ProjectConfig { @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) private SourceStorageImpl source; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private List mixins; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn @MapKey(name = "name") private Map dbAttributes; @@ -230,7 +231,7 @@ private static class Attribute { @Basic private String name; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private List values; public Attribute() {} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ServerConf2Impl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ServerConf2Impl.java index 45a32df5b67b..387b35e2a601 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ServerConf2Impl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ServerConf2Impl.java @@ -15,6 +15,7 @@ import javax.persistence.Basic; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import java.util.HashMap; @@ -37,7 +38,7 @@ public class ServerConf2Impl implements ServerConf2 { @Basic private String protocol; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private Map properties; public ServerConf2Impl() {} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/SourceStorageImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/SourceStorageImpl.java index dbe5d0ffd582..989cb73877f1 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/SourceStorageImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/SourceStorageImpl.java @@ -16,6 +16,7 @@ import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import java.util.HashMap; @@ -40,7 +41,7 @@ public class SourceStorageImpl implements SourceStorage { @Column(columnDefinition = "TEXT") private String location; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private Map parameters; public SourceStorageImpl() {} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java index ef8bd2c7faa0..7a983632b01c 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java @@ -20,6 +20,7 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -62,15 +63,15 @@ public static WorkspaceConfigImplBuilder builder() { @Column(nullable = false) private String defaultEnv; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private List commands; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private List projects; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private Map environments; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java index e95050bfc396..e340c8487c03 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java @@ -84,7 +84,7 @@ public static WorkspaceImplBuilder builder() { @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) private WorkspaceConfigImpl config; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private Map attributes; @Basic From 5d30868c468a00605590f6920d860c14a17edd51 Mon Sep 17 00:00:00 2001 From: Mathias Schaefer Date: Tue, 9 Aug 2016 12:04:56 +0200 Subject: [PATCH 22/33] Add new example plugins provided by EclipseSource Signed-off-by: Ann Shumilova --- samples/pom.xml | 4 + .../che-sample-plugin-embedjs-ide/pom.xml | 61 +++++++++++++ .../ide/HelloWorldResources.java | 24 +++++ .../ide/HelloWorldViewExampleExtension.java | 39 ++++++++ .../ide/action/HelloWorldAction.java | 46 ++++++++++ .../embedjsexample/ide/common/Constants.java | 20 +++++ .../HelloWorldViewExampleGinModule.java | 29 ++++++ .../ide/view/HelloWorldView.java | 27 ++++++ .../ide/view/HelloWorldViewImpl.java | 48 ++++++++++ .../ide/view/HelloWorldViewImpl.ui.xml | 34 +++++++ .../ide/view/HelloWorldViewPresenter.java | 88 +++++++++++++++++++ .../client/jso/HelloWorldViewOverlay.java | 30 +++++++ .../embedjsexample/EmbedJSExample.gwt.xml | 26 ++++++ .../plugin/embedjsexample/ide/svg/icon.svg | 48 ++++++++++ .../embedjsexample/public/helloworld.js | 15 ++++ samples/sample-plugin-embedjs/pom.xml | 28 ++++++ .../che-sample-plugin-json-ide/pom.xml | 22 ++--- .../ide/action/JsonExampleProjectAction.java | 4 +- .../pom.xml | 85 ++++++++++++++++++ .../ide/NativeAccessExampleExtension.java | 41 +++++++++ .../ide/action/RunNativeCommandAction.java | 42 +++++++++ .../client/command/CommandManager.java | 81 +++++++++++++++++ .../NativeAccessExample.gwt.xml | 28 ++++++ samples/sample-plugin-nativeaccess/pom.xml | 28 ++++++ .../che-sample-plugin-parts-ide/pom.xml | 57 ++++++++++++ .../parts/ide/SamplePartsExtension.java | 46 ++++++++++ .../parts/ide/SamplePartsResources.java | 37 ++++++++ .../helloworldview/HelloWorldPresenter.java | 66 ++++++++++++++ .../ide/helloworldview/HelloWorldView.java | 37 ++++++++ .../helloworldview/HelloWorldViewAction.java | 51 +++++++++++ .../helloworldview/HelloWorldViewImpl.java | 37 ++++++++ .../plugin/parts/ide/inject/MyGinModule.java | 32 +++++++ .../che/plugin/parts/SampleParts.gwt.xml | 28 ++++++ .../eclipse/che/plugin/parts/ide/icons/my.svg | 39 ++++++++ samples/sample-plugin-parts/pom.xml | 28 ++++++ .../pom.xml | 57 ++++++++++++ .../serverservice/ide/MyServiceClient.java | 63 +++++++++++++ .../ide/ServerServiceExtension.java | 45 ++++++++++ .../serverservice/ide/action/MyAction.java | 66 ++++++++++++++ .../serverservice/ServerService.gwt.xml | 28 ++++++ .../pom.xml | 37 ++++++++ .../che/plugin/serverservice/MyService.java | 36 ++++++++ .../inject/ServerServiceGuiceModule.java | 28 ++++++ samples/sample-plugin-serverservice/pom.xml | 29 ++++++ 44 files changed, 1730 insertions(+), 15 deletions(-) create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/pom.xml create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldResources.java create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldViewExampleExtension.java create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/action/HelloWorldAction.java create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/common/Constants.java create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/inject/HelloWorldViewExampleGinModule.java create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldView.java create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.java create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.ui.xml create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewPresenter.java create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/client/jso/HelloWorldViewOverlay.java create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/EmbedJSExample.gwt.xml create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/ide/svg/icon.svg create mode 100644 samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/public/helloworld.js create mode 100644 samples/sample-plugin-embedjs/pom.xml create mode 100644 samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/pom.xml create mode 100644 samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/NativeAccessExampleExtension.java create mode 100644 samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/action/RunNativeCommandAction.java create mode 100644 samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/machine/client/command/CommandManager.java create mode 100644 samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/resources/org/eclipse/che/plugin/nativeaccessexample/NativeAccessExample.gwt.xml create mode 100644 samples/sample-plugin-nativeaccess/pom.xml create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/pom.xml create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsExtension.java create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsResources.java create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldPresenter.java create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldView.java create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewAction.java create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewImpl.java create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/inject/MyGinModule.java create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/SampleParts.gwt.xml create mode 100644 samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/ide/icons/my.svg create mode 100644 samples/sample-plugin-parts/pom.xml create mode 100644 samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/pom.xml create mode 100644 samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/MyServiceClient.java create mode 100644 samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/ServerServiceExtension.java create mode 100644 samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/action/MyAction.java create mode 100644 samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/resources/org/eclipse/che/plugin/serverservice/ServerService.gwt.xml create mode 100644 samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/pom.xml create mode 100644 samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/MyService.java create mode 100644 samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/inject/ServerServiceGuiceModule.java create mode 100644 samples/sample-plugin-serverservice/pom.xml diff --git a/samples/pom.xml b/samples/pom.xml index 63b8afc70b6b..797d737c94ad 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -25,8 +25,12 @@ pom Che Sample :: Parent + sample-plugin-embedjs sample-plugin-json sample-plugin-filetype sample-plugin-wizard + sample-plugin-nativeaccess + sample-plugin-parts + sample-plugin-serverservice diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/pom.xml b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/pom.xml new file mode 100644 index 000000000000..f31e4d1e246c --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/pom.xml @@ -0,0 +1,61 @@ + + + + 4.0.0 + + che-sample-plugin-embedjs-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-embedjs-ide + jar + Che Sample :: Plugin Embed JavaScript :: IDE + + + com.google.gwt.inject + gin + + + com.google.inject + guice + + + org.eclipse.che.core + che-core-commons-gwt + + + org.eclipse.che.core + che-core-ide-api + + + org.vectomatic + lib-gwt-svg + + + com.google.gwt + gwt-user + provided + + + + + + src/main/java + + + src/main/resources + + + + diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldResources.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldResources.java new file mode 100644 index 000000000000..a95a898cab4a --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldResources.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; +import org.vectomatic.dom.svg.ui.SVGResource; + +public interface HelloWorldResources extends ClientBundle { + + HelloWorldResources INSTANCE = GWT.create(HelloWorldResources.class); + + @Source("svg/icon.svg") + SVGResource icon(); + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldViewExampleExtension.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldViewExampleExtension.java new file mode 100644 index 000000000000..b38589c59975 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldViewExampleExtension.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.ActionManager; +import org.eclipse.che.ide.api.action.DefaultActionGroup; +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.plugin.embedjsexample.ide.action.HelloWorldAction; + +/** + * @author Mathias Schaefer + */ +@Extension(title = "Hello world from JavaScript example") +@Singleton +public class HelloWorldViewExampleExtension { + + @Inject + private void configureActions(final ActionManager actionManager, + final HelloWorldAction helloWorldAction) { + + DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup)actionManager.getAction("resourceOperation"); + DefaultActionGroup jsGroup = new DefaultActionGroup("JavaScript View Example", true, actionManager); + mainContextMenuGroup.add(jsGroup); + + actionManager.registerAction(helloWorldAction.ACTION_ID, helloWorldAction); + jsGroup.addAction(helloWorldAction); + } + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/action/HelloWorldAction.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/action/HelloWorldAction.java new file mode 100644 index 000000000000..777dbcf9dff0 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/action/HelloWorldAction.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.action; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.Action; +import org.eclipse.che.ide.api.action.ActionEvent; +import org.eclipse.che.ide.api.parts.PartStackType; +import org.eclipse.che.ide.api.parts.WorkspaceAgent; +import org.eclipse.che.plugin.embedjsexample.ide.view.HelloWorldViewPresenter; + +/** + * Action for opening a part which embeds javascript code. + */ +@Singleton +public class HelloWorldAction extends Action { + + public final static String ACTION_ID = "helloWorldFromJSAction"; + + private WorkspaceAgent workspaceAgent; + private HelloWorldViewPresenter helloWorldViewPresenter; + + @Inject + public HelloWorldAction(WorkspaceAgent workspaceAgent, HelloWorldViewPresenter helloWorldViewPresenter) { + super("Show Hello World JavaScript View"); + this.workspaceAgent = workspaceAgent; + this.helloWorldViewPresenter = helloWorldViewPresenter; + } + + @Override + public void actionPerformed(ActionEvent e) { + workspaceAgent.openPart(helloWorldViewPresenter, PartStackType.INFORMATION); + workspaceAgent.setActivePart(helloWorldViewPresenter); + helloWorldViewPresenter.setVisible(true); + } + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/common/Constants.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/common/Constants.java new file mode 100644 index 000000000000..42849e531731 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/common/Constants.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.common; + +/** + * @author Mathias Schaefer + */ +public class Constants { + + public final static String JAVASCRIPT_FILE_ID = "helloworld.js"; + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/inject/HelloWorldViewExampleGinModule.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/inject/HelloWorldViewExampleGinModule.java new file mode 100644 index 000000000000..c6010dbd7be3 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/inject/HelloWorldViewExampleGinModule.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.inject; + +import com.google.gwt.inject.client.AbstractGinModule; +import org.eclipse.che.ide.api.extension.ExtensionGinModule; +import org.eclipse.che.plugin.embedjsexample.ide.view.HelloWorldView; +import org.eclipse.che.plugin.embedjsexample.ide.view.HelloWorldViewImpl; + +/** + * @author Mathias Schaefer + */ +@ExtensionGinModule +public class HelloWorldViewExampleGinModule extends AbstractGinModule { + + @Override + protected void configure() { + bind(HelloWorldView.class).to(HelloWorldViewImpl.class); + } + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldView.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldView.java new file mode 100644 index 000000000000..d1720b217868 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldView.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.view; + +import org.eclipse.che.ide.api.mvp.View; +import org.eclipse.che.ide.api.parts.base.BaseActionDelegate; + +/** + * @author Mathias Schaefer + */ +public interface HelloWorldView extends View { + + interface ActionDelegate extends BaseActionDelegate { + } + + void sayHello(String content); + + void setVisible(boolean visible); +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.java new file mode 100644 index 000000000000..a4e04f75e436 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.view; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Widget; +import com.google.inject.Inject; +import org.eclipse.che.ide.api.parts.PartStackUIResources; +import org.eclipse.che.ide.api.parts.base.BaseView; +import org.eclipse.che.plugin.embedjsexample.ide.view.client.jso.HelloWorldViewOverlay; + +/** + * @author Mathias Schaefer + */ +public class HelloWorldViewImpl extends BaseView implements HelloWorldView { + + interface HelloWorldViewImplUiBinder extends UiBinder { + } + + private final static HelloWorldViewImplUiBinder UI_BINDER = GWT.create(HelloWorldViewImplUiBinder.class); + + @UiField + FlowPanel helloWorldPanel; + + @Inject + public HelloWorldViewImpl(PartStackUIResources resources) { + super(resources); + setContentWidget(UI_BINDER.createAndBindUi(this)); + } + + @Override + public void sayHello(String content) { + HelloWorldViewOverlay.sayHello(helloWorldPanel.getElement(), content); + helloWorldPanel.setVisible(true); + } + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.ui.xml b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.ui.xml new file mode 100644 index 000000000000..f70d234b60ef --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.ui.xml @@ -0,0 +1,34 @@ + + + + + + + + @eval outputBackgroundColor org.eclipse.che.ide.api.theme.Style.theme.outputBackgroundColor(); + + .helloWorldPanel { + width: 100%; + height: 100%; + overflow: hidden; + background-color: outputBackgroundColor; + } + + + + + + + diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewPresenter.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewPresenter.java new file mode 100644 index 000000000000..daaf92e16d2d --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewPresenter.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.view; + +import com.google.gwt.core.client.Callback; +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.ScriptInjector; +import com.google.gwt.user.client.ui.AcceptsOneWidget; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.mvp.View; +import org.eclipse.che.ide.api.parts.base.BasePresenter; +import org.eclipse.che.ide.util.loging.Log; +import org.eclipse.che.plugin.embedjsexample.ide.HelloWorldResources; +import org.eclipse.che.plugin.embedjsexample.ide.common.Constants; +import org.vectomatic.dom.svg.ui.SVGResource; + +/** + * @author Mathias Schaefer + */ +@Singleton +public class HelloWorldViewPresenter extends BasePresenter implements HelloWorldView.ActionDelegate { + + private final HelloWorldView helloWorldView; + + @Inject + public HelloWorldViewPresenter(final HelloWorldView helloWorldView) { + this.helloWorldView = helloWorldView; + + ScriptInjector.fromUrl(GWT.getModuleBaseURL() + Constants.JAVASCRIPT_FILE_ID) + .setWindow(ScriptInjector.TOP_WINDOW) + .setCallback(new Callback() { + @Override + public void onSuccess(final Void result) { + Log.info(HelloWorldViewPresenter.class, Constants.JAVASCRIPT_FILE_ID + " loaded."); + sayHello("Hello from Java Script!"); + } + + @Override + public void onFailure(final Exception e) { + Log.error(HelloWorldViewPresenter.class, "Unable to load "+Constants.JAVASCRIPT_FILE_ID, e); + } + }).inject(); + + } + + private void sayHello(String content) { + this.helloWorldView.sayHello(content); + } + + @Override + public String getTitle() { + return "Hello world"; + } + + @Override + public SVGResource getTitleImage() { + return (HelloWorldResources.INSTANCE.icon()); + } + + @Override + public void setVisible(boolean visible) { + helloWorldView.setVisible(visible); + } + + @Override + public View getView() { + return helloWorldView; + } + + @Override + public String getTitleToolTip() { + return getTitle(); + } + + @Override + public void go(AcceptsOneWidget container) { + container.setWidget(helloWorldView); + } +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/client/jso/HelloWorldViewOverlay.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/client/jso/HelloWorldViewOverlay.java new file mode 100644 index 000000000000..ee3a9a8d94fd --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/client/jso/HelloWorldViewOverlay.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.view.client.jso; + +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.dom.client.Element; + +/** + * JavaScript overlay to demonstrate a global js function call + * + * @author Mathias Schaefer + */ +public class HelloWorldViewOverlay extends JavaScriptObject { + + protected HelloWorldViewOverlay() { + } + + public final static native void sayHello(final Element element, String message) /*-{ + new $wnd.HelloWorld(element, message); + }-*/; + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/EmbedJSExample.gwt.xml b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/EmbedJSExample.gwt.xml new file mode 100644 index 000000000000..cbc6c91e7ef4 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/EmbedJSExample.gwt.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/ide/svg/icon.svg b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/ide/svg/icon.svg new file mode 100644 index 000000000000..ba2158499113 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/ide/svg/icon.svg @@ -0,0 +1,48 @@ + + + + {} + + diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/public/helloworld.js b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/public/helloworld.js new file mode 100644 index 000000000000..af119c6d05ab --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/public/helloworld.js @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + */ +function HelloWorld( + element, contents) { + element.textContent = contents; +}; + diff --git a/samples/sample-plugin-embedjs/pom.xml b/samples/sample-plugin-embedjs/pom.xml new file mode 100644 index 000000000000..964a92c0eedd --- /dev/null +++ b/samples/sample-plugin-embedjs/pom.xml @@ -0,0 +1,28 @@ + + + + 4.0.0 + + che-sample-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + ../pom.xml + + che-sample-plugin-embedjs-parent + pom + Che Sample :: Plugin Embed JavaScript :: Parent + + che-sample-plugin-embedjs-ide + + diff --git a/samples/sample-plugin-json/che-sample-plugin-json-ide/pom.xml b/samples/sample-plugin-json/che-sample-plugin-json-ide/pom.xml index a722eadd9f1f..2d96f8e0971e 100644 --- a/samples/sample-plugin-json/che-sample-plugin-json-ide/pom.xml +++ b/samples/sample-plugin-json/che-sample-plugin-json-ide/pom.xml @@ -22,6 +22,10 @@ jar Che Sample :: Plugin JSON :: IDE + + com.google.guava + guava + com.google.gwt.inject gin @@ -42,14 +46,6 @@ javax.validation validation-api - - org.eclipse.che.core - che-core-api-workspace - - - org.eclipse.che.core - che-core-api-workspace-shared - org.eclipse.che.core che-core-commons-annotations @@ -90,6 +86,7 @@ + org.apache.maven.plugins maven-dependency-plugin @@ -97,15 +94,14 @@ analyze - true + + org.eclipse.che.core:che-core-ide-app + org.eclipse.che.sample:che-sample-plugin-json-shared + - - org.apache.maven.plugins - maven-surefire-plugin - diff --git a/samples/sample-plugin-json/che-sample-plugin-json-ide/src/main/java/org/eclipse/che/plugin/jsonexample/ide/action/JsonExampleProjectAction.java b/samples/sample-plugin-json/che-sample-plugin-json-ide/src/main/java/org/eclipse/che/plugin/jsonexample/ide/action/JsonExampleProjectAction.java index b5f9be779cbf..9065390c21d3 100644 --- a/samples/sample-plugin-json/che-sample-plugin-json-ide/src/main/java/org/eclipse/che/plugin/jsonexample/ide/action/JsonExampleProjectAction.java +++ b/samples/sample-plugin-json/che-sample-plugin-json-ide/src/main/java/org/eclipse/che/plugin/jsonexample/ide/action/JsonExampleProjectAction.java @@ -18,7 +18,7 @@ import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; -import org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective; +import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID; import org.vectomatic.dom.svg.ui.SVGResource; import javax.validation.constraints.NotNull; @@ -49,7 +49,7 @@ public JsonExampleProjectAction(AppContext appContext, @NotNull String text, @NotNull String description, @Nullable SVGResource svgResource) { - super(Collections.singletonList(ProjectPerspective.PROJECT_PERSPECTIVE_ID), + super(Collections.singletonList(PROJECT_PERSPECTIVE_ID), text, description, null, diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/pom.xml b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/pom.xml new file mode 100644 index 000000000000..f0af27f22c1f --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + che-sample-plugin-nativeaccess-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-nativeaccess-ide + jar + Che Sample :: Plugin Native Access :: IDE + + + com.google.inject + guice + + + javax.validation + validation-api + + + org.eclipse.che.core + che-core-api-machine-shared + + + org.eclipse.che.core + che-core-api-model + + + org.eclipse.che.core + che-core-commons-gwt + + + org.eclipse.che.core + che-core-ide-api + + + com.google.gwt + gwt-user + provided + + + com.google.gwt + gwt-dev + test + + + com.google.gwt.gwtmockito + gwtmockito + test + + + junit + junit + test + + + org.mockito + mockito-core + test + + + + + + src/main/java + + + src/main/resources + + + + diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/NativeAccessExampleExtension.java b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/NativeAccessExampleExtension.java new file mode 100644 index 000000000000..1ab6895e0eb5 --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/NativeAccessExampleExtension.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nativeaccessexample.ide; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.ActionManager; +import org.eclipse.che.ide.api.action.DefaultActionGroup; +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.plugin.nativeaccessexample.ide.action.RunNativeCommandAction; + +/** + * Native access example extension which registers exactly one sample action. + * + * @author Mathias Schaefer + */ +@Extension(title = "Native access example") +@Singleton +public class NativeAccessExampleExtension { + + @Inject + private void configureActions(final ActionManager actionManager, + final RunNativeCommandAction runNativenCommandAction) { + + DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup)actionManager.getAction("resourceOperation"); + DefaultActionGroup naGroup = new DefaultActionGroup("Native Access Example", true, actionManager); + mainContextMenuGroup.add(naGroup); + + actionManager.registerAction(runNativenCommandAction.ACTION_ID, runNativenCommandAction); + naGroup.addAction(runNativenCommandAction); + } + +} diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/action/RunNativeCommandAction.java b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/action/RunNativeCommandAction.java new file mode 100644 index 000000000000..0c0526ea2c60 --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/action/RunNativeCommandAction.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nativeaccessexample.ide.action; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.Action; +import org.eclipse.che.ide.api.action.ActionEvent; +import org.eclipse.che.ide.util.loging.Log; +import org.eclipse.che.plugin.nativeaccessexample.machine.client.command.CommandManager; + +/** + * Action for opening a part which embeds javascript code. + */ +@Singleton +public class RunNativeCommandAction extends Action { + + public final static String ACTION_ID = "runNativeCommandSAction"; + + private CommandManager commandManager; + + @Inject + public RunNativeCommandAction(CommandManager commandManager) { + super("Run native command demo"); + this.commandManager = commandManager; + } + + @Override + public void actionPerformed(ActionEvent e) { + Log.warn(getClass(), "Executing native command..."); + commandManager.execute("cd && touch che-was-here"); + } + +} diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/machine/client/command/CommandManager.java b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/machine/client/command/CommandManager.java new file mode 100644 index 000000000000..a25bfa68c7ae --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/machine/client/command/CommandManager.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nativeaccessexample.machine.client.command; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.api.core.model.machine.Machine; +import org.eclipse.che.api.machine.shared.dto.CommandDto; +import org.eclipse.che.api.machine.shared.dto.MachineProcessDto; +import org.eclipse.che.api.promises.client.Operation; +import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.machine.MachineServiceClient; +import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.dto.DtoFactory; +import org.eclipse.che.ide.util.UUID; + +import javax.validation.constraints.NotNull; + +/** + * Simple command manager which allows to run native commands within the workspace Docker container. + * Please note that the actual call is delegated to the MachineServiceClient service. + * + * @author Mathias Schaefer + */ +@Singleton +public class CommandManager { + + private final DtoFactory dtoFactory; + private final MachineServiceClient machineServiceClient; + private final NotificationManager notificationManager; + private final AppContext appContext; + + @Inject + public CommandManager(DtoFactory dtoFactory, MachineServiceClient machineServiceClient, NotificationManager notificationManager, AppContext appContext) { + this.dtoFactory = dtoFactory; + this.machineServiceClient = machineServiceClient; + this.notificationManager = notificationManager; + this.appContext = appContext; + } + + /** + * Execute the the given command command within the workspace Docker container. + */ + public void execute(String commandLine) { + final Machine machine = appContext.getDevMachine().getDescriptor(); + if (machine == null) { + return; + } + String workspaceID = appContext.getWorkspaceId(); + String machineID = machine.getId(); + final CommandDto command = dtoFactory.createDto(CommandDto.class) + .withName("some-command") + .withCommandLine(commandLine) + .withType("arbitrary-type"); + final String outputChannel = "process:output:" + UUID.uuid(); + executeCommand(command, workspaceID, machineID, outputChannel); + } + + public void executeCommand(final CommandDto command, @NotNull final String workspaceID, @NotNull final String machineID, String outputChannel) { + final Promise processPromise = machineServiceClient.executeCommand(workspaceID, machineID, command, outputChannel); + processPromise.then(new Operation() { + @Override + public void apply(MachineProcessDto process) throws OperationException + { + //Do nothing in this example + } + + }); + + } +} diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/resources/org/eclipse/che/plugin/nativeaccessexample/NativeAccessExample.gwt.xml b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/resources/org/eclipse/che/plugin/nativeaccessexample/NativeAccessExample.gwt.xml new file mode 100644 index 000000000000..309970144658 --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/resources/org/eclipse/che/plugin/nativeaccessexample/NativeAccessExample.gwt.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/sample-plugin-nativeaccess/pom.xml b/samples/sample-plugin-nativeaccess/pom.xml new file mode 100644 index 000000000000..1e0be8ba6183 --- /dev/null +++ b/samples/sample-plugin-nativeaccess/pom.xml @@ -0,0 +1,28 @@ + + + + 4.0.0 + + che-sample-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + ../pom.xml + + che-sample-plugin-nativeaccess-parent + pom + Che Sample :: Plugin Native Access :: Parent + + che-sample-plugin-nativeaccess-ide + + diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/pom.xml b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/pom.xml new file mode 100644 index 000000000000..346f7bc6c692 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + + che-sample-plugin-parts-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-parts-ide + jar + Che Sample :: Plugin Parts :: IDE + + + com.google.gwt.inject + gin + + + com.google.inject + guice + + + org.eclipse.che.core + che-core-ide-api + + + org.vectomatic + lib-gwt-svg + + + com.google.gwt + gwt-user + provided + + + + + + src/main/java + + + src/main/resources + + + + diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsExtension.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsExtension.java new file mode 100644 index 000000000000..9d13ab79fd88 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsExtension.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide; + +import com.google.inject.Inject; + +import org.eclipse.che.ide.api.action.ActionManager; +import org.eclipse.che.ide.api.action.DefaultActionGroup; +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.plugin.parts.ide.helloworldview.HelloWorldViewAction; + +import static org.eclipse.che.ide.api.action.IdeActions.GROUP_MAIN_MENU; + +/** + * Extension that defines a simple view containing a 'Hello World' label. + * + * @author Edgar Mueller + */ +@Extension(title = "Sample Parts Extension") +public class SamplePartsExtension { + + /** + * Constructor. + * + * @param actionManager the {@link ActionManager} that is used to register the action + * @param action the {@link HelloWorldViewAction} that display the sample view + */ + @Inject + public SamplePartsExtension(ActionManager actionManager, HelloWorldViewAction action){ + actionManager.registerAction("helloWorldViewAction",action); + DefaultActionGroup mainMenu = (DefaultActionGroup)actionManager.getAction(GROUP_MAIN_MENU); + + DefaultActionGroup sampleActionGroup = new DefaultActionGroup("Sample Action", true, actionManager); + sampleActionGroup.add(action); + + mainMenu.add(sampleActionGroup); + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsResources.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsResources.java new file mode 100644 index 000000000000..3c9d6fedfc1a --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsResources.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; + +import org.vectomatic.dom.svg.ui.SVGResource; + +/** + * Resources for the Sample Parts extension. + * + * @author Edgar Mueller + */ +public interface SamplePartsResources extends ClientBundle { + + /** + * Singleton instance. + */ + SamplePartsResources INSTANCE = GWT.create(SamplePartsResources.class); + + /** + * Declares an icon. + * + * @return the icon + */ + @Source("icons/my.svg") + SVGResource icon(); +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldPresenter.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldPresenter.java new file mode 100644 index 000000000000..9637122af1f4 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldPresenter.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ + +package org.eclipse.che.plugin.parts.ide.helloworldview; +import com.google.gwt.user.client.ui.AcceptsOneWidget; +import com.google.gwt.user.client.ui.IsWidget; +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.parts.base.BasePresenter; +import org.eclipse.che.plugin.parts.ide.SamplePartsResources; +import org.vectomatic.dom.svg.ui.SVGResource; + +/** + * Presenter for the sample Hello World View. + * + * @author Edgar Mueller + */ +@Singleton +public class HelloWorldPresenter extends BasePresenter { + + private HelloWorldView view; + + @Inject + public HelloWorldPresenter(HelloWorldView view){ + this.view = view; + } + + @Override + public String getTitle() { + return "Hello World View"; + } + + @Override + public void setVisible(boolean visible) { + view.setVisible(visible); + } + + @Override + public SVGResource getTitleImage() { + return (SamplePartsResources.INSTANCE.icon()); + } + + @Override + public IsWidget getView() { + return view; + } + + @Override + public String getTitleToolTip() { + return "Hello World Tooltip"; + } + + @Override + public void go(AcceptsOneWidget container) { + container.setWidget(view); + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldView.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldView.java new file mode 100644 index 000000000000..6e3bebcd6abf --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldView.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide.helloworldview; + + +import org.eclipse.che.ide.api.mvp.View; +import org.eclipse.che.ide.api.parts.base.BaseActionDelegate; + +/** + * Simple view only containing a label. + * + * @author Edgar Mueller + */ +public interface HelloWorldView extends View { + + /** + * Make this view visible. + * + * @param visible whether the view is visible + */ + void setVisible(boolean visible); + + /** + * Empty action delegate. + */ + interface ActionDelegate extends BaseActionDelegate { + + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewAction.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewAction.java new file mode 100644 index 000000000000..711647c7d248 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewAction.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide.helloworldview; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.Action; +import org.eclipse.che.ide.api.action.ActionEvent; +import org.eclipse.che.ide.api.parts.PartStackType; +import org.eclipse.che.ide.api.parts.WorkspaceAgent; + +/** + * Action for showing the Hello World View. + * + * @author Edgar Mueller + */ +@Singleton +public class HelloWorldViewAction extends Action { + + private WorkspaceAgent workspaceAgent; + private HelloWorldPresenter helloWorldPresenter; + + /** + * Constructor. + * + * @param workspaceAgent the {@link WorkspaceAgent} that will open our sample part + * @param helloWorldPresenter the {@link HelloWorldPresenter} displaying the view + * + */ + @Inject + public HelloWorldViewAction(WorkspaceAgent workspaceAgent, HelloWorldPresenter helloWorldPresenter) { + super("Show Hello World View"); + this.workspaceAgent = workspaceAgent; + this.helloWorldPresenter = helloWorldPresenter; + } + + + @Override + public void actionPerformed(ActionEvent e) { + workspaceAgent.openPart(helloWorldPresenter, PartStackType.INFORMATION); + workspaceAgent.setActivePart(helloWorldPresenter); + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewImpl.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewImpl.java new file mode 100644 index 000000000000..1d81df254853 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewImpl.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide.helloworldview; + +import com.google.gwt.user.client.ui.Label; +import com.google.inject.Inject; + +import org.eclipse.che.ide.api.parts.PartStackUIResources; +import org.eclipse.che.ide.api.parts.base.BaseView; + +/** + * Implementation class of the {@link HelloWorldView}. + * + * @author Edgar Mueller + */ +public class HelloWorldViewImpl extends BaseView implements HelloWorldView { + + /** + * Constructor. + * + * @param resources the {@link PartStackUIResources} + */ + @Inject + public HelloWorldViewImpl(PartStackUIResources resources){ + super(resources); + Label label = new Label("Hello World"); + setContentWidget(label); + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/inject/MyGinModule.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/inject/MyGinModule.java new file mode 100644 index 000000000000..3eb24f3c87d2 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/inject/MyGinModule.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide.inject; + +import com.google.gwt.inject.client.AbstractGinModule; + +import org.eclipse.che.ide.api.extension.ExtensionGinModule; +import org.eclipse.che.plugin.parts.ide.helloworldview.HelloWorldView; +import org.eclipse.che.plugin.parts.ide.helloworldview.HelloWorldViewImpl; + +/** + * Gin module binding the {@link HelloWorldView} to the {@link HelloWorldViewImpl} implementation class. + * + * @author Edgar Mueller + */ +@ExtensionGinModule +public class MyGinModule extends AbstractGinModule { + + @Override + protected void configure() { + bind(HelloWorldView.class).to(HelloWorldViewImpl.class); + } + +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/SampleParts.gwt.xml b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/SampleParts.gwt.xml new file mode 100644 index 000000000000..160df50f8f97 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/SampleParts.gwt.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/ide/icons/my.svg b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/ide/icons/my.svg new file mode 100644 index 000000000000..cbe1599c8aa1 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/ide/icons/my.svg @@ -0,0 +1,39 @@ + + + + my + diff --git a/samples/sample-plugin-parts/pom.xml b/samples/sample-plugin-parts/pom.xml new file mode 100644 index 000000000000..0c92e1558de4 --- /dev/null +++ b/samples/sample-plugin-parts/pom.xml @@ -0,0 +1,28 @@ + + + + 4.0.0 + + che-sample-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + ../pom.xml + + che-sample-plugin-parts-parent + pom + Che Sample :: Plugin Parts :: Parent + + che-sample-plugin-parts-ide + + diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/pom.xml b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/pom.xml new file mode 100644 index 000000000000..c6eece677734 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + + che-sample-plugin-serverservice-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-serverservice-ide + jar + Che Sample :: Plugin ServerService :: IDE + + + com.google.inject + guice + + + javax.inject + javax.inject + + + org.eclipse.che.core + che-core-commons-gwt + + + org.eclipse.che.core + che-core-ide-api + + + com.google.gwt + gwt-user + provided + + + + + + src/main/java + + + src/main/resources + + + + diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/MyServiceClient.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/MyServiceClient.java new file mode 100644 index 000000000000..e068d5c3c478 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/MyServiceClient.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ + +package org.eclipse.che.plugin.serverservice.ide; + +import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.rest.AsyncRequestFactory; +import org.eclipse.che.ide.rest.StringUnmarshaller; +import org.eclipse.che.ide.ui.loaders.request.LoaderFactory; + +import javax.inject.Inject; + +/** + * Client for consuming the sample server service. + * + * @author Edgar Mueller + */ +public class MyServiceClient { + + private AppContext appContext; + private AsyncRequestFactory asyncRequestFactory; + private LoaderFactory loaderFactory; + + /** + * Constructor. + * + * @param appContext the {@link AppContext} + * @param asyncRequestFactory the {@link AsyncRequestFactory} that is used to create requests + * @param loaderFactory the {@link LoaderFactory} for displaying a message while waiting for a response + */ + @Inject + public MyServiceClient( + final AppContext appContext, + final AsyncRequestFactory asyncRequestFactory, + final LoaderFactory loaderFactory) { + + this.appContext = appContext; + this.asyncRequestFactory = asyncRequestFactory; + this.loaderFactory = loaderFactory; + } + + /** + * Invoke the sample server service. + * + * @param name a parameter + * @return a Promise containing the server response + */ + public Promise getHello(String name) { + return asyncRequestFactory.createGetRequest(appContext.getDevMachine().getWsAgentBaseUrl() + "/hello/" + name) + .loader(loaderFactory.newLoader("Waiting for hello...")) + .send(new StringUnmarshaller()); + } + +} diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/ServerServiceExtension.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/ServerServiceExtension.java new file mode 100644 index 000000000000..997973bedfc8 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/ServerServiceExtension.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.serverservice.ide; + +import com.google.inject.Inject; + +import org.eclipse.che.ide.api.action.ActionManager; +import org.eclipse.che.ide.api.action.DefaultActionGroup; +import org.eclipse.che.ide.api.action.IdeActions; +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.plugin.serverservice.ide.action.MyAction; + +/** + * Server service extension that registers action which calls a service. + * + * @author Edgar Mueller + */ +@Extension(title = "Server Service Sample Extension", version = "0.0.1") +public class ServerServiceExtension { + + /** + * Constructor. + * + * @param actionManager + * the {@link ActionManager} that is used to register our actions + * @param myAction + * the action that calls the example server service + */ + @Inject + public ServerServiceExtension(ActionManager actionManager, MyAction myAction) { + + actionManager.registerAction("myAction", myAction); + + DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup)actionManager.getAction(IdeActions.GROUP_MAIN_CONTEXT_MENU); + mainContextMenuGroup.add(myAction); + } +} diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/action/MyAction.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/action/MyAction.java new file mode 100644 index 000000000000..97c4cfedf8d7 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/action/MyAction.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.serverservice.ide.action; + +import com.google.inject.Inject; + +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.api.action.Action; +import org.eclipse.che.ide.api.action.ActionEvent; +import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.api.notification.StatusNotification; +import org.eclipse.che.plugin.serverservice.ide.MyServiceClient; + +/** + * Actions that triggers the sample server service call. + * + * @author Edgar Mueller + */ +public class MyAction extends Action { + + private final NotificationManager notificationManager; + private final MyServiceClient serviceClient; + + /** + * Constructor. + * + * @param notificationManager the notification manager + * @param serviceClient the client that is used to create requests + */ + @Inject + public MyAction(final NotificationManager notificationManager, + final MyServiceClient serviceClient) { + super("My Action", "My Action Description"); + this.notificationManager = notificationManager; + this.serviceClient = serviceClient; + } + + @Override + public void actionPerformed(ActionEvent e) { + // This calls the service in the workspace. + // This method is in our org.eclipse.che.plugin.serverservice.ide.MyServiceClient class + // This is a Promise, so the .then() method is invoked after the response is made + serviceClient.getHello("CheTheAllPowerful!").then(new Operation() { + @Override + public void apply(String response) throws OperationException { + // This passes the response String to the notification manager. + notificationManager.notify(response, StatusNotification.Status.SUCCESS, StatusNotification.DisplayMode.FLOAT_MODE); + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError error) throws OperationException { + notificationManager.notify("Fail", StatusNotification.Status.FAIL, StatusNotification.DisplayMode.FLOAT_MODE); + } + }); + } +} diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/resources/org/eclipse/che/plugin/serverservice/ServerService.gwt.xml b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/resources/org/eclipse/che/plugin/serverservice/ServerService.gwt.xml new file mode 100644 index 000000000000..160df50f8f97 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/resources/org/eclipse/che/plugin/serverservice/ServerService.gwt.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/pom.xml b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/pom.xml new file mode 100644 index 000000000000..5e94168175e6 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + che-sample-plugin-serverservice-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-serverservice-server + Che Sample :: Plugin ServerService :: Server + + + com.google.inject + guice + + + javax.ws.rs + javax.ws.rs-api + + + org.eclipse.che.core + che-core-commons-inject + + + diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/MyService.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/MyService.java new file mode 100644 index 000000000000..399cba29ca04 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/MyService.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.serverservice; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +/** + * Example server service that greets the user. + * + * @author Edgar Mueller + */ +@Path("hello") +public class MyService { + + /** + * Returns a greeting message. + * + * @param name the parameter + * @return a greeting message + */ + @GET + @Path("{name}") + public String sayHello(@PathParam("name") String name) { + return "Hello " + name + "!"; + } +} diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/inject/ServerServiceGuiceModule.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/inject/ServerServiceGuiceModule.java new file mode 100644 index 000000000000..3c083e15e28a --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/inject/ServerServiceGuiceModule.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.serverservice.inject; + +import com.google.inject.AbstractModule; + +import org.eclipse.che.inject.DynaModule; +import org.eclipse.che.plugin.serverservice.MyService; + +/** + * Server service example Guice module for setting up a simple service. + */ +@DynaModule +public class ServerServiceGuiceModule extends AbstractModule { + + @Override + protected void configure() { + bind(MyService.class); + } +} diff --git a/samples/sample-plugin-serverservice/pom.xml b/samples/sample-plugin-serverservice/pom.xml new file mode 100644 index 000000000000..010d2529b45f --- /dev/null +++ b/samples/sample-plugin-serverservice/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + + che-sample-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + ../pom.xml + + che-sample-plugin-serverservice-parent + pom + Che Sample :: Plugin ServerService :: Parent + + che-sample-plugin-serverservice-ide + che-sample-plugin-serverservice-server + + From 0003b2324bc8b5c59d868549070bf26e195786f2 Mon Sep 17 00:00:00 2001 From: Vitalii Parfonov Date: Wed, 5 Oct 2016 18:41:00 +0300 Subject: [PATCH 23/33] che#2608: added vfs exlude filters, small vfs watcher fix, improved project tree changes detection algorithm (#2713) Signed-off-by: Dmitry Kuleshov --- ...ProjectTreeStatusNotificationReceiver.java | 9 ++- .../plugin/java/plain/server/BaseTest.java | 8 +-- .../che/plugin/maven/server/BaseTest.java | 7 +-- .../plugin/nodejs/inject/NodeJsModule.java | 19 ++++++ wsagent/che-core-api-project/pom.xml | 4 ++ .../api/project/server/ProjectApiModule.java | 39 +++++++++--- .../api/vfs/impl/file/FileTreeWatcher.java | 3 + .../detectors/ProjectTreeChangesDetector.java | 63 ++++++++++++------- .../api/project/server/WsAgentTestBase.java | 5 +- 9 files changed, 112 insertions(+), 45 deletions(-) diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/event/ng/ProjectTreeStatusNotificationReceiver.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/event/ng/ProjectTreeStatusNotificationReceiver.java index 4d55131a7ae9..9f56771f8ff6 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/event/ng/ProjectTreeStatusNotificationReceiver.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/event/ng/ProjectTreeStatusNotificationReceiver.java @@ -24,6 +24,7 @@ import javax.inject.Inject; import javax.inject.Singleton; +import java.util.Objects; import static org.eclipse.che.ide.api.resources.ResourceDelta.ADDED; import static org.eclipse.che.ide.api.resources.ResourceDelta.REMOVED; @@ -80,8 +81,12 @@ public void receive(JsonRpcRequest request) { } } - Log.debug(getClass(), "Received request\npath: " + path +"\ntype:"+ type +"\nstatus:" + status); + Log.debug(getClass(), "Received request\npath: " + path + "\ntype:" + type + "\nstatus:" + status); - appContext.getWorkspaceRoot().synchronize(new ExternalResourceDelta(Path.valueOf(path), Path.valueOf(path), status)); + if (path == null || path.isEmpty()) { + appContext.getWorkspaceRoot().synchronize(); + } else { + appContext.getWorkspaceRoot().synchronize(new ExternalResourceDelta(Path.valueOf(path), Path.valueOf(path), status)); + } } } diff --git a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/test/java/org/eclipse/che/plugin/java/plain/server/BaseTest.java b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/test/java/org/eclipse/che/plugin/java/plain/server/BaseTest.java index 5e2c9e20019e..9f243430797a 100644 --- a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/test/java/org/eclipse/che/plugin/java/plain/server/BaseTest.java +++ b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/test/java/org/eclipse/che/plugin/java/plain/server/BaseTest.java @@ -51,6 +51,8 @@ import java.util.List; import java.util.Set; +import static org.mockito.Mockito.mock; + /** * @author Valeriy Svydenko */ @@ -62,7 +64,6 @@ public abstract class BaseTest { protected ProjectRegistry projectRegistry; protected ProjectManager projectManager; protected LocalVirtualFileSystemProvider vfsProvider; - protected ProjectTreeChangesDetector projectTreeChangesDetector; @BeforeClass protected void initProjectApi() throws Exception { @@ -105,8 +106,6 @@ protected void initProjectApi() throws Exception { FileWatcherNotificationHandler fileWatcherNotificationHandler = new DefaultFileWatcherNotificationHandler(vfsProvider); FileTreeWatcher fileTreeWatcher = new FileTreeWatcher(root, new HashSet<>(), fileWatcherNotificationHandler); - projectTreeChangesDetector = new ProjectTreeChangesDetector(null); - projectManager = new ProjectManager(vfsProvider, eventService, projectTypeRegistry, @@ -115,7 +114,8 @@ protected void initProjectApi() throws Exception { importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, - new TestWorkspaceHolder(new ArrayList<>()), projectTreeChangesDetector); + new TestWorkspaceHolder(new ArrayList<>()), + mock(ProjectTreeChangesDetector.class)); ResourcesPlugin plugin = new ResourcesPlugin("target/index", wsPath, () -> projectRegistry, () -> projectManager); diff --git a/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/BaseTest.java b/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/BaseTest.java index 1893d154067f..3648d18b758e 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/BaseTest.java +++ b/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/BaseTest.java @@ -33,11 +33,11 @@ import org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider; import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; import org.eclipse.che.commons.lang.IoUtil; +import org.eclipse.che.jdt.core.resources.ResourceChangedEvent; import org.eclipse.che.plugin.java.server.projecttype.JavaProjectType; import org.eclipse.che.plugin.java.server.projecttype.JavaValueProviderFactory; import org.eclipse.che.plugin.maven.server.projecttype.MavenProjectType; import org.eclipse.che.plugin.maven.server.projecttype.MavenValueProviderFactory; -import org.eclipse.che.jdt.core.resources.ResourceChangedEvent; import org.eclipse.core.internal.filebuffers.FileBuffersPlugin; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jdt.core.JavaCore; @@ -58,6 +58,7 @@ import java.util.Set; import static org.eclipse.che.plugin.maven.shared.MavenAttributes.MAVEN_ID; +import static org.mockito.Mockito.mock; /** * @author Evgen Vidolob @@ -87,7 +88,6 @@ public abstract class BaseTest { protected ProjectHandlerRegistry projectHandlerRegistry; protected ProjectImporterRegistry importerRegistry; protected MavenServerManager mavenServerManager; - protected ProjectTreeChangesDetector projectTreeChangesDetector; public BaseTest() { options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); @@ -146,11 +146,10 @@ protected void initProjectApi() throws Exception { fileWatcherNotificationHandler = new DefaultFileWatcherNotificationHandler(vfsProvider); fileTreeWatcher = new FileTreeWatcher(root, new HashSet<>(), fileWatcherNotificationHandler); - projectTreeChangesDetector = new ProjectTreeChangesDetector(null); pm = new ProjectManager(vfsProvider, eventService, projectTypeRegistry, projectRegistry, projectHandlerRegistry, importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, new TestWorkspaceHolder(new ArrayList<>()), - projectTreeChangesDetector); + mock(ProjectTreeChangesDetector.class)); plugin = new ResourcesPlugin("target/index", wsPath, () -> projectRegistry, () -> pm); diff --git a/plugins/plugin-nodejs/che-plugin-nodejs-lang-server/src/main/java/org/eclipse/che/plugin/nodejs/inject/NodeJsModule.java b/plugins/plugin-nodejs/che-plugin-nodejs-lang-server/src/main/java/org/eclipse/che/plugin/nodejs/inject/NodeJsModule.java index f6815ce822e4..fd20a250290c 100644 --- a/plugins/plugin-nodejs/che-plugin-nodejs-lang-server/src/main/java/org/eclipse/che/plugin/nodejs/inject/NodeJsModule.java +++ b/plugins/plugin-nodejs/che-plugin-nodejs-lang-server/src/main/java/org/eclipse/che/plugin/nodejs/inject/NodeJsModule.java @@ -12,6 +12,7 @@ import com.google.inject.AbstractModule; import com.google.inject.multibindings.Multibinder; +import com.google.inject.name.Names; import org.eclipse.che.api.project.server.handlers.ProjectHandler; import org.eclipse.che.api.project.server.type.ProjectTypeDef; @@ -19,6 +20,9 @@ import org.eclipse.che.plugin.nodejs.generator.NodeJsProjectGenerator; import org.eclipse.che.plugin.nodejs.projecttype.NodeJsProjectType; +import java.nio.file.Path; +import java.nio.file.PathMatcher; + import static com.google.inject.multibindings.Multibinder.newSetBinder; /** @@ -34,5 +38,20 @@ protected void configure() { Multibinder projectHandlerMultibinder = newSetBinder(binder(), ProjectHandler.class); projectHandlerMultibinder.addBinding().to(NodeJsProjectGenerator.class); + + configureVfsExcludeFilter(); + } + + private void configureVfsExcludeFilter() { + newSetBinder(binder(), PathMatcher.class, Names.named("vfs.index_filter_matcher")) + .addBinding() + .toInstance(path -> { + for (Path pathElement : path) { + if (pathElement == null || "node_modules".equals(pathElement.toString())) { + return true; + } + } + return false; + }); } } diff --git a/wsagent/che-core-api-project/pom.xml b/wsagent/che-core-api-project/pom.xml index ee871b2b8b32..d8b679e460f5 100644 --- a/wsagent/che-core-api-project/pom.xml +++ b/wsagent/che-core-api-project/pom.xml @@ -115,6 +115,10 @@ org.eclipse.che.core che-core-commons-lang + + org.eclipse.che.core + che-core-commons-schedule + org.eclipse.che.core wsagent-local diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java index 1fe764f4f91a..0219c47e2e6d 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java @@ -41,8 +41,11 @@ import org.eclipse.che.api.vfs.search.SearcherProvider; import org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider; +import java.nio.file.Path; import java.nio.file.PathMatcher; +import static com.google.inject.multibindings.Multibinder.newSetBinder; + /** * Guice module contains configuration of Project API components. * @@ -54,12 +57,12 @@ public class ProjectApiModule extends AbstractModule { @Override protected void configure() { - Multibinder projectImportersMultibinder = Multibinder.newSetBinder(binder(), ProjectImporter.class); + Multibinder projectImportersMultibinder = newSetBinder(binder(), ProjectImporter.class); projectImportersMultibinder.addBinding().to(ZipProjectImporter.class); - Multibinder.newSetBinder(binder(), ProjectTypeDef.class).addBinding().to(BaseProjectType.class); + newSetBinder(binder(), ProjectTypeDef.class).addBinding().to(BaseProjectType.class); - Multibinder projectHandlersMultibinder = Multibinder.newSetBinder(binder(), ProjectHandler.class); + Multibinder projectHandlersMultibinder = newSetBinder(binder(), ProjectHandler.class); projectHandlersMultibinder.addBinding().to(CreateBaseProjectTypeHandler.class); projectHandlersMultibinder.addBinding().to(InitBaseProjectTypeHandler.class); @@ -71,30 +74,46 @@ protected void configure() { bind(WorkspaceProjectsSyncer.class).to(WorkspaceHolder.class); // configure VFS - Multibinder filtersMultibinder = Multibinder.newSetBinder(binder(), - VirtualFileFilter.class, - Names.named("vfs.index_filter")); + Multibinder filtersMultibinder = + newSetBinder(binder(), VirtualFileFilter.class, Names.named("vfs.index_filter")); + filtersMultibinder.addBinding().to(MediaTypeFilter.class); - Multibinder pathMatcherMultibinder = Multibinder.newSetBinder(binder(), - PathMatcher.class, - Names.named("vfs.index_filter_matcher")); + Multibinder excludeMatcher = newSetBinder(binder(), PathMatcher.class, Names.named("vfs.index_filter_matcher")); bind(SearcherProvider.class).to(FSLuceneSearcherProvider.class); bind(VirtualFileSystemProvider.class).to(LocalVirtualFileSystemProvider.class); bind(FileWatcherNotificationHandler.class).to(DefaultFileWatcherNotificationHandler.class); + configureVfsFilters(excludeMatcher); configureVfsEvent(); } + private void configureVfsFilters(Multibinder excludeMatcher) { + addVfsFilter(excludeMatcher, ".che"); + addVfsFilter(excludeMatcher, ".codenvy"); + addVfsFilter(excludeMatcher, ".#"); + } + + private void addVfsFilter(Multibinder excludeMatcher, String filter) { + excludeMatcher.addBinding().toInstance(path -> { + for (Path pathElement : path) { + if (pathElement == null || filter.equals(pathElement.toString())) { + return true; + } + } + return false; + }); + } + private void configureVfsEvent() { bind(LoEventListener.class); bind(LoEventService.class); bind(HiEventService.class); Multibinder> highLevelVfsEventDetectorMultibinder = - Multibinder.newSetBinder(binder(), new TypeLiteral>() { + newSetBinder(binder(), new TypeLiteral>() { }); highLevelVfsEventDetectorMultibinder.addBinding().to(FileStatusDetector.class); diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/FileTreeWatcher.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/FileTreeWatcher.java index 06793f4d271f..9f7e99583317 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/FileTreeWatcher.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/FileTreeWatcher.java @@ -278,6 +278,9 @@ private void processPendingEvents(Collection pendingEvents) throws for (PendingEvent pendingEvent : pendingEvents) { Path eventDirectoryPath = pendingEvent.getPath(); WatchedDirectory watchedDirectory = watchedDirectories.get(eventDirectoryPath); + if (watchedDirectory == null){ + continue; + } if (Files.exists(eventDirectoryPath)) { boolean isModifiedNotYetReported = true; diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/event/detectors/ProjectTreeChangesDetector.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/event/detectors/ProjectTreeChangesDetector.java index f4599a77e007..50eda5474ad2 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/event/detectors/ProjectTreeChangesDetector.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/event/detectors/ProjectTreeChangesDetector.java @@ -19,6 +19,7 @@ import org.eclipse.che.api.vfs.impl.file.event.EventTreeNode; import org.eclipse.che.api.vfs.impl.file.event.HiEvent; import org.eclipse.che.api.vfs.impl.file.event.HiEventDetector; +import org.eclipse.che.commons.schedule.executor.ThreadPullLauncher; import org.slf4j.Logger; import javax.annotation.PostConstruct; @@ -28,7 +29,9 @@ import java.util.Optional; import java.util.Set; -import static java.util.stream.Collectors.toSet; +import static java.lang.Math.min; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; import static org.eclipse.che.dto.server.DtoFactory.newDto; import static org.slf4j.LoggerFactory.getLogger; @@ -41,17 +44,34 @@ public class ProjectTreeChangesDetector implements HiEventDetector trees = new HashSet<>(); private State state; @Inject - public ProjectTreeChangesDetector(JsonRpcRequestTransmitter transmitter) { + public ProjectTreeChangesDetector(JsonRpcRequestTransmitter transmitter, ThreadPullLauncher launcher) { this.transmitter = transmitter; + this.launcher = launcher; + } + + public static String findLongestPrefix(String s1, String s2) { + if (s1 == null) { + return s2; + } + + for (int i = min(s1.length(), s2.length()); ; i--) { + if (s2.startsWith(s1.substring(0, i))) { + return s1.substring(0, i); + } + } } @PostConstruct public void postConstruct() { this.state = State.RESUMED; + launcher.scheduleWithFixedDelay(this::transmit, 20_000L, 1_500L, MILLISECONDS); } public void suspend() { @@ -73,33 +93,30 @@ public void resume() { @Override public Optional> detect(EventTreeNode eventTreeNode) { - if (!eventTreeNode.isRoot() || eventTreeNode.getChildren().isEmpty()) { - return Optional.empty(); + if (eventTreeNode.isRoot() && !eventTreeNode.getChildren().isEmpty()) { + trees.add(eventTreeNode); } - if (state == State.RESUMED) { - final Set directories = new HashSet<>(); - - for (EventTreeNode candidateDir : eventTreeNode.stream() - .filter(EventTreeNode::modificationOccurred) - .filter(EventTreeNode::isDir) - .collect(toSet())) { - directories.removeIf(dir -> dir.getPath().contains(candidateDir.getPath())); - - if (directories.stream().noneMatch(dir -> candidateDir.getPath().contains(dir.getPath()))) { - directories.add(candidateDir); - } - } + return Optional.empty(); + } - for (EventTreeNode node : directories) { - final String path = node.getPath(); - final FileWatcherEventType lastEventType = node.getLastEventType(); + private void transmit() { + if (state == State.SUSPENDED) { + return; + } - transmit(path, lastEventType); - } + final Optional commonSubstring = trees.stream() + .flatMap(EventTreeNode::stream) + .filter(EventTreeNode::modificationOccurred) + .map(EventTreeNode::getPath) + .reduce(ProjectTreeChangesDetector::findLongestPrefix); + if (commonSubstring.isPresent()) { + final String s = commonSubstring.get(); + final String path = s.substring(0, s.lastIndexOf('/')); + transmit(path, FileWatcherEventType.MODIFIED); } - return Optional.empty(); + trees.clear(); } private void transmit(String path, FileWatcherEventType type) { diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/WsAgentTestBase.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/WsAgentTestBase.java index 3b42ff414872..34bc7bfc7c56 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/WsAgentTestBase.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/WsAgentTestBase.java @@ -44,6 +44,8 @@ import java.util.Map; import java.util.Set; +import static org.mockito.Mockito.mock; + /** * @author gazarenkov */ @@ -120,11 +122,10 @@ public void setUp() throws Exception { TestWorkspaceHolder wsHolder = new TestWorkspaceHolder(); - projectTreeChangesDetector = new ProjectTreeChangesDetector(null); pm = new ProjectManager(vfsProvider, eventService, projectTypeRegistry, projectRegistry, projectHandlerRegistry, importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, wsHolder, - projectTreeChangesDetector); + mock(ProjectTreeChangesDetector.class)); pm.initWatcher(); } From 045e32a564727128cb8e2cb29332bdca46fc6899 Mon Sep 17 00:00:00 2001 From: RomanNikitenko Date: Wed, 5 Oct 2016 21:40:03 +0300 Subject: [PATCH 24/33] =?UTF-8?q?CHE-2702.=20Fix=20displaying=20of=20termi?= =?UTF-8?q?nal=20and=20ws=20agent=20logs=20at=20starting/re=E2=80=A6=20(#2?= =?UTF-8?q?715)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * CHE-2702. Fix displaying of terminal and ws agent logs at starting/restarting workspace Signed-off-by: Roman Nikitenko --- .../panel/ProcessesPanelPresenter.java | 18 +++++++- .../panel/ProcessesPanelPresenterTest.java | 43 +++++++++++++++++-- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java index 37462c1ff652..d3f602ff1593 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java @@ -657,10 +657,23 @@ private MachineEntity getMachine(@NotNull String machineId) { } @Override + //TODO: need to improve this method. Avoid duplicate for(;;). + //Then we get output form machine it must be added to process tree already. public void onEnvironmentOutputEvent(EnvironmentOutputEvent event) { + final String content = event.getContent(); + final String machineName = event.getMachineName(); for (ProcessTreeNode machineNode : machineNodes.values()) { - if (machineNode.getName().equals(event.getMachineName())) { - printMachineOutput(machineNode.getId(), event.getContent()); + if (machineName.equals(machineNode.getName())) { + printMachineOutput(machineNode.getId(), content); + return; + } + } + + final List machines = getMachines(appContext.getWorkspace()); + for (MachineEntity machineEntity : machines) { + if (machineName.equals(machineEntity.getDisplayName())) { + ProcessTreeNode machineNode = addMachineNode(machineEntity); + printMachineOutput(machineNode.getId(), content); } } } @@ -707,6 +720,7 @@ public void onWorkspaceStopped(WorkspaceStoppedEvent event) { rootNode.getChildren().clear(); rootNodes.clear(); + machineNodes.clear(); view.clear(); view.selectNode(null); diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenterTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenterTest.java index f79f855fa88b..f7a4a7045a21 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenterTest.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenterTest.java @@ -38,6 +38,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode; import org.eclipse.che.ide.api.outputconsole.OutputConsole; import org.eclipse.che.ide.api.parts.WorkspaceAgent; +import org.eclipse.che.ide.api.workspace.event.EnvironmentOutputEvent; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; import org.eclipse.che.ide.extension.machine.client.MachineResources; @@ -86,6 +87,7 @@ @RunWith(GwtMockitoTestRunner.class) public class ProcessesPanelPresenterTest { private static final String MACHINE_ID = "machineID"; + private static final String MACHINE_NAME = "machineName"; private static final String WORKSPACE_ID = "workspaceID"; private static final String PROCESS_ID = "processID"; private static final String PROCESS_NAME = "processName"; @@ -181,10 +183,10 @@ public void shouldAddMachineWhenMachineCreating() throws Exception { MachineEntity machine = mock(MachineEntity.class); MachineConfigDto machineConfigDto = mock(MachineConfigDto.class); OutputConsole outputConsole = mock(OutputConsole.class); - when(machineConfigDto.getName()).thenReturn("machine_name"); + when(machineConfigDto.getName()).thenReturn(MACHINE_NAME); when(machine.getConfig()).thenReturn(machineConfigDto); when(appContext.getWorkspaceId()).thenReturn(WORKSPACE_ID); - when(commandConsoleFactory.create(eq("machine_name"))).thenReturn(outputConsole); + when(commandConsoleFactory.create(eq(MACHINE_NAME))).thenReturn(outputConsole); MachineStateEvent machineStateEvent = mock(MachineStateEvent.class); when(machineStateEvent.getMachine()).thenReturn(machine); @@ -197,7 +199,7 @@ public void shouldAddMachineWhenMachineCreating() throws Exception { acceptsOneWidgetCaptor.getValue().setWidget(widget); verify(workspaceAgent).setActivePart(anyObject()); - verify(commandConsoleFactory).create(eq("machine_name")); + verify(commandConsoleFactory).create(eq(MACHINE_NAME)); verify(view).addWidget(anyString(), anyString(), anyObject(), anyObject(), anyBoolean()); verify(view).setProcessesData(eq(presenter.rootNode)); } @@ -587,7 +589,7 @@ public void testGo() throws Exception { } @Test - public void commandShouldBeRestoredWheWsAgentIsStarted() throws Exception { + public void commandShouldBeRestoredWhenWsAgentIsStarted() throws Exception { WsAgentStateEvent event = mock(WsAgentStateEvent.class); CommandConfigurationFactory commandConfigurationFactory = mock(CommandConfigurationFactory.class); CommandConfiguration commandConfiguration = mock(CommandConfiguration.class); @@ -634,4 +636,37 @@ public void commandShouldBeRestoredWheWsAgentIsStarted() throws Exception { verify(outputConsole).listenToOutput(eq(OUTPUT_CHANNEL)); verify(outputConsole).attachToProcess(machineProcessDto); } + + @Test + public void shouldCreateMachineNodeToPrintWsAgentOutput() throws Exception { + EnvironmentOutputEvent event = mock(EnvironmentOutputEvent.class); + when(event.getMachineName()).thenReturn(MACHINE_NAME); + + MachineEntity machineEntity = mock(MachineEntity.class); + MachineDto machine = mock(MachineDto.class); + when(entityFactory.createMachine(machine)).thenReturn(machineEntity); + when(machineEntity.getDisplayName()).thenReturn(MACHINE_NAME); + when(machineEntity.getId()).thenReturn(MACHINE_ID); + when(machineEntity.getWorkspaceId()).thenReturn(WORKSPACE_ID); + MachineConfigDto machineConfigDto = mock(MachineConfigDto.class); + when(machineEntity.getConfig()).thenReturn(machineConfigDto); + when(machineConfigDto.isDev()).thenReturn(true); + List machines = new ArrayList<>(2); + machines.add(machine); + when(workspaceRuntime.getMachines()).thenReturn(machines); + OutputConsole outputConsole = mock(OutputConsole.class); + when(machineConfigDto.getName()).thenReturn(MACHINE_NAME); + when(appContext.getWorkspaceId()).thenReturn(WORKSPACE_ID); + when(commandConsoleFactory.create(eq(MACHINE_NAME))).thenReturn(outputConsole); + + presenter.onEnvironmentOutputEvent(event); + + verify(outputConsole).go(acceptsOneWidgetCaptor.capture()); + IsWidget widget = mock(IsWidget.class); + acceptsOneWidgetCaptor.getValue().setWidget(widget); + + verify(commandConsoleFactory).create(eq(MACHINE_NAME)); + verify(view).addWidget(anyString(), anyString(), anyObject(), anyObject(), anyBoolean()); + verify(view).setProcessesData(eq(presenter.rootNode)); + } } From ca9aac259316403c011dda15c02968815cc00c9c Mon Sep 17 00:00:00 2001 From: Eugene Ivantsov Date: Thu, 6 Oct 2016 09:56:25 +0300 Subject: [PATCH 25/33] Remove --no-bin-links as it conflicts with the latest noce and npm version. Tests on windows 10 (no virtual box) revealed no errors --- ide/che-core-ide-templates/src/main/resources/samples.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ide/che-core-ide-templates/src/main/resources/samples.json b/ide/che-core-ide-templates/src/main/resources/samples.json index d362d74a783f..237bfbb80efa 100644 --- a/ide/che-core-ide-templates/src/main/resources/samples.json +++ b/ide/che-core-ide-templates/src/main/resources/samples.json @@ -671,7 +671,7 @@ { "name": "install dependencies", "type": "custom", - "commandLine": "cd ${current.project.path} && npm install --no-bin-links && bower install", + "commandLine": "cd ${current.project.path} && npm install && bower install", "attributes": { "previewUrl": "" } From 24a24fa919f24d97086e2f6ac3f0e0913aaca2d6 Mon Sep 17 00:00:00 2001 From: Yevhenii Voevodin Date: Thu, 6 Oct 2016 10:15:19 +0300 Subject: [PATCH 26/33] Check if workspace exists before saving snapshot (#2712) --- .../workspace/server/WorkspaceManager.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceManager.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceManager.java index 60436a36125a..ce803667d866 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceManager.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceManager.java @@ -404,8 +404,10 @@ public WorkspaceImpl startWorkspace(WorkspaceConfig config, /** * Starts machine in running workspace * - * @param machineConfig configuration of machine to start - * @param workspaceId id of workspace in which machine should be started + * @param machineConfig + * configuration of machine to start + * @param workspaceId + * id of workspace in which machine should be started * @throws NotFoundException * if machine type from recipe is unsupported * @throws NotFoundException @@ -516,7 +518,8 @@ public List getSnapshot(String workspaceId) throws ServerException * Removes all snapshots of workspace machines. * Continues to remove snapshots even when removal of some of them fails. * - * @param workspaceId workspace id to remove machine snapshots + * @param workspaceId + * workspace id to remove machine snapshots * @throws NotFoundException * when workspace with given id doesn't exists * @throws ServerException @@ -737,8 +740,18 @@ private String replaceSnapshot(MachineImpl machine, String namespace) { snapshot = runtimes.saveMachine(namespace, machine.getWorkspaceId(), machine.getId()); - - snapshotDao.saveSnapshot(snapshot); + // check if the workspace exists before creating a snapshot, + // if it is not an integrity constraint violation exception will occur, + // this may happen when workspace stop called simultaneously. + // The issue https://github.com/eclipse/che/issues/2683 should fix it + // in a way that it won't be possible to snapshot workspace simultaneously. + if (exists(machine.getWorkspaceId())) { + snapshotDao.saveSnapshot(snapshot); + } else { + LOG.warn("Snapshot for a workspace '{}' won't be saved, as the workspace doesn't exist anymore", + machine.getWorkspaceId()); + runtimes.removeSnapshot(snapshot); + } } catch (ApiException e) { if (snapshot != null) { try { @@ -839,4 +852,14 @@ private WorkspaceImpl getByKey(String key) throws NotFoundException, ServerExcep final String namespace = nsPart.isEmpty() ? sessionUser().getUserName() : nsPart; return workspaceDao.get(wsName, namespace); } + + /** Returns true if workspace exists and false otherwise. */ + private boolean exists(String workspaceId) throws ServerException { + try { + workspaceDao.get(workspaceId); + } catch (NotFoundException x) { + return false; + } + return true; + } } From 19591c8cf127676573f5f16e018b075e7b4af95b Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Thu, 6 Oct 2016 10:55:42 +0200 Subject: [PATCH 27/33] Add wrapper method for Linux commands (#2711) Check if user or group exists with corresponding uid/gid instead of creating them each time Change-Id: I016e25c2d90bc527865c98b76dc6d91597c3d925 Signed-off-by: Florent BENOIT --- .../dto/TypeScriptDTOGeneratorMojoITest.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java b/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java index 5a80b679e155..f8f76e478d8b 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java +++ b/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java @@ -205,11 +205,11 @@ protected void installTypeScriptCompiler() throws IOException, InterruptedExcept // avoid root permissions in generated files if (SystemInfo.isLinux()) { - - command.add("groupadd -g " + getGid() + " user && useradd -u" + getUid() + " -g user user && (chown --silent -R user.user /usr/src/app || true) && cd /usr/src/app/ && npm install && (chown --silent -R user.user /usr/src/app || true)"); + command.add(wrapLinuxCommand("npm install")); } else { command.add("npm install"); } + // setup typescript compiler ProcessBuilder processBuilder = new ProcessBuilder().command(command).directory(rootPath.toFile()).redirectErrorStream(true).inheritIO(); Process process = processBuilder.start(); @@ -224,6 +224,21 @@ protected void installTypeScriptCompiler() throws IOException, InterruptedExcept } + + /** + * Wrap the given command into a command with chown. Also add group/user that match host environment if not exists + * @param command the command to wrap + * @return an updated command with chown applied on it + */ + protected String wrapLinuxCommand(String command) throws IOException, InterruptedException { + + String setGroup = "export GROUP_NAME=`(getent group " + getGid() + " || (groupadd -g " + getGid() + " user && echo user:x:" + getGid() +")) | cut -d: -f1`"; + String setUser = "export USER_NAME=`(getent passwd " + getUid() + " || (useradd -u " + getUid() + " -g ${GROUP_NAME} user && echo user:x:" + getGid() +")) | cut -d: -f1`"; + String chownCommand= "chown --silent -R ${USER_NAME}.${GROUP_NAME} /usr/src/app || true"; + return setGroup + " && " + setUser + " && " + chownCommand + " && " + command + " && " + chownCommand; + } + + /** * Starts tests by compiling first generated DTO from maven plugin * @throws IOException if unable to start process @@ -253,7 +268,7 @@ public void compileDTOAndLaunchTests() throws IOException, InterruptedException // avoid root permissions in generated files if (SystemInfo.isLinux()) { - command.add("groupadd -g " + getGid() + " user && useradd -u" + getUid() + " -g user user && (chown --silent -R user.user /usr/src/app || true) && npm test && (chown --silent -R user.user /usr/src/app || true)"); + command.add(wrapLinuxCommand("npm test")); } else { command.add("npm test"); } From 9530a6206b2ab68f89b42cbf35839f783cd69a58 Mon Sep 17 00:00:00 2001 From: Kaloyan Raev Date: Thu, 6 Oct 2016 14:22:20 +0300 Subject: [PATCH 28/33] Fix default PHP content (#2721) Signed-off-by: Kaloyan Raev --- .../src/main/resources/files/default_php_content | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content b/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content index 9a4d9faa3640..a93819658c6e 100644 --- a/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content @@ -1,5 +1,3 @@ -// Hello World program - + +echo "Hello World!\n"; From 13a1a52f2eb8b22ab0e0700e63fc4b3db665b50b Mon Sep 17 00:00:00 2001 From: Kaloyan Raev Date: Thu, 6 Oct 2016 14:29:14 +0300 Subject: [PATCH 29/33] Fixes #2437: Apply multi-edit formatting without messing up the document (#2719) * Fixes #2437: Shift remaining ranges when applying multi-edit formatting A formatting request to a language server may result in a list of multiple text edits. The ranges of all these text edits are based on the yet unmodified document. Che applies the edits to the document one by one. If the inserted text has a different length than the replaced text then the ranges of the remaining edits become invalid and they must be shifted appropriately. This patch shifts the ranges as necessary. To achieve this, it first converts the ranges based on lines and characters to linear ranges, which are easier for shifting. Signed-off-by: Kaloyan Raev * Simplify the shifting logic Signed-off-by: Kaloyan Raev * Reworked: just applying the text edits backwards is enough --- .../languageserver/ide/editor/LanguageServerFormatter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java index e0edbe92d6fa..07d9d393d64e 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java @@ -41,6 +41,7 @@ import org.eclipse.che.ide.util.loging.Log; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; +import java.util.Collections; import java.util.List; /** @@ -156,6 +157,9 @@ private void applyEdits(List edits, Document document) { if (undoRedo != null) { undoRedo.beginCompoundChange(); } + + // #2437: apply the text edits from last to first to avoid messing up the document + Collections.reverse(edits); for (TextEditDTO change : edits) { RangeDTO range = change.getRange(); document.replace(range.getStart().getLine(), range.getStart().getCharacter(), From 902912b5b9d3fd218ab66f993308287c4405adfa Mon Sep 17 00:00:00 2001 From: Kaloyan Raev Date: Thu, 6 Oct 2016 14:39:53 +0300 Subject: [PATCH 30/33] Fixes #2592: Filter code completion proposals from language server (#2658) * Fixes #2592: Filter code completion proposals from language server Implements filtering based on the existing FuzzyMatches used for the GoToSymbolAction. Signed-off-by: Kaloyan Raev * Add empty line at end of file. --- .../org/eclipse/che/ide/api/theme/Theme.java | 7 ++ .../org/eclipse/che/ide/api/ui/style.css | 1 + .../org/eclipse/che/ide/theme/DarkTheme.java | 5 ++ .../org/eclipse/che/ide/theme/LightTheme.java | 5 ++ .../org/eclipse/che/ide/ui/popup/popup.css | 4 -- .../ide/LanguageServerResources.java | 5 +- ...CompletionItemBasedCompletionProposal.java | 56 ++++++++++++--- .../LanguageServerCodeAssistProcessor.java | 70 ++++++++++++++++--- .../languageserver/ide/languageserver.css | 8 ++- 9 files changed, 136 insertions(+), 25 deletions(-) diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/theme/Theme.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/theme/Theme.java index 2736667a6e67..ce49eb448474 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/theme/Theme.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/theme/Theme.java @@ -662,6 +662,13 @@ public interface Theme { */ String completionPopupItemSubtitleTextColor(); + /** + * Item highlight text color for completion popup. + * + * @return color + */ + String completionPopupItemHighlightTextColor(); + /** * Background color of the window widget. * diff --git a/ide/che-core-ide-api/src/main/resources/org/eclipse/che/ide/api/ui/style.css b/ide/che-core-ide-api/src/main/resources/org/eclipse/che/ide/api/ui/style.css index 7fe01b89902b..a1bc24a52218 100644 --- a/ide/che-core-ide-api/src/main/resources/org/eclipse/che/ide/api/ui/style.css +++ b/ide/che-core-ide-api/src/main/resources/org/eclipse/che/ide/api/ui/style.css @@ -146,6 +146,7 @@ @eval completionPopupSelectedItemBackgroundColor org.eclipse.che.ide.api.theme.Style.theme.completionPopupSelectedItemBackgroundColor(); @eval completionPopupItemTextColor org.eclipse.che.ide.api.theme.Style.theme.completionPopupItemTextColor(); @eval completionPopupItemSubtitleTextColor org.eclipse.che.ide.api.theme.Style.theme.completionPopupItemSubtitleTextColor(); +@eval completionPopupItemHighlightTextColor org.eclipse.che.ide.api.theme.Style.theme.completionPopupItemHighlightTextColor(); @eval editorInfoBorderColor org.eclipse.che.ide.api.theme.Style.getEditorInfoBorderColor(); @eval editorInfoBorderShadowColor org.eclipse.che.ide.api.theme.Style.getEditorInfoBorderShadowColor(); diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/DarkTheme.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/DarkTheme.java index a5b62bdd4f56..056ac6d55d07 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/DarkTheme.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/DarkTheme.java @@ -506,6 +506,11 @@ public String completionPopupItemSubtitleTextColor() { return "#727272"; } + @Override + public String completionPopupItemHighlightTextColor() { + return "#4EABFF"; + } + @Override public String getWindowContentBackground() { return "#292C2F"; diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/LightTheme.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/LightTheme.java index dfddc812c039..d60ca22067c0 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/LightTheme.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/theme/LightTheme.java @@ -487,6 +487,11 @@ public String completionPopupItemSubtitleTextColor() { return "#909090"; } + @Override + public String completionPopupItemHighlightTextColor() { + return "#1A68AF"; + } + @Override public String getWindowContentBackground() { return "#ECECEC"; diff --git a/ide/che-core-ide-ui/src/main/resources/org/eclipse/che/ide/ui/popup/popup.css b/ide/che-core-ide-ui/src/main/resources/org/eclipse/che/ide/ui/popup/popup.css index 88e600d203b8..f0cdaa3e13f3 100644 --- a/ide/che-core-ide-ui/src/main/resources/org/eclipse/che/ide/ui/popup/popup.css +++ b/ide/che-core-ide-ui/src/main/resources/org/eclipse/che/ide/ui/popup/popup.css @@ -110,7 +110,3 @@ color: completionPopupItemTextColor; } - -.label span { - color: completionPopupItemSubtitleTextColor !important; -} diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerResources.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerResources.java index a1c215b9c6e0..17262506853b 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerResources.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerResources.java @@ -24,7 +24,7 @@ public interface LanguageServerResources extends ClientBundle { LanguageServerResources INSTANCE = GWT.create(LanguageServerResources.class); - @Source("languageserver.css") + @Source({"languageserver.css", "org/eclipse/che/ide/api/ui/style.css"}) LSCss css(); @Source({"QuickOpenList.css", "org/eclipse/che/ide/ui/constants.css", "org/eclipse/che/ide/api/ui/style.css"}) @@ -103,6 +103,9 @@ interface LSCss extends CssResource { @ClassName("codeassistant-detail") String codeassistantDetail(); + + @ClassName("codeassistant-highlight") + String codeassistantHighlight(); } interface QuickOpenListCss extends SimpleList.Css{ diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java index 030182e67ec2..09a940d9d972 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java @@ -17,6 +17,8 @@ import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; +import java.util.List; + import org.eclipse.che.api.languageserver.shared.lsapi.CompletionItemDTO; import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; @@ -31,6 +33,7 @@ import org.eclipse.che.ide.api.icon.Icon; import org.eclipse.che.ide.util.loging.Log; import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources; +import org.eclipse.che.plugin.languageserver.ide.filters.Match; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; /** @@ -38,24 +41,27 @@ */ public class CompletionItemBasedCompletionProposal implements CompletionProposal { + private final CompletionItemDTO completionItem; private final TextDocumentServiceClient documentServiceClient; private final TextDocumentIdentifierDTO documentId; private final LanguageServerResources resources; private final Icon icon; private final ServerCapabilities serverCapabilities; - private CompletionItemDTO completionItem; + private final List highlights; CompletionItemBasedCompletionProposal(CompletionItemDTO completionItem, TextDocumentServiceClient documentServiceClient, TextDocumentIdentifierDTO documentId, LanguageServerResources resources, Icon icon, - ServerCapabilities serverCapabilities) { + ServerCapabilities serverCapabilities, + List highlights) { this.completionItem = completionItem; this.documentServiceClient = documentServiceClient; this.documentId = documentId; this.resources = resources; this.icon = icon; this.serverCapabilities = serverCapabilities; + this.highlights = highlights; } @Override @@ -72,14 +78,48 @@ public Widget getAdditionalProposalInfo() { @Override public String getDisplayString() { + SafeHtmlBuilder builder = new SafeHtmlBuilder(); + + String label = completionItem.getLabel(); + int pos = 0; + for (Match highlight : highlights) { + if (highlight.getStart() == highlight.getEnd()) { + continue; + } + + if (pos < highlight.getStart()) { + appendPlain(builder, label.substring(pos, highlight.getStart())); + } + + appendHighlighted(builder, label.substring(highlight.getStart(), highlight.getEnd())); + pos = highlight.getEnd(); + } + + if (pos < label.length()) { + appendPlain(builder, label.substring(pos)); + } + if (completionItem.getDetail() != null) { - SafeHtmlBuilder builder = new SafeHtmlBuilder(); - builder.appendEscaped(completionItem.getLabel()); - builder.appendHtmlConstant(" "); - builder.appendEscaped(completionItem.getDetail()); - builder.appendHtmlConstant(""); + appendDetail(builder, completionItem.getDetail()); } - return completionItem.getLabel(); + + return builder.toSafeHtml().asString(); + } + + private void appendPlain(SafeHtmlBuilder builder, String text) { + builder.appendEscaped(text); + } + + private void appendHighlighted(SafeHtmlBuilder builder, String text) { + builder.appendHtmlConstant(""); + builder.appendEscaped(text); + builder.appendHtmlConstant(""); + } + + private void appendDetail(SafeHtmlBuilder builder, String text) { + builder.appendHtmlConstant(" "); + builder.appendEscaped(text); + builder.appendHtmlConstant(""); } @Override diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java index ff3396f12f58..a818a163172f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java @@ -26,9 +26,12 @@ import org.eclipse.che.ide.api.editor.codeassist.CompletionProposal; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources; +import org.eclipse.che.plugin.languageserver.ide.filters.FuzzyMatches; +import org.eclipse.che.plugin.languageserver.ide.filters.Match; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper; +import java.util.ArrayList; import java.util.List; import static com.google.common.collect.Lists.newArrayList; @@ -41,27 +44,32 @@ public class LanguageServerCodeAssistProcessor implements CodeAssistProcessor { private final DtoBuildHelper dtoBuildHelper; private final LanguageServerResources resources; private final CompletionImageProvider imageProvider; - private final ServerCapabilities serverCapabilities; - private TextDocumentServiceClient documentServiceClient; - private String lastErrorMessage; + private final ServerCapabilities serverCapabilities; + private final TextDocumentServiceClient documentServiceClient; + private final FuzzyMatches fuzzyMatches; + private String lastErrorMessage; @Inject public LanguageServerCodeAssistProcessor(TextDocumentServiceClient documentServiceClient, DtoBuildHelper dtoBuildHelper, LanguageServerResources resources, CompletionImageProvider imageProvider, - @Assisted ServerCapabilities serverCapabilities) { + @Assisted ServerCapabilities serverCapabilities, + FuzzyMatches fuzzyMatches) { this.documentServiceClient = documentServiceClient; this.dtoBuildHelper = dtoBuildHelper; this.resources = resources; this.imageProvider = imageProvider; this.serverCapabilities = serverCapabilities; + this.fuzzyMatches = fuzzyMatches; } @Override public void computeCompletionProposals(TextEditor editor, int offset, final CodeAssistCallback callback) { TextDocumentPositionParamsDTO documentPosition = dtoBuildHelper.createTDPP(editor.getDocument(), offset); final TextDocumentIdentifierDTO documentId = documentPosition.getTextDocument(); + String currentLine = editor.getDocument().getLineContent(documentPosition.getPosition().getLine()); + final String currentIdentifier = getCurrentIdentifier(currentLine, documentPosition.getPosition().getCharacter()); this.lastErrorMessage = null; documentServiceClient.completion(documentPosition).then(new Operation>() { @@ -69,12 +77,16 @@ public void computeCompletionProposals(TextEditor editor, int offset, final Code public void apply(List items) throws OperationException { List proposals = newArrayList(); for (CompletionItemDTO item : items) { - proposals.add(new CompletionItemBasedCompletionProposal(item, - documentServiceClient, - documentId, - resources, - imageProvider.getIcon(item.getKind()), - serverCapabilities)); + List highlights = filter(currentIdentifier, item); + if (highlights != null ) { + proposals.add(new CompletionItemBasedCompletionProposal(item, + documentServiceClient, + documentId, + resources, + imageProvider.getIcon(item.getKind()), + serverCapabilities, + highlights)); + } } callback.proposalComputed(proposals); } @@ -91,4 +103,42 @@ public String getErrorMessage() { return lastErrorMessage; } + private String getCurrentIdentifier(String text, int offset) { + int i = offset - 1; + while (i >= 0 && isIdentifierChar(text.charAt(i))) { + i--; + } + return text.substring(i + 1, offset); + } + + private boolean isIdentifierChar(char c) { + return c >= 'a' && c <= 'z' || + c >= 'A' && c <= 'Z' || + c >= '0' && c <= '9' || + c >= '\u007f' && c <= '\u00ff' || + c == '$' || + c == '_' || + c == '-'; + } + + private List filter(String word, CompletionItemDTO item) { + return filter(word, item.getLabel(), item.getFilterText()); + } + + private List filter(String word, String label, String filterText) { + if (filterText == null || filterText.isEmpty()) { + filterText = label; + } + + // check if the word matches the filterText + if (fuzzyMatches.fuzzyMatch(word, filterText) != null) { + // return the highlights based on the label + List highlights = fuzzyMatches.fuzzyMatch(word, label); + // return empty list of highlights if nothing matches the label + return (highlights == null) ? new ArrayList() : highlights; + } + + return null; + } + } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/ide/languageserver.css b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/ide/languageserver.css index 507937352d0e..1d7afbb8552f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/ide/languageserver.css +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/ide/languageserver.css @@ -49,5 +49,9 @@ } .codeassistant-detail { - color: #326EED; -} \ No newline at end of file + color: completionPopupItemSubtitleTextColor; +} + +.codeassistant-highlight { + color: completionPopupItemHighlightTextColor; +} From f98b226faa74cfed3a51fcdc2dd43b20039043b8 Mon Sep 17 00:00:00 2001 From: RomanNikitenko Date: Thu, 6 Oct 2016 18:37:05 +0300 Subject: [PATCH 31/33] Update machine node when we have all info about machine (#2723) Signed-off-by: Roman Nikitenko --- .../panel/ProcessesPanelPresenter.java | 57 ++++++++++++------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java index d3f602ff1593..8f9fa5dca247 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/processes/panel/ProcessesPanelPresenter.java @@ -210,11 +210,15 @@ public SVGResource getTitleImage() { @Override public void onMachineCreating(MachineStateEvent event) { workspaceAgent.setActivePart(this); - addMachineNode(event.getMachine()); + provideMachineNode(event.getMachine(), false); } @Override public void onMachineRunning(MachineStateEvent event) { + final MachineEntity machine = event.getMachine(); + if (!machine.isDev()) { + provideMachineNode(machine, true); + } } @Override @@ -603,28 +607,41 @@ private ProcessTreeNode findProcessTreeNodeById(String id) { return null; } - private ProcessTreeNode addMachineNode(MachineEntity machine) { - if (machineNodes.containsKey(machine.getId())) { - return machineNodes.get(machine.getId()); + /** + * Provides machine node: + *
  • creates new machine node when this one not exist or {@code replace} is {@code true}
  • + *
  • returns old machine node when this one exist and {@code replace} is {@code false}
  • + * + * @param machine + * machine to creating node + * @param replace + * existed node will be replaced when {@code replace} is {@code true} + * @return machine node + */ + private ProcessTreeNode provideMachineNode(@NotNull MachineEntity machine, boolean replace) { + final String machineId = machine.getId(); + if (!replace && machineNodes.containsKey(machineId)) { + return machineNodes.get(machineId); } - final ProcessTreeNode machineNode = new ProcessTreeNode(MACHINE_NODE, rootNode, machine, null, new ArrayList()); - machineNode.setRunning(true); - machineNodes.put(machine.getId(), machineNode); + final ProcessTreeNode existedMachineNode = machineNodes.remove(machineId); + final ProcessTreeNode newMachineNode = new ProcessTreeNode(MACHINE_NODE, rootNode, machine, null, new ArrayList()); + newMachineNode.setRunning(true); + machineNodes.put(machineId, newMachineNode); - if (rootNodes.contains(machineNode)) { - rootNodes.remove(machineNode); + if (rootNodes.contains(existedMachineNode)) { + rootNodes.remove(existedMachineNode); } - rootNodes.add(machineNode); - - OutputConsole outputConsole = commandConsoleFactory.create(machine.getConfig().getName()); - - addOutputConsole(machine.getId(), machineNode, outputConsole, true); + rootNodes.add(newMachineNode); view.setProcessesData(rootNode); - return machineNode; + if (existedMachineNode == null) { + final OutputConsole outputConsole = commandConsoleFactory.create(machine.getConfig().getName()); + addOutputConsole(machineId, newMachineNode, outputConsole, true); + } + return newMachineNode; } private List getMachines(Workspace workspace) { @@ -656,9 +673,9 @@ private MachineEntity getMachine(@NotNull String machineId) { return null; } + //TODO: need to improve this method. Avoid duplicate for(;;). + //Then we get output form machine it must be added to process tree already. @Override - //TODO: need to improve this method. Avoid duplicate for(;;). - //Then we get output form machine it must be added to process tree already. public void onEnvironmentOutputEvent(EnvironmentOutputEvent event) { final String content = event.getContent(); final String machineName = event.getMachineName(); @@ -672,7 +689,7 @@ public void onEnvironmentOutputEvent(EnvironmentOutputEvent event) { final List machines = getMachines(appContext.getWorkspace()); for (MachineEntity machineEntity : machines) { if (machineName.equals(machineEntity.getDisplayName())) { - ProcessTreeNode machineNode = addMachineNode(machineEntity); + ProcessTreeNode machineNode = provideMachineNode(machineEntity, false); printMachineOutput(machineNode.getId(), content); } } @@ -688,12 +705,12 @@ public void onWorkspaceStarted(WorkspaceStartedEvent event) { ProcessTreeNode machineToSelect = null; MachineEntity devMachine = appContext.getDevMachine(); if (devMachine != null) { - machineToSelect = addMachineNode(devMachine); + machineToSelect = provideMachineNode(devMachine, true); machines.remove(devMachine); } for (MachineEntity machine : machines) { - addMachineNode(machine); + provideMachineNode(machine, true); } if (machineToSelect != null) { From a909972b7c01ed3648103dad215212c71687183f Mon Sep 17 00:00:00 2001 From: Anton Korneta Date: Thu, 6 Oct 2016 18:41:08 +0300 Subject: [PATCH 32/33] Add recipe persisted event (#2725) --- .../server/event/RecipePersistedEvent.java | 32 +++++++++++++++++++ .../api/machine/server/jpa/JpaRecipeDao.java | 6 ++++ 2 files changed, 38 insertions(+) create mode 100644 wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/event/RecipePersistedEvent.java diff --git a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/event/RecipePersistedEvent.java b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/event/RecipePersistedEvent.java new file mode 100644 index 000000000000..1a7f8b7ae05d --- /dev/null +++ b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/event/RecipePersistedEvent.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * 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: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.api.machine.server.event; + +import org.eclipse.che.api.core.notification.EventOrigin; +import org.eclipse.che.api.machine.shared.ManagedRecipe; + +/** + * Published after recipe instance is persisted. + * + * @author Anton Korneta. + */ +@EventOrigin("recipe") +public class RecipePersistedEvent { + private final ManagedRecipe recipe; + + public RecipePersistedEvent(ManagedRecipe recipe) { + this.recipe = recipe; + } + + public ManagedRecipe getRecipe() { + return recipe; + } +} diff --git a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/jpa/JpaRecipeDao.java b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/jpa/JpaRecipeDao.java index afb551409ab9..7b93f1e43d3f 100644 --- a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/jpa/JpaRecipeDao.java +++ b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/jpa/JpaRecipeDao.java @@ -17,6 +17,8 @@ import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.core.jdbc.jpa.DuplicateKeyException; import org.eclipse.che.api.core.jdbc.jpa.IntegrityConstraintViolationException; +import org.eclipse.che.api.core.notification.EventService; +import org.eclipse.che.api.machine.server.event.RecipePersistedEvent; import org.eclipse.che.api.machine.server.recipe.RecipeImpl; import org.eclipse.che.api.machine.server.spi.RecipeDao; @@ -47,11 +49,15 @@ public class JpaRecipeDao implements RecipeDao { @Inject private Provider managerProvider; + @Inject + private EventService eventService; + @Override public void create(RecipeImpl recipe) throws ConflictException, ServerException { requireNonNull(recipe); try { doCreateRecipe(recipe); + eventService.publish(new RecipePersistedEvent(recipe)); } catch (DuplicateKeyException ex) { throw new ConflictException(format("Recipe with id %s already exists", recipe.getId())); } catch (IntegrityConstraintViolationException ex) { From 391ab1eb25ed39da0400835f386506d1a43dbd30 Mon Sep 17 00:00:00 2001 From: Yevhenii Voevodin Date: Thu, 6 Oct 2016 20:19:37 +0300 Subject: [PATCH 33/33] Synchronize project attributes before storing workspace (#2726) * Synchronize attribute before storing workspace * fixup! Synchronize attribute before storing workspace * fixup! fixup! Synchronize attribute before storing workspace --- .../api/factory/server/jpa/JpaFactoryDao.java | 7 +++ .../server/spi/tck/FactoryDaoTest.java | 26 +++++---- .../api/workspace/server/jpa/JpaStackDao.java | 7 +++ .../workspace/server/jpa/JpaWorkspaceDao.java | 7 +++ .../server/model/impl/ProjectConfigImpl.java | 36 +++++++++---- .../model/impl/WorkspaceConfigImpl.java | 6 --- .../server/jpa/JpaWorkspaceDaoTest.java | 54 ++++++++++++++++--- .../server/spi/tck/StackDaoTest.java | 33 ++++++------ .../server/spi/tck/WorkspaceDaoTest.java | 12 +++-- 9 files changed, 134 insertions(+), 54 deletions(-) diff --git a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/jpa/JpaFactoryDao.java b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/jpa/JpaFactoryDao.java index d3629ecb115d..8a31e78ced9f 100644 --- a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/jpa/JpaFactoryDao.java +++ b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/jpa/JpaFactoryDao.java @@ -22,6 +22,7 @@ import org.eclipse.che.api.factory.server.model.impl.FactoryImpl; import org.eclipse.che.api.factory.server.spi.FactoryDao; import org.eclipse.che.api.user.server.event.BeforeUserRemovedEvent; +import org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl; import org.eclipse.che.commons.lang.NameGenerator; import org.eclipse.che.commons.lang.Pair; import org.slf4j.Logger; @@ -141,6 +142,9 @@ public List getByAttribute(int maxItems, @Transactional protected void doCreate(FactoryImpl factory) { final EntityManager manager = managerProvider.get(); + if (factory.getWorkspace() != null) { + factory.getWorkspace().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } manager.persist(factory); } @@ -150,6 +154,9 @@ protected FactoryImpl doUpdate(FactoryImpl update) throws NotFoundException { if (manager.find(FactoryImpl.class, update.getId()) == null) { throw new NotFoundException(format("Could not update factory with id %s because it doesn't exist", update.getId())); } + if (update.getWorkspace() != null) { + update.getWorkspace().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } return manager.merge(update); } diff --git a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java index daaeb2942532..d02ecc0b04b0 100644 --- a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java +++ b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java @@ -257,17 +257,18 @@ private static FactoryImpl createFactory(int index, String userId) { final List a3 = new ArrayList<>(singletonList(new ActionImpl("id" + index, ImmutableMap.of("key3", "value3")))); final OnAppClosedImpl onAppClosed = new OnAppClosedImpl(a3); final IdeImpl ide = new IdeImpl(onAppLoaded, onProjectsLoaded, onAppClosed); - return FactoryImpl.builder() - .generateId() - .setVersion("4_0") - .setName("factoryName" + index) - .setWorkspace(createWorkspaceConfig(index)) - .setButton(factoryButton) - .setCreator(creator) - .setPolicies(policies) - .setImages(images) - .setIde(ide) - .build(); + final FactoryImpl factory = FactoryImpl.builder() + .generateId() + .setVersion("4_0") + .setName("factoryName" + index) + .setButton(factoryButton) + .setCreator(creator) + .setPolicies(policies) + .setImages(images) + .setIde(ide) + .build(); + factory.setWorkspace(createWorkspaceConfig(index)); + return factory; } public static WorkspaceConfigImpl createWorkspaceConfig(int index) { @@ -363,6 +364,9 @@ public static WorkspaceConfigImpl createWorkspaceConfig(int index) { wCfg.setCommands(commands); wCfg.setProjects(projects); wCfg.setEnvironments(environments); + + wCfg.getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + return wCfg; } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaStackDao.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaStackDao.java index bb9aa1217f4d..18180bedf7dd 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaStackDao.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaStackDao.java @@ -18,6 +18,7 @@ import org.eclipse.che.api.core.jdbc.jpa.DuplicateKeyException; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.workspace.server.event.StackPersistedEvent; +import org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; import org.eclipse.che.api.workspace.server.spi.StackDao; import org.eclipse.che.commons.annotation.Nullable; @@ -123,6 +124,9 @@ public List searchStacks(@Nullable String user, @Transactional protected void doCreate(StackImpl stack) { + if (stack.getWorkspaceConfig() != null) { + stack.getWorkspaceConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } managerProvider.get().persist(stack); } @@ -141,6 +145,9 @@ protected StackImpl doUpdate(StackImpl update) throws NotFoundException { if (manager.find(StackImpl.class, update.getId()) == null) { throw new NotFoundException(format("Workspace with id '%s' doesn't exist", update.getId())); } + if (update.getWorkspaceConfig() != null) { + update.getWorkspaceConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } return manager.merge(update); } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDao.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDao.java index d71710078f71..59bfe6bcadfb 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDao.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDao.java @@ -22,6 +22,7 @@ import org.eclipse.che.api.machine.server.model.impl.SnapshotImpl; import org.eclipse.che.api.machine.server.spi.SnapshotDao; import org.eclipse.che.api.workspace.server.event.BeforeWorkspaceRemovedEvent; +import org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl; import org.eclipse.che.api.workspace.server.spi.WorkspaceDao; import org.slf4j.Logger; @@ -154,6 +155,9 @@ public List getWorkspaces(String userId) throws ServerException { @Transactional protected void doCreate(WorkspaceImpl workspace) { + if (workspace.getConfig() != null) { + workspace.getConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } manager.get().persist(workspace); } @@ -170,6 +174,9 @@ protected WorkspaceImpl doUpdate(WorkspaceImpl update) throws NotFoundException if (manager.get().find(WorkspaceImpl.class, update.getId()) == null) { throw new NotFoundException(format("Workspace with id '%s' doesn't exist", update.getId())); } + if (update.getConfig() != null) { + update.getConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } return manager.get().merge(update); } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java index 0a2466c907ef..f83d69b7fc96 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java @@ -11,8 +11,8 @@ package org.eclipse.che.api.workspace.server.model.impl; -import org.eclipse.che.api.core.model.project.SourceStorage; import org.eclipse.che.api.core.model.project.ProjectConfig; +import org.eclipse.che.api.core.model.project.SourceStorage; import javax.persistence.Basic; import javax.persistence.CascadeType; @@ -27,7 +27,9 @@ import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.PostLoad; +import javax.persistence.PrePersist; import javax.persistence.PreUpdate; +import javax.persistence.Transient; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -72,10 +74,9 @@ public class ProjectConfigImpl implements ProjectConfig { @MapKey(name = "name") private Map dbAttributes; - // TODO consider using List or Map on model level instead // Mapping delegated to 'dbAttributes' field // as it is impossible to map nested list directly - @Column(insertable = false, updatable = false) + @Transient private Map> attributes; public ProjectConfigImpl() {} @@ -207,15 +208,32 @@ public String toString() { '}'; } - @PreUpdate - public void syncDbAttributes() { - dbAttributes = getAttributes().entrySet() - .stream() - .collect(toMap(Map.Entry::getKey, e -> new Attribute(e.getKey(), e.getValue()))); + /** + * Synchronizes instance attribute with db attributes, + * should be called by internal components in needed places, + * this can't be done neither by {@link PrePersist} nor by {@link PreUpdate} + * as when the entity is merged the transient attribute won't be passed + * to event handlers. + */ + public void prePersistAttributes() { + if (dbAttributes == null) { + dbAttributes = new HashMap<>(); + } + final Map dbAttrsCopy = new HashMap<>(dbAttributes); + dbAttributes.clear(); + for (Map.Entry> entry : getAttributes().entrySet()) { + Attribute attribute = dbAttrsCopy.get(entry.getKey()); + if (attribute == null) { + attribute = new Attribute(entry.getKey(), entry.getValue()); + } else if (!Objects.equals(attribute.values, entry.getValue())) { + attribute.values = entry.getValue(); + } + dbAttributes.put(entry.getKey(), attribute); + } } @PostLoad - private void initEntityAttributes() { + private void postLoadAttributes() { attributes = dbAttributes.values() .stream() .collect(toMap(attr -> attr.name, attr -> attr.values)); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java index 7a983632b01c..fd2e2a08dfb1 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java @@ -214,12 +214,6 @@ public String toString() { '}'; } - @PreUpdate - @PrePersist - public void syncProjects() { - getProjects().forEach(ProjectConfigImpl::syncDbAttributes); - } - /** * Helps to build complex {@link WorkspaceConfigImpl users workspace instance}. * diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java index c8f211e1f760..86201d90e450 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java @@ -11,10 +11,10 @@ package org.eclipse.che.api.workspace.server.jpa; import com.google.inject.Guice; +import com.google.inject.Injector; import org.eclipse.che.account.spi.AccountImpl; import org.eclipse.che.api.core.jdbc.jpa.DuplicateKeyException; -import org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl; import org.testng.annotations.AfterMethod; @@ -23,10 +23,10 @@ import javax.persistence.EntityManager; -import java.util.Collections; -import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; -import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; import static org.eclipse.che.api.workspace.server.spi.tck.WorkspaceDaoTest.createWorkspace; import static org.testng.Assert.assertEquals; @@ -37,18 +37,25 @@ */ public class JpaWorkspaceDaoTest { - private EntityManager manager; + private EntityManager manager; + private JpaWorkspaceDao workspaceDao; @BeforeMethod private void setUpManager() { - manager = Guice.createInjector(new WorkspaceTckModule()).getInstance(EntityManager.class); + final Injector injector = Guice.createInjector(new WorkspaceTckModule()); + manager = injector.getInstance(EntityManager.class); + workspaceDao = injector.getInstance(JpaWorkspaceDao.class); } @AfterMethod private void cleanup() { manager.getTransaction().begin(); - manager.createQuery("DELETE FROM Workspace workspaces"); - manager.createQuery("DELETE FROM Account accounts"); + final List entities = new ArrayList<>(); + entities.addAll(manager.createQuery("SELECT w FROM Workspace w").getResultList()); + entities.addAll(manager.createQuery("SELECT a FROM Account a").getResultList()); + for (Object entity : entities) { + manager.remove(entity); + } manager.getTransaction().commit(); manager.getEntityManagerFactory().close(); } @@ -107,6 +114,37 @@ public void shouldSynchronizeWorkspaceNameWithConfigNameWhenConfigIsUpdated() th manager.getTransaction().commit(); } + @Test + public void shouldSyncDbAttributesWhileUpdatingWorkspace() throws Exception { + final AccountImpl account = new AccountImpl("accountId", "namespace", "test"); + final WorkspaceImpl workspace = createWorkspace("id", account, "name"); + + // persist the workspace + manager.getTransaction().begin(); + manager.persist(account); + manager.persist(workspace); + manager.getTransaction().commit(); + manager.clear(); + + // put a new attribute + workspace.getConfig() + .getProjects() + .get(0) + .getAttributes() + .put("new-attr", singletonList("value")); + workspaceDao.update(workspace); + + manager.clear(); + + // check it's okay + assertEquals(workspaceDao.get(workspace.getId()) + .getConfig() + .getProjects() + .get(0) + .getAttributes() + .size(), 3); + } + private long asLong(String query) { return manager.createQuery(query, Long.class).getSingleResult(); } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/StackDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/StackDaoTest.java index 4af8b3fa83be..3b4948ceb97a 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/StackDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/StackDaoTest.java @@ -18,6 +18,7 @@ import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.machine.server.spi.SnapshotDao; import org.eclipse.che.api.workspace.server.event.StackPersistedEvent; +import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl; @@ -242,20 +243,22 @@ private void updateAll() throws ConflictException, NotFoundException, ServerExce } private static StackImpl createStack(String id, String name) { - return StackImpl.builder() - .setId(id) - .setName(name) - .setCreator("user123") - .setDescription(id + "-description") - .setScope(id + "-scope") - .setWorkspaceConfig(createWorkspaceConfig("test")) - .setTags(asList(id + "-tag1", id + "-tag2")) - .setComponents(asList(new StackComponentImpl(id + "-component1", id + "-component1-version"), - new StackComponentImpl(id + "-component2", id + "-component2-version"))) - .setSource(new StackSourceImpl(id + "-type", id + "-origin")) - .setStackIcon(new StackIcon(id + "-icon", - id + "-media-type", - "0x1234567890abcdef".getBytes())) - .build(); + final StackImpl stack = StackImpl.builder() + .setId(id) + .setName(name) + .setCreator("user123") + .setDescription(id + "-description") + .setScope(id + "-scope") + .setTags(asList(id + "-tag1", id + "-tag2")) + .setComponents(asList(new StackComponentImpl(id + "-component1", id + "-component1-version"), + new StackComponentImpl(id + "-component2", id + "-component2-version"))) + .setSource(new StackSourceImpl(id + "-type", id + "-origin")) + .setStackIcon(new StackIcon(id + "-icon", + id + "-media-type", + "0x1234567890abcdef".getBytes())) + .build(); + final WorkspaceConfigImpl config = createWorkspaceConfig("test"); + stack.setWorkspaceConfig(config); + return stack; } } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java index 8e5a52bb9a27..baa5991fc512 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java @@ -455,8 +455,8 @@ public static WorkspaceConfigImpl createWorkspaceConfig(String name) { recipe2.setContentType("text/x-dockerfile"); recipe2.setContent("content"); final EnvironmentImpl env2 = new EnvironmentImpl(); - env2.setMachines(new HashMap<>(ImmutableMap.of("machine1", exMachine1, - "machine3", exMachine3))); + env2.setMachines(new HashMap<>(ImmutableMap.of("machine1", new ExtendedMachineImpl(exMachine1), + "machine3", new ExtendedMachineImpl(exMachine3)))); env2.setRecipe(recipe2); final Map environments = ImmutableMap.of("env1", env1, "env2", env2); @@ -469,6 +469,9 @@ public static WorkspaceConfigImpl createWorkspaceConfig(String name) { wCfg.setCommands(commands); wCfg.setProjects(projects); wCfg.setEnvironments(new HashMap<>(environments)); + + wCfg.getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + return wCfg; } @@ -478,9 +481,8 @@ public static WorkspaceImpl createWorkspace(String id, AccountImpl account, Stri final WorkspaceImpl workspace = new WorkspaceImpl(); workspace.setId(id); workspace.setAccount(account); - final WorkspaceConfigImpl cfg = new WorkspaceConfigImpl(); - cfg.setName(name); - workspace.setConfig(cfg); + wCfg.setName(name); + workspace.setConfig(wCfg); workspace.setAttributes(new HashMap<>(ImmutableMap.of("attr1", "value1", "attr2", "value2", "attr3", "value3")));