From a0cd37c28661279ec173b8fbc18645739ae055aa Mon Sep 17 00:00:00 2001 From: Vitalii Parfonov Date: Mon, 16 Jan 2017 18:57:21 +0200 Subject: [PATCH 1/3] CHE-3620:Remove MachineServiceClient and related classes Signed-off-by: Vitalii Parfonov --- .../che/ide/api/machine/MachineManager.java | 58 --- .../ide/api/machine/MachineServiceClient.java | 49 --- .../api/machine/MachineServiceClientImpl.java | 71 ---- .../command/CommandProducerActionManager.java | 20 +- .../eclipse/che/ide/core/CoreGinModule.java | 3 - .../workspace/DefaultWorkspaceComponent.java | 4 - .../workspace/FactoryWorkspaceComponent.java | 4 - .../che/ide/workspace/WorkspaceComponent.java | 6 - .../ide/workspace/WorkspaceEventsHandler.java | 5 - .../workspace/WorkspaceEventsHandlerTest.java | 5 - .../client/command/CommandManagerImpl.java | 4 - .../client/inject/MachineGinModule.java | 7 - .../client/machine/MachineManagerImpl.java | 156 ------- .../create/CreateMachinePresenter.java | 147 ------- .../machine/create/CreateMachineView.java | 105 ----- .../machine/create/CreateMachineViewImpl.java | 387 ------------------ .../create/CreateMachineViewImpl.ui.xml | 81 ---- .../processes/ProcessesPresenter.java | 1 - .../docker/DockerCategoryPresenter.java | 76 +--- .../categories/ssh/SshCategoryPresenter.java | 61 +-- .../machine/MachineManagerImplTest.java | 169 -------- .../create/CreateMachinePresenterTest.java | 147 ------- .../processes/ProcessesPresenterTest.java | 1 - .../panel/ProcessesPanelPresenterTest.java | 4 - .../docker/DockerCategoryPresenterTest.java | 49 +-- .../ssh/SshCategoryPresenterTest.java | 41 -- ...ebuggerConfigurationPagePresenterTest.java | 3 - .../client/command/CommandManager.java | 9 +- 28 files changed, 19 insertions(+), 1654 deletions(-) delete mode 100644 ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineManager.java delete mode 100644 ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineServiceClient.java delete mode 100644 ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineServiceClientImpl.java delete mode 100644 plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/MachineManagerImpl.java delete mode 100644 plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachinePresenter.java delete mode 100644 plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineView.java delete mode 100644 plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineViewImpl.java delete mode 100644 plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineViewImpl.ui.xml delete mode 100644 plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/machine/MachineManagerImplTest.java delete mode 100644 plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachinePresenterTest.java diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineManager.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineManager.java deleted file mode 100644 index 6f74f6f5591..00000000000 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineManager.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2017 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.machine; - -import org.eclipse.che.api.promises.client.Promise; - -/** - * Manager for machine. - * - * @author Roman Nikitenko - */ -public interface MachineManager { - - /** - * Start new machine as dev-machine (bind workspace to running machine). - * - * @param recipeURL - * special recipe url to get docker image. - * @param displayName - * display name for machine - */ - void startDevMachine(String recipeURL, String displayName); - - /** - * Start new machine in workspace. - * - * @param recipeURL - * special recipe url to get docker image. - * @param displayName - * display name for machine - */ - void startMachine(String recipeURL, String displayName); - - /** - * Destroy machine. - * - * @param machine - * contains information about machine state - */ - Promise destroyMachine(MachineEntity machine); - - - /** - * Restart machine. - * - * @param machine - * contains information about machine state - */ - void restartMachine(final MachineEntity machine); -} diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineServiceClient.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineServiceClient.java deleted file mode 100644 index e19e13bab0e..00000000000 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineServiceClient.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2017 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.machine; - -import org.eclipse.che.api.core.model.machine.Command; -import org.eclipse.che.api.machine.shared.dto.MachineDto; -import org.eclipse.che.api.machine.shared.dto.MachineProcessDto; -import org.eclipse.che.api.promises.client.Promise; -import org.eclipse.che.commons.annotation.Nullable; - -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * Client for Machine API. - * - * @author Artem Zatsarynnyi - * @author Dmitry Shnurenko - */ -public interface MachineServiceClient { - - /** - * Returns list of machines which are bounded to the specified workspace. - * - * @param workspaceId - * workspace id - * @return a promise that will provide a list of {@link MachineDto}s for the given workspace ID, or rejects with an error - */ - Promise> getMachines(String workspaceId); - - /** - * Destroy machine with the specified ID. - * - * @param workspaceId - * ID of workspace - * @param machineId - * ID of machine that should be destroyed - * @return a promise that will resolve when the machine has been destroyed, or rejects with an error - */ - Promise destroyMachine(@NotNull String workspaceId, @NotNull String machineId); -} diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineServiceClientImpl.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineServiceClientImpl.java deleted file mode 100644 index 8866eef8448..00000000000 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/MachineServiceClientImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2017 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.machine; - -import com.google.inject.Inject; - -import org.eclipse.che.api.machine.shared.dto.MachineDto; -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.ui.loaders.request.LoaderFactory; - -import javax.validation.constraints.NotNull; -import java.util.List; - -import static com.google.gwt.http.client.RequestBuilder.DELETE; -import static org.eclipse.che.ide.MimeType.APPLICATION_JSON; -import static org.eclipse.che.ide.rest.HTTPHeader.ACCEPT; - -/** - * Implementation for {@link MachineServiceClient}. - * - * @author Artem Zatsarynnyi - * @author Dmitry Shnurenko - */ -public class MachineServiceClientImpl implements MachineServiceClient { - private final DtoUnmarshallerFactory dtoUnmarshallerFactory; - private final AsyncRequestFactory asyncRequestFactory; - private final LoaderFactory loaderFactory; - private final String baseHttpUrl; - - @Inject - protected MachineServiceClientImpl(AppContext appContext, - DtoUnmarshallerFactory dtoUnmarshallerFactory, - AsyncRequestFactory asyncRequestFactory, - LoaderFactory loaderFactory) { - this.dtoUnmarshallerFactory = dtoUnmarshallerFactory; - this.asyncRequestFactory = asyncRequestFactory; - this.loaderFactory = loaderFactory; - this.baseHttpUrl = appContext.getMasterEndpoint() + "/workspace/"; - } - - @Override - public Promise> getMachines(String workspaceId) { - return asyncRequestFactory.createGetRequest(baseHttpUrl + workspaceId + "/machine") - .header(ACCEPT, APPLICATION_JSON) - .loader(loaderFactory.newLoader("Getting info about bound machines...")) - .send(dtoUnmarshallerFactory.newListUnmarshaller(MachineDto.class)); - } - - @Override - public Promise destroyMachine(@NotNull final String workspaceId, - @NotNull final String machineId) { - return asyncRequestFactory.createRequest(DELETE, - baseHttpUrl + workspaceId + - "/machine/" + machineId, - null, - false) - .loader(loaderFactory.newLoader("Destroying machine...")) - .send(); - } -} diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/command/CommandProducerActionManager.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/command/CommandProducerActionManager.java index 41594bfe0a6..cf962f7c7de 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/command/CommandProducerActionManager.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/command/CommandProducerActionManager.java @@ -16,9 +16,6 @@ import com.google.web.bindery.event.shared.EventBus; import org.eclipse.che.api.core.model.machine.Machine; -import org.eclipse.che.api.machine.shared.dto.MachineDto; -import org.eclipse.che.api.promises.client.Operation; -import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.ide.Resources; import org.eclipse.che.ide.api.action.Action; import org.eclipse.che.ide.api.action.ActionEvent; @@ -28,7 +25,7 @@ import org.eclipse.che.ide.api.command.CommandProducer; import org.eclipse.che.ide.api.component.Component; import org.eclipse.che.ide.api.constraints.Constraints; -import org.eclipse.che.ide.api.machine.MachineServiceClient; +import org.eclipse.che.ide.api.machine.ActiveRuntime; import org.eclipse.che.ide.api.machine.events.MachineStateEvent; import org.eclipse.che.ide.api.machine.events.WsAgentStateEvent; import org.eclipse.che.ide.api.machine.events.WsAgentStateHandler; @@ -61,7 +58,6 @@ public class CommandProducerActionManager implements MachineStateEvent.Handler, private final ActionManager actionManager; private final CommandProducerActionFactory commandProducerActionFactory; private final AppContext appContext; - private final MachineServiceClient machineServiceClient; private final Resources resources; private final List machines; @@ -77,12 +73,10 @@ public CommandProducerActionManager(EventBus eventBus, ActionManager actionManager, CommandProducerActionFactory commandProducerActionFactory, AppContext appContext, - MachineServiceClient machineServiceClient, Resources resources) { this.actionManager = actionManager; this.commandProducerActionFactory = commandProducerActionFactory; this.appContext = appContext; - this.machineServiceClient = machineServiceClient; this.resources = resources; machines = new ArrayList<>(); @@ -119,14 +113,12 @@ private void start(Set commandProducers) { @Override public void start(final Callback callback) { - machineServiceClient.getMachines(appContext.getWorkspaceId()).then(new Operation>() { - @Override - public void apply(List arg) throws OperationException { - machines.addAll(arg); + ActiveRuntime activeRuntime = appContext.getActiveRuntime(); + if (activeRuntime != null) { + machines.addAll(activeRuntime.getMachines()); + } - callback.onSuccess(CommandProducerActionManager.this); - } - }); + callback.onSuccess(this); } @Override diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/core/CoreGinModule.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/core/CoreGinModule.java index 086d69f5a1d..645107fe78b 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/core/CoreGinModule.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/core/CoreGinModule.java @@ -31,8 +31,6 @@ import org.eclipse.che.ide.api.keybinding.KeyBindingAgent; import org.eclipse.che.ide.api.machine.ExecAgentCommandManager; import org.eclipse.che.ide.api.machine.ExecAgentEventManager; -import org.eclipse.che.ide.api.machine.MachineServiceClient; -import org.eclipse.che.ide.api.machine.MachineServiceClientImpl; import org.eclipse.che.ide.api.machine.RecipeServiceClient; import org.eclipse.che.ide.api.machine.RecipeServiceClientImpl; import org.eclipse.che.ide.api.machine.execagent.ConnectedEventHandler; @@ -138,7 +136,6 @@ protected void configure() { bind(GitServiceClient.class).to(GitServiceClientImpl.class).in(Singleton.class); bind(SshServiceClient.class).to(SshServiceClientImpl.class).in(Singleton.class); bind(RecipeServiceClient.class).to(RecipeServiceClientImpl.class).in(Singleton.class); - bind(MachineServiceClient.class).to(MachineServiceClientImpl.class).in(Singleton.class); // IDE agents bind(SelectionAgent.class).to(SelectionAgentImpl.class).asEagerSingleton(); diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/DefaultWorkspaceComponent.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/DefaultWorkspaceComponent.java index 2dca9ad8fd6..b8f9bb21441 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/DefaultWorkspaceComponent.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/DefaultWorkspaceComponent.java @@ -12,7 +12,6 @@ import com.google.gwt.core.client.Callback; import com.google.inject.Inject; -import com.google.inject.Provider; import com.google.inject.Singleton; import com.google.web.bindery.event.shared.EventBus; @@ -24,7 +23,6 @@ import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.component.Component; import org.eclipse.che.ide.api.dialogs.DialogFactory; -import org.eclipse.che.ide.api.machine.MachineManager; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.preferences.PreferencesManager; import org.eclipse.che.ide.api.workspace.WorkspaceServiceClient; @@ -54,7 +52,6 @@ public DefaultWorkspaceComponent(WorkspaceServiceClient workspaceServiceClient, DtoUnmarshallerFactory dtoUnmarshallerFactory, EventBus eventBus, AppContext appContext, - Provider machineManagerProvider, NotificationManager notificationManager, MessageBusProvider messageBusProvider, BrowserQueryFieldRenderer browserQueryFieldRenderer, @@ -70,7 +67,6 @@ public DefaultWorkspaceComponent(WorkspaceServiceClient workspaceServiceClient, dtoUnmarshallerFactory, eventBus, appContext, - machineManagerProvider, notificationManager, messageBusProvider, browserQueryFieldRenderer, diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/FactoryWorkspaceComponent.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/FactoryWorkspaceComponent.java index 04ea1c9ddbd..80f71185c24 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/FactoryWorkspaceComponent.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/FactoryWorkspaceComponent.java @@ -12,7 +12,6 @@ import com.google.gwt.core.client.Callback; import com.google.inject.Inject; -import com.google.inject.Provider; import com.google.inject.Singleton; import com.google.web.bindery.event.shared.EventBus; @@ -30,7 +29,6 @@ import org.eclipse.che.ide.api.component.Component; import org.eclipse.che.ide.api.dialogs.DialogFactory; import org.eclipse.che.ide.api.factory.FactoryServiceClient; -import org.eclipse.che.ide.api.machine.MachineManager; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.preferences.PreferencesManager; import org.eclipse.che.ide.api.workspace.WorkspaceServiceClient; @@ -74,7 +72,6 @@ public FactoryWorkspaceComponent(WorkspaceServiceClient workspaceServiceClient, DtoUnmarshallerFactory dtoUnmarshallerFactory, EventBus eventBus, AppContext appContext, - Provider machineManagerProvider, NotificationManager notificationManager, MessageBusProvider messageBusProvider, BrowserQueryFieldRenderer browserQueryFieldRenderer, @@ -90,7 +87,6 @@ public FactoryWorkspaceComponent(WorkspaceServiceClient workspaceServiceClient, dtoUnmarshallerFactory, eventBus, appContext, - machineManagerProvider, notificationManager, messageBusProvider, browserQueryFieldRenderer, diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/WorkspaceComponent.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/WorkspaceComponent.java index 52bcd1db4e2..bab1ec6b39c 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/WorkspaceComponent.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/WorkspaceComponent.java @@ -12,7 +12,6 @@ import com.google.gwt.core.client.Callback; import com.google.gwt.core.client.Scheduler; -import com.google.inject.Provider; import com.google.web.bindery.event.shared.EventBus; import org.eclipse.che.api.core.model.workspace.Workspace; @@ -28,7 +27,6 @@ import org.eclipse.che.ide.api.dialogs.CancelCallback; import org.eclipse.che.ide.api.dialogs.ConfirmCallback; import org.eclipse.che.ide.api.dialogs.DialogFactory; -import org.eclipse.che.ide.api.machine.MachineManager; import org.eclipse.che.ide.api.machine.events.WsAgentStateEvent; import org.eclipse.che.ide.api.machine.events.WsAgentStateHandler; import org.eclipse.che.ide.api.notification.NotificationManager; @@ -73,7 +71,6 @@ public abstract class WorkspaceComponent implements Component, WsAgentStateHandl protected final StartWorkspacePresenter startWorkspacePresenter; private final EventBus eventBus; - private final Provider machineManagerProvider; private final MessageBusProvider messageBusProvider; private final WorkspaceEventsHandler workspaceEventsHandler; private final LoaderPresenter loader; @@ -89,7 +86,6 @@ public WorkspaceComponent(WorkspaceServiceClient workspaceServiceClient, DtoUnmarshallerFactory dtoUnmarshallerFactory, EventBus eventBus, AppContext appContext, - Provider machineManagerProvider, NotificationManager notificationManager, MessageBusProvider messageBusProvider, BrowserQueryFieldRenderer browserQueryFieldRenderer, @@ -105,7 +101,6 @@ public WorkspaceComponent(WorkspaceServiceClient workspaceServiceClient, this.dtoUnmarshallerFactory = dtoUnmarshallerFactory; this.eventBus = eventBus; this.appContext = appContext; - this.machineManagerProvider = machineManagerProvider; this.notificationManager = notificationManager; this.messageBusProvider = messageBusProvider; this.browserQueryFieldRenderer = browserQueryFieldRenderer; @@ -198,7 +193,6 @@ public void onOpen() { public void execute() { loader.setSuccess(STARTING_WORKSPACE_RUNTIME); eventBus.fireEvent(new WorkspaceStartedEvent(workspace)); - machineManagerProvider.get();//start instance of machine manager } }); break; diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/WorkspaceEventsHandler.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/WorkspaceEventsHandler.java index 140de8ac5f7..56779afc4fb 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/WorkspaceEventsHandler.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/workspace/WorkspaceEventsHandler.java @@ -38,7 +38,6 @@ import org.eclipse.che.ide.api.dialogs.ConfirmCallback; import org.eclipse.che.ide.api.dialogs.DialogFactory; import org.eclipse.che.ide.api.machine.ExecAgentCommandManager; -import org.eclipse.che.ide.api.machine.MachineManager; import org.eclipse.che.ide.api.machine.OutputMessageUnmarshaller; import org.eclipse.che.ide.api.machine.events.WsAgentStateEvent; import org.eclipse.che.ide.api.notification.NotificationManager; @@ -90,7 +89,6 @@ public class WorkspaceEventsHandler { private final NotificationManager notificationManager; private final DialogFactory dialogFactory; private final DtoUnmarshallerFactory dtoUnmarshallerFactory; - private final Provider machineManagerProvider; private final Provider wsComponentProvider; private final AsyncRequestFactory asyncRequestFactory; private final WorkspaceSnapshotCreator snapshotCreator; @@ -125,7 +123,6 @@ public class WorkspaceEventsHandler { final DtoUnmarshallerFactory dtoUnmarshallerFactory, final NotificationManager notificationManager, final MessageBusProvider messageBusProvider, - final Provider machineManagerProvider, final WorkspaceSnapshotCreator snapshotCreator, final WorkspaceServiceClient workspaceServiceClient, final StartWorkspaceNotification startWorkspaceNotification, @@ -140,7 +137,6 @@ public class WorkspaceEventsHandler { this.notificationManager = notificationManager; this.dialogFactory = dialogFactory; this.dtoUnmarshallerFactory = dtoUnmarshallerFactory; - this.machineManagerProvider = machineManagerProvider; this.workspaceServiceClient = workspaceServiceClient; this.startWorkspaceNotification = startWorkspaceNotification; this.wsComponentProvider = wsComponentProvider; @@ -190,7 +186,6 @@ public void apply(WorkspaceDto workspace) throws OperationException { } workspaceComponent.setCurrentWorkspace(workspace); - machineManagerProvider.get(); loader.show(LoaderPresenter.Phase.STARTING_WORKSPACE_RUNTIME); eventBus.fireEvent(new WorkspaceStartingEvent(workspace)); diff --git a/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/workspace/WorkspaceEventsHandlerTest.java b/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/workspace/WorkspaceEventsHandlerTest.java index 4c1df0321c3..7a03c35fd7b 100644 --- a/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/workspace/WorkspaceEventsHandlerTest.java +++ b/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/workspace/WorkspaceEventsHandlerTest.java @@ -35,7 +35,6 @@ import org.eclipse.che.ide.api.dialogs.DialogFactory; import org.eclipse.che.ide.api.dialogs.MessageDialog; import org.eclipse.che.ide.api.machine.ExecAgentCommandManager; -import org.eclipse.che.ide.api.machine.MachineManager; import org.eclipse.che.ide.api.machine.events.WsAgentStateEvent; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; @@ -109,8 +108,6 @@ public class WorkspaceEventsHandlerTest { @Mock private DtoUnmarshallerFactory dtoUnmarshallerFactory; @Mock - private Provider machineManagerProvider; - @Mock private MessageLoader snapshotLoader; @Mock private Provider wsComponentProvider; @@ -173,7 +170,6 @@ public void setUp() { dtoUnmarshallerFactory, notificationManager, messageBusProvider, - machineManagerProvider, snapshotCreator, workspaceServiceClient, startWorkspaceNotification, @@ -252,7 +248,6 @@ public void onWorkspaceStartingTest() throws Exception { verify(workspaceServiceClient).getWorkspace(WORKSPACE_ID); verify(workspaceComponent).setCurrentWorkspace(workspace); - verify(machineManagerProvider).get(); verify(loader).show(eq(LoaderPresenter.Phase.STARTING_WORKSPACE_RUNTIME)); diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/command/CommandManagerImpl.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/command/CommandManagerImpl.java index 85364249e20..70da8ae8d42 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/command/CommandManagerImpl.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/command/CommandManagerImpl.java @@ -15,7 +15,6 @@ import org.eclipse.che.api.core.model.machine.Command; 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.Function; import org.eclipse.che.api.promises.client.FunctionException; import org.eclipse.che.api.promises.client.Operation; @@ -29,15 +28,12 @@ import org.eclipse.che.ide.api.command.CommandType; import org.eclipse.che.ide.api.command.CommandTypeRegistry; import org.eclipse.che.ide.api.machine.ExecAgentCommandManager; -import org.eclipse.che.ide.api.machine.MachineServiceClient; import org.eclipse.che.ide.api.macro.MacroProcessor; import org.eclipse.che.ide.api.workspace.WorkspaceServiceClient; import org.eclipse.che.ide.dto.DtoFactory; 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.processes.panel.ProcessesPanelPresenter; -import org.eclipse.che.ide.util.UUID; -import org.eclipse.che.ide.util.loging.Log; import java.util.ArrayList; import java.util.Collections; diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/inject/MachineGinModule.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/inject/MachineGinModule.java index 8effb47d0fc..5bffcc4f043 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/inject/MachineGinModule.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/inject/MachineGinModule.java @@ -21,7 +21,6 @@ import org.eclipse.che.ide.api.command.CommandType; import org.eclipse.che.ide.api.extension.ExtensionGinModule; import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineManager; import org.eclipse.che.ide.api.macro.Macro; import org.eclipse.che.ide.api.outputconsole.OutputConsole; import org.eclipse.che.ide.extension.machine.client.RecipeScriptDownloadServiceClient; @@ -37,9 +36,6 @@ import org.eclipse.che.ide.extension.machine.client.inject.factories.TerminalFactory; import org.eclipse.che.ide.extension.machine.client.inject.factories.WidgetsFactory; import org.eclipse.che.ide.extension.machine.client.machine.MachineItem; -import org.eclipse.che.ide.extension.machine.client.machine.MachineManagerImpl; -import org.eclipse.che.ide.extension.machine.client.machine.create.CreateMachineView; -import org.eclipse.che.ide.extension.machine.client.machine.create.CreateMachineViewImpl; 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; @@ -82,7 +78,6 @@ public class MachineGinModule extends AbstractGinModule { @Override protected void configure() { - bind(CreateMachineView.class).to(CreateMachineViewImpl.class); bind(OutputConsoleView.class).to(OutputConsoleViewImpl.class); install(new GinFactoryModuleBuilder() .implement(CommandOutputConsole.class, Names.named("command"), CommandOutputConsolePresenter.class) @@ -111,8 +106,6 @@ protected void configure() { .build(EntityFactory.class)); install(new GinFactoryModuleBuilder().build(TerminalFactory.class)); - bind(MachineManager.class).to(MachineManagerImpl.class).in(Singleton.class); - bindConstant().annotatedWith(Names.named("machine.extension.api_port")).to(Constants.WS_AGENT_PORT); bind(SshView.class).to(SshViewImpl.class); diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/MachineManagerImpl.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/MachineManagerImpl.java deleted file mode 100644 index 12e8fc4aaaa..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/MachineManagerImpl.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2017 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.extension.machine.client.machine; - -import com.google.inject.Inject; -import com.google.inject.Singleton; -import com.google.web.bindery.event.shared.EventBus; - -import org.eclipse.che.api.core.model.machine.MachineConfig; -import org.eclipse.che.api.core.model.machine.MachineSource; -import org.eclipse.che.api.machine.shared.dto.MachineConfigDto; -import org.eclipse.che.api.machine.shared.dto.MachineLimitsDto; -import org.eclipse.che.api.machine.shared.dto.MachineSourceDto; -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.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineManager; -import org.eclipse.che.ide.api.machine.MachineServiceClient; -import org.eclipse.che.ide.api.machine.events.MachineStateEvent; -import org.eclipse.che.ide.api.workspace.WorkspaceServiceClient; -import org.eclipse.che.ide.dto.DtoFactory; - -import static org.eclipse.che.ide.api.machine.events.MachineStateEvent.MachineAction.DESTROYED; - -/** - * Manager for machine operations. - * - * @author Artem Zatsarynnyi - * @author Roman Nikitenko - */ -@Singleton -public class MachineManagerImpl implements MachineManager { - - private final MachineServiceClient machineServiceClient; - private final WorkspaceServiceClient workspaceServiceClient; - private final AppContext appContext; - private final DtoFactory dtoFactory; - private final EventBus eventBus; - - @Inject - public MachineManagerImpl(final MachineServiceClient machineServiceClient, - final WorkspaceServiceClient workspaceServiceClient, - final EventBus eventBus, - final AppContext appContext, - final DtoFactory dtoFactory) { - this.machineServiceClient = machineServiceClient; - this.workspaceServiceClient = workspaceServiceClient; - this.appContext = appContext; - this.dtoFactory = dtoFactory; - this.eventBus = eventBus; - } - - @Override - public void restartMachine(final MachineEntity machineState) { - destroyMachine(machineState).then(new Operation() { - @Override - public void apply(Void arg) throws OperationException { - final MachineConfig machineConfig = machineState.getConfig(); - final MachineSource machineSource = machineConfig.getSource(); - final String displayName = machineConfig.getName(); - final boolean isDev = machineConfig.isDev(); - - startMachine(asDto(machineSource), displayName, isDev, "docker"); - } - }); - } - - /** - * Converts {@link MachineSource} to {@link MachineSourceDto}. - */ - public MachineSourceDto asDto(MachineSource source) { - return this.dtoFactory.createDto(MachineSourceDto.class) - .withType(source.getType()) - .withLocation(source.getLocation()) - .withContent(source.getContent()); - } - - @Override - public void startMachine(String recipeURL, String displayName) { - startMachine(recipeURL, displayName, false, "dockerfile", "docker"); - } - - @Override - public void startDevMachine(String recipeURL, String displayName) { - startMachine(recipeURL, displayName, true, "dockerfile", "docker"); - } - - /** - * Start new machine in workspace. - * - * @param recipeURL - * special recipe url to get docker image. - * @param displayName - * display name for machine - * @param isDev - * @param sourceType - * "dockerfile" or "ssh-config" - * @param machineType - * "docker" or "ssh" - */ - private void startMachine(final String recipeURL, - final String displayName, - final boolean isDev, - final String sourceType, - final String machineType) { - MachineSourceDto sourceDto = dtoFactory.createDto(MachineSourceDto.class).withType(sourceType).withLocation(recipeURL); - startMachine(sourceDto, displayName, isDev, machineType); - } - - /** - * @param machineSourceDto - * @param displayName - * @param isDev - * @param machineType - * "docker" or "ssh" - */ - private void startMachine(final MachineSourceDto machineSourceDto, - final String displayName, - final boolean isDev, - final String machineType) { - - MachineLimitsDto limitsDto = dtoFactory.createDto(MachineLimitsDto.class).withRam(1024); - if (isDev) { - limitsDto.withRam(3072); - } - - MachineConfigDto configDto = dtoFactory.createDto(MachineConfigDto.class) - .withDev(isDev) - .withName(displayName) - .withSource(machineSourceDto) - .withLimits(limitsDto) - .withType(machineType); - workspaceServiceClient.createMachine(appContext.getWorkspaceId(), configDto); - } - - @Override - public Promise destroyMachine(final MachineEntity machineState) { - return machineServiceClient.destroyMachine(machineState.getWorkspaceId(), - machineState.getId()).then(new Operation() { - @Override - public void apply(Void arg) throws OperationException { - eventBus.fireEvent(new MachineStateEvent(machineState, DESTROYED)); - } - }); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachinePresenter.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachinePresenter.java deleted file mode 100644 index 12ba65b38c3..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachinePresenter.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2017 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.extension.machine.client.machine.create; - -import com.google.gwt.regexp.shared.RegExp; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor; -import org.eclipse.che.api.promises.client.Operation; -import org.eclipse.che.api.promises.client.OperationException; -import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.machine.DevMachine; -import org.eclipse.che.ide.api.machine.MachineManager; -import org.eclipse.che.ide.api.machine.RecipeServiceClient; - -import java.util.Collections; -import java.util.List; - -/** - * Presenter for creating machine. - * - * @author Artem Zatsarynnyi - */ -@Singleton -public class CreateMachinePresenter implements CreateMachineView.ActionDelegate { - - private static final String URL_PATTERN = - "(https?|ftp)://(www\\.)?(((([a-zA-Z0-9.-]+\\.){1,}[a-zA-Z]{2,4}|localhost))|((\\d{1,3}\\.){3}(\\d{1,3})))(:(\\d+))?(/" + - "([a-zA-Z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?(\\?([a-zA-Z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*)?(#([a-zA-Z0-9" + - "._-]|%[0-9A-F]{2})*)?"; - private static final RegExp URL = RegExp.compile(URL_PATTERN); - - private static final String RECIPE_TYPE = "docker"; - private static final int SKIP_COUNT = 0; - private static final int MAX_COUNT = 100; - - private final CreateMachineView view; - private final AppContext appContext; - private final MachineManager machineManager; - private final RecipeServiceClient recipeServiceClient; - - @Inject - public CreateMachinePresenter(CreateMachineView view, - AppContext appContext, - MachineManager machineManager, - RecipeServiceClient recipeServiceClient) { - this.view = view; - this.appContext = appContext; - this.machineManager = machineManager; - this.recipeServiceClient = recipeServiceClient; - - view.setDelegate(this); - } - - public void showDialog() { - view.show(); - - view.setCreateButtonState(false); - view.setReplaceButtonState(false); - view.setMachineName(""); - view.setErrorHint(false); - view.setNoRecipeHint(false); - view.setTags(""); - view.setRecipeURL(""); - } - - @Override - public void onNameChanged() { - checkButtons(); - } - - @Override - public void onRecipeUrlChanged() { - checkButtons(); - } - - @Override - public void onTagsChanged() { - if (view.getTags().isEmpty()) { - view.setRecipes(Collections.emptyList()); - view.setNoRecipeHint(false); - return; - } - - recipeServiceClient.searchRecipes(view.getTags(), RECIPE_TYPE, SKIP_COUNT, MAX_COUNT).then(new Operation>() { - @Override - public void apply(List arg) throws OperationException { - view.setRecipes(arg); - view.setNoRecipeHint(arg.isEmpty()); - } - }); - } - - @Override - public void onRecipeSelected(RecipeDescriptor recipe) { - view.setRecipeURL(recipe.getLink("get recipe script").getHref()); - } - - private void checkButtons() { - final String recipeURL = view.getRecipeURL(); - final boolean urlValid = URL.test(recipeURL); - - view.setErrorHint(!urlValid); - - final boolean allowCreation = urlValid && !view.getMachineName().isEmpty(); - - view.setCreateButtonState(allowCreation); - view.setReplaceButtonState(allowCreation); - } - - @Override - public void onCreateClicked() { - final String machineName = view.getMachineName(); - final String recipeURL = view.getRecipeURL(); - machineManager.startMachine(recipeURL, machineName); - - view.close(); - } - - @Override - public void onReplaceDevMachineClicked() { - final String machineName = view.getMachineName(); - final String recipeURL = view.getRecipeURL(); - final DevMachine devMachine = appContext.getDevMachine(); - - if (devMachine != null) { - machineManager.destroyMachine(devMachine); - } - - machineManager.startDevMachine(recipeURL, machineName); - view.close(); - } - - @Override - public void onCancelClicked() { - view.close(); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineView.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineView.java deleted file mode 100644 index 6c40c047afe..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineView.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2017 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.extension.machine.client.machine.create; - -import org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor; -import org.eclipse.che.ide.api.mvp.View; - -import java.util.List; - -/** - * The view of {@link CreateMachinePresenter}. - * - * @author Artem Zatsarynnyi - */ -public interface CreateMachineView extends View { - - /** Show view. */ - void show(); - - /** Close view. */ - void close(); - - /** Returns machine name. */ - String getMachineName(); - - /** Sets machine name. */ - void setMachineName(String name); - - /** Returns recipe URL. */ - String getRecipeURL(); - - /** Sets recipe URL. */ - void setRecipeURL(String url); - - /** Sets error hint visibility. */ - void setErrorHint(boolean show); - - /** Returns tags. */ - List getTags(); - - /** Sets tags. */ - void setTags(String tags); - - /** Sets 'no recipe' hint visibility. */ - void setNoRecipeHint(boolean show); - - /** Sets recipes corresponded to tags. */ - void setRecipes(List recipes); - - /** - * Sets whether 'Create' button is enabled. - * - * @param enabled - * true to enable the button, - * false to disable it - */ - void setCreateButtonState(boolean enabled); - - /** - * Sets whether 'Replace' button is enabled. - * - * @param enabled - * true to enable the button, - * false to disable it - */ - void setReplaceButtonState(boolean enabled); - - /** Action handler for the view actions/controls. */ - interface ActionDelegate { - - /** Called when machines name has been changed. */ - void onNameChanged(); - - /** Called when recipe URL has been changed. */ - void onRecipeUrlChanged(); - - /** Called when tags has been changed. */ - void onTagsChanged(); - - /** - * Called when recipe has been selected. - * - * @param recipe - * selected recipe - */ - void onRecipeSelected(RecipeDescriptor recipe); - - /** Called when 'Create' button has been clicked. */ - void onCreateClicked(); - - /** Called when 'Replace Dev Machine' button has been clicked. */ - void onReplaceDevMachineClicked(); - - /** Called when 'Cancel' button has been clicked. */ - void onCancelClicked(); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineViewImpl.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineViewImpl.java deleted file mode 100644 index 3634aed0bd6..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineViewImpl.java +++ /dev/null @@ -1,387 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2017 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.extension.machine.client.machine.create; - -import elemental.dom.Element; -import elemental.dom.Node; -import elemental.html.TableCellElement; -import elemental.html.TableElement; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.dom.client.Style; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.KeyDownEvent; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.dom.client.KeyUpHandler; -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.Command; -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.PopupPanel; -import com.google.gwt.user.client.ui.PopupPanel.PositionCallback; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor; -import org.eclipse.che.ide.api.autocomplete.AutoCompleteResources; -import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; -import org.eclipse.che.ide.extension.machine.client.MachineResources; -import org.eclipse.che.ide.ui.list.SimpleList; -import org.eclipse.che.ide.ui.toolbar.ToolbarResources; -import org.eclipse.che.ide.ui.window.Window; -import org.eclipse.che.ide.util.dom.Elements; -import org.vectomatic.dom.svg.ui.SVGImage; - -import java.util.ArrayList; -import java.util.List; - -import static com.google.gwt.dom.client.Style.Overflow.AUTO; -import static com.google.gwt.event.dom.client.KeyCodes.KEY_DOWN; -import static com.google.gwt.event.dom.client.KeyCodes.KEY_ENTER; -import static com.google.gwt.event.dom.client.KeyCodes.KEY_ESCAPE; -import static com.google.gwt.event.dom.client.KeyCodes.KEY_LEFT; -import static com.google.gwt.event.dom.client.KeyCodes.KEY_RIGHT; -import static com.google.gwt.event.dom.client.KeyCodes.KEY_UP; - -/** - * The implementation of {@link CreateMachineView}. - * - * @author Artem Zatsarynnyi - */ -@Singleton -public class CreateMachineViewImpl extends Window implements CreateMachineView { - - private static final CreateMachineViewImplUiBinder UI_BINDER = GWT.create(CreateMachineViewImplUiBinder.class); - - private final MachineResources machineResources; - private final org.eclipse.che.ide.Resources coreResources; - private final AutoCompleteResources.Css css; - private final SimpleList.ListItemRenderer listItemRenderer = - new SimpleList.ListItemRenderer() { - @Override - public void render(Element itemElement, RecipeDescriptor itemData) { - final TableCellElement icon = Elements.createTDElement(css.proposalIcon()); - final TableCellElement label = Elements.createTDElement(css.proposalLabel()); - final TableCellElement group = Elements.createTDElement(css.proposalGroup()); - - final SVGImage image = new SVGImage(machineResources.recipe()); - image.getElement().setAttribute("class", toolbarResources.toolbar().iconButtonIcon()); - image.getElement().getStyle().setMargin(0, Style.Unit.PX); - icon.appendChild((Node)image.getElement()); - - label.setInnerHTML(itemData.getName()); - group.setInnerHTML(itemData.getType()); - - itemElement.appendChild(icon); - itemElement.appendChild(label); - itemElement.appendChild(group); - } - - @Override - public Element createElement() { - return Elements.createTRElement(); - } - }; - - private final PopupPanel popupPanel; - - @UiField(provided = true) - MachineLocalizationConstant localizationConstant; - @UiField - TextBox machineName; - @UiField - TextBox recipeURL; - @UiField - Label errorHint; - @UiField - TextBox tags; - @UiField - Label noRecipeHint; - - private ToolbarResources toolbarResources; - - private SimpleList list; - private ActionDelegate delegate; - private final SimpleList.ListEventDelegate eventDelegate = new SimpleList.ListEventDelegate() { - @Override - public void onListItemClicked(Element listItemBase, RecipeDescriptor itemData) { - list.getSelectionModel().setSelectedItem(itemData); - } - - @Override - public void onListItemDoubleClicked(Element listItemBase, RecipeDescriptor itemData) { - delegate.onRecipeSelected(itemData); - popupPanel.hide(); - tags.setFocus(true); - } - }; - - private Button createButton; - private Button replaceButton; - private Button cancelButton; - - @Inject - public CreateMachineViewImpl(MachineLocalizationConstant localizationConstant, - MachineResources machineResources, - org.eclipse.che.ide.Resources coreResources, - AutoCompleteResources autoCompleteResources, - ToolbarResources toolbarResources) { - this.localizationConstant = localizationConstant; - this.machineResources = machineResources; - this.coreResources = coreResources; - this.toolbarResources = toolbarResources; - - css = autoCompleteResources.autocompleteComponentCss(); - popupPanel = new PopupPanel(); - - setWidget(UI_BINDER.createAndBindUi(this)); - setTitle(localizationConstant.viewCreateMachineTitle()); - - machineName.addKeyUpHandler(new KeyUpHandler() { - @Override - public void onKeyUp(KeyUpEvent event) { - delegate.onNameChanged(); - } - }); - - recipeURL.addKeyUpHandler(new KeyUpHandler() { - @Override - public void onKeyUp(KeyUpEvent event) { - delegate.onRecipeUrlChanged(); - } - }); - - createFooterButtons(); - } - - private void createFooterButtons() { - createButton = createButton(localizationConstant.viewCreateMachineButtonCreate(), "window-create-machine-create", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - delegate.onCreateClicked(); - } - }); - - replaceButton = createButton(localizationConstant.viewCreateMachineButtonReplace(), "window-create-machine-replace", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - delegate.onReplaceDevMachineClicked(); - } - }); - - cancelButton = createButton(localizationConstant.cancelButton(), "window-create-machine-cancel", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - delegate.onCancelClicked(); - } - }); - - addButtonToFooter(createButton); - addButtonToFooter(replaceButton); - addButtonToFooter(cancelButton); - } - - @Override - public void setDelegate(ActionDelegate delegate) { - this.delegate = delegate; - } - - @Override - public void show() { - super.show(); - - new Timer() { - @Override - public void run() { - machineName.setFocus(true); - } - }.schedule(300); - } - - @Override - public void close() { - hide(); - } - - @Override - protected void onClose() { - super.onClose(); - popupPanel.hide(); - } - - @Override - public String getMachineName() { - return machineName.getValue(); - } - - @Override - public void setMachineName(String name) { - machineName.setValue(name); - delegate.onNameChanged(); - } - - @Override - public String getRecipeURL() { - return recipeURL.getValue(); - } - - @Override - public void setRecipeURL(String url) { - recipeURL.setValue(url); - recipeURL.setTitle(url); - - delegate.onRecipeUrlChanged(); - } - - @Override - public void setErrorHint(boolean show) { - errorHint.setVisible(show); - } - - @Override - public List getTags() { - final List tagList = new ArrayList<>(); - - for (String tag : tags.getValue().split(" ")) { - if (!tag.isEmpty()) { - tagList.add(tag.trim()); - } - } - - return tagList; - } - - @Override - public void setTags(String tags) { - this.tags.setValue(tags); - } - - @Override - public void setNoRecipeHint(boolean show) { - noRecipeHint.setVisible(show); - } - - @Override - public void setRecipes(List recipes) { - if (recipes.isEmpty()) { - popupPanel.hide(); - return; - } - - popupPanel.clear(); - - final TableElement itemHolder = Elements.createTableElement(); - itemHolder.setClassName(css.items()); - - final HTML html = new HTML(); - html.setStyleName(css.container()); - html.getElement().getStyle().setOverflow(AUTO); - html.getElement().appendChild(((com.google.gwt.dom.client.Element)itemHolder)); - ((Element)html.getElement()).getStyle().setProperty("max-height", "200px"); - - final HTML container = new HTML(); - container.getElement().appendChild(html.getElement()); - - list = SimpleList.create((SimpleList.View)container.getElement().cast(), - (Element)html.getElement(), - itemHolder, - coreResources.defaultSimpleListCss(), - listItemRenderer, - eventDelegate); - - list.render(recipes); - - popupPanel.add(container); - popupPanel.setWidth(tags.getOffsetWidth() - 10 + "px"); - popupPanel.setPopupPositionAndShow(new PositionCallback() { - @Override - public void setPosition(int offsetWidth, int offsetHeight) { - popupPanel.setPopupPosition(tags.getAbsoluteLeft(), tags.getAbsoluteTop() + tags.getOffsetHeight()); - } - }); - - list.getSelectionModel().setSelectedItem(0); - } - - @Override - public void setCreateButtonState(boolean enabled) { - createButton.setEnabled(enabled); - } - - @Override - public void setReplaceButtonState(boolean enabled) { - replaceButton.setEnabled(enabled); - } - - @UiHandler("tags") - void handleKeyDown(KeyDownEvent event) { - switch (event.getNativeKeyCode()) { - case KEY_UP: - if (popupPanel.isShowing()) { - event.preventDefault(); - - if (list.getSelectionModel().getSelectedIndex() == 0) { - list.getSelectionModel().setSelectedItem(list.getSelectionModel().size() - 1); - } else { - list.getSelectionModel().selectPrevious(); - } - } - break; - case KEY_DOWN: - if (popupPanel.isShowing()) { - event.preventDefault(); - - if (list.getSelectionModel().getSelectedIndex() == list.getSelectionModel().size() - 1) { - list.getSelectionModel().setSelectedItem(0); - } else { - list.getSelectionModel().selectNext(); - } - } - break; - case KEY_ENTER: - if (popupPanel.isShowing()) { - delegate.onRecipeSelected(list.getSelectionModel().getSelectedItem()); - popupPanel.hide(); - } - break; - case KEY_ESCAPE: - if (popupPanel.isShowing()) { - popupPanel.hide(); - } - break; - case KEY_LEFT: - case KEY_RIGHT: - break; - default: - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - delegate.onTagsChanged(); - } - }); - break; - } - } - - interface CreateMachineViewImplUiBinder extends UiBinder { - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineViewImpl.ui.xml b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineViewImpl.ui.xml deleted file mode 100644 index b083f64fdec..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachineViewImpl.ui.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - .emptyBorder { - margin: 6px; - } - - .inputField { - color: #dbdbdb; - border: 1px solid #191c1e; - border-radius: 1px; - box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.19) inset, 0px 1px 0px 0px rgba(223, 223, 223, 0.4); - font-size: 12px; - padding-left: 8px; - height: 20px; - } - - .label { - line-height: 25px; - } - - .floatLeft { - float: left; - } - - .floatRight { - float: right; - } - - .errorHint { - color: red; - height: 12px; - margin: 10px; - } - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/machine/appliance/processes/ProcessesPresenter.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/machine/appliance/processes/ProcessesPresenter.java index a4aeef627b2..97f5ea2ce95 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/machine/appliance/processes/ProcessesPresenter.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/machine/appliance/processes/ProcessesPresenter.java @@ -20,7 +20,6 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.ide.api.machine.ExecAgentCommandManager; -import org.eclipse.che.ide.api.machine.MachineServiceClient; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.ide.extension.machine.client.perspective.widgets.tab.content.TabPresenter; diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/targets/categories/docker/DockerCategoryPresenter.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/targets/categories/docker/DockerCategoryPresenter.java index 0ef8b879dcb..1e0e1bc59b4 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/targets/categories/docker/DockerCategoryPresenter.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/targets/categories/docker/DockerCategoryPresenter.java @@ -12,30 +12,14 @@ import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.inject.Inject; -import com.google.web.bindery.event.shared.EventBus; - -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.dialogs.CancelCallback; -import org.eclipse.che.ide.api.dialogs.ConfirmCallback; -import org.eclipse.che.ide.api.dialogs.DialogFactory; + import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineServiceClient; -import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; -import org.eclipse.che.ide.api.machine.events.MachineStateEvent; import org.eclipse.che.ide.extension.machine.client.targets.CategoryPage; import org.eclipse.che.ide.extension.machine.client.targets.Target; import org.eclipse.che.ide.extension.machine.client.targets.TargetManager; import org.eclipse.che.ide.extension.machine.client.targets.TargetsTreeManager; -import static org.eclipse.che.api.core.model.machine.MachineStatus.RUNNING; -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.SUCCESS; -import static org.eclipse.che.ide.api.machine.events.MachineStateEvent.MachineAction.DESTROYED; - /** * Docker type page presenter. * @@ -43,29 +27,16 @@ */ public class DockerCategoryPresenter implements CategoryPage, TargetManager, DockerView.ActionDelegate { private final DockerView dockerView; - private final DialogFactory dialogFactory; - private final NotificationManager notificationManager; private final MachineLocalizationConstant machineLocale; - private final MachineServiceClient machineService; - private final EventBus eventBus; private DockerMachineTarget selectedTarget; private TargetsTreeManager targetsTreeManager; @Inject public DockerCategoryPresenter(DockerView dockerView, - DialogFactory dialogFactory, - NotificationManager notificationManager, - MachineLocalizationConstant machineLocale, - MachineServiceClient machineService, - EventBus eventBus) { + MachineLocalizationConstant machineLocale) { this.dockerView = dockerView; - this.dialogFactory = dialogFactory; - this.notificationManager = notificationManager; this.machineLocale = machineLocale; - this.machineService = machineService; - this.eventBus = eventBus; - dockerView.setDelegate(this); } @@ -93,13 +64,6 @@ private MachineEntity getMachineByName(String machineName) { return this.targetsTreeManager != null ? this.targetsTreeManager.getMachineByName(machineName) : null; } - private void updateTargets(String preselectTargetName) { - if (this.targetsTreeManager == null) { - return; - } - this.targetsTreeManager.updateTargets(preselectTargetName); - } - @Override public boolean onRestoreTargetFields(DockerMachineTarget target) { if (target == null) { @@ -122,44 +86,10 @@ public boolean onRestoreTargetFields(DockerMachineTarget target) { @Override public void onDeleteClicked(final Target target) { - dialogFactory.createConfirmDialog(machineLocale.targetsViewDeleteConfirmTitle(), - machineLocale.targetsViewDeleteConfirm(target.getName()), - new ConfirmCallback() { - @Override - public void accepted() { - destroyTargetMachine(target); - } - }, new CancelCallback() { - @Override - public void cancelled() { - updateTargets(null); - } - }).show(); + //unsupported operation } - private void destroyTargetMachine(final Target target) { - final MachineEntity machine = this.getMachineByName(target.getName()); - if (machine == null || machine.getStatus() != RUNNING) { - return; - } - - machineService.destroyMachine(machine.getWorkspaceId(), - machine.getId()).then(new Operation() { - @Override - public void apply(Void arg) throws OperationException { - eventBus.fireEvent(new MachineStateEvent(machine, DESTROYED)); - notificationManager.notify(machineLocale.targetsViewDisconnectSuccess(target.getName()), SUCCESS, FLOAT_MODE); - updateTargets(null); - } - }).catchError(new Operation() { - @Override - public void apply(PromiseError arg) throws OperationException { - notificationManager.notify(machineLocale.targetsViewDisconnectError(target.getName()), FAIL, FLOAT_MODE); - updateTargets(target.getName()); - } - }); - } @Override public void setCurrentSelection(Target selectedTarget) { diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/targets/categories/ssh/SshCategoryPresenter.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/targets/categories/ssh/SshCategoryPresenter.java index c632f0c7a5b..3c26813ddcd 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/targets/categories/ssh/SshCategoryPresenter.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/targets/categories/ssh/SshCategoryPresenter.java @@ -32,12 +32,10 @@ import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto; import org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto; import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.dialogs.CancelCallback; -import org.eclipse.che.ide.api.dialogs.ConfirmCallback; import org.eclipse.che.ide.api.dialogs.DialogFactory; import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineServiceClient; import org.eclipse.che.ide.api.machine.RecipeServiceClient; +import org.eclipse.che.ide.api.machine.events.MachineStateEvent; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.workspace.WorkspaceServiceClient; @@ -45,7 +43,6 @@ import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; import org.eclipse.che.ide.extension.machine.client.inject.factories.EntityFactory; -import org.eclipse.che.ide.api.machine.events.MachineStateEvent; import org.eclipse.che.ide.extension.machine.client.targets.CategoryPage; import org.eclipse.che.ide.extension.machine.client.targets.Target; import org.eclipse.che.ide.extension.machine.client.targets.TargetManager; @@ -55,11 +52,10 @@ import java.util.List; import static org.eclipse.che.api.core.model.machine.MachineStatus.RUNNING; +import static org.eclipse.che.ide.api.machine.events.MachineStateEvent.MachineAction.DESTROYED; 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; -import static org.eclipse.che.ide.api.machine.events.MachineStateEvent.MachineAction.DESTROYED; /** * SSH type page presenter. @@ -77,7 +73,6 @@ public class SshCategoryPresenter implements CategoryPage, TargetManager, SshVie private final NotificationManager notificationManager; private final MachineLocalizationConstant machineLocale; private final AppContext appContext; - private final MachineServiceClient machineService; private final EventBus eventBus; private final WorkspaceServiceClient workspaceServiceClient; @@ -100,7 +95,6 @@ public SshCategoryPresenter(SshView sshView, MachineLocalizationConstant machineLocale, WorkspaceServiceClient workspaceServiceClient, AppContext appContext, - MachineServiceClient machineService, EventBus eventBus) { this.sshView = sshView; this.recipeServiceClient = recipeServiceClient; @@ -111,7 +105,6 @@ public SshCategoryPresenter(SshView sshView, this.workspaceServiceClient = workspaceServiceClient; this.machineLocale = machineLocale; this.appContext = appContext; - this.machineService = machineService; this.eventBus = eventBus; sshView.setDelegate(this); @@ -471,40 +464,14 @@ private void disconnect(final MachineEntity machine) { return; } sshView.setConnectButtonText(null); - - machineService.destroyMachine(machine.getWorkspaceId(), - machine.getId()).then(new Operation() { - @Override - public void apply(Void arg) throws OperationException { - eventBus.fireEvent(new MachineStateEvent(machine, DESTROYED)); - - notificationManager.notify(machineLocale.targetsViewDisconnectSuccess(selectedTarget.getName()), SUCCESS, FLOAT_MODE); - updateTargets(null); - } - }).catchError(new Operation() { - @Override - public void apply(PromiseError arg) throws OperationException { - notificationManager.notify(machineLocale.targetsViewDisconnectError(selectedTarget.getName()), FAIL, FLOAT_MODE); - updateTargets(null); - } - }); + eventBus.fireEvent(new MachineStateEvent(machine, DESTROYED)); + notificationManager.notify(machineLocale.targetsViewDisconnectSuccess(selectedTarget.getName()), SUCCESS, FLOAT_MODE); + updateTargets(null); } @Override public void onDeleteClicked(final Target target) { - dialogFactory.createConfirmDialog(machineLocale.targetsViewDeleteConfirmTitle(), - machineLocale.targetsViewDeleteConfirm(target.getName()), - new ConfirmCallback() { - @Override - public void accepted() { - deleteTarget(target); - } - }, new CancelCallback() { - @Override - public void cancelled() { - updateTargets(null); - } - }).show(); + //unsupported operation } private void deleteTarget(final Target target) { @@ -519,22 +486,6 @@ private void deleteTarget(final Target target) { disconnect(machine); return; } - - machineService.destroyMachine(machine.getWorkspaceId(), - machine.getId()).then(new Operation() { - @Override - public void apply(Void arg) throws OperationException { - eventBus.fireEvent(new MachineStateEvent(machine, DESTROYED)); - notificationManager.notify(machineLocale.targetsViewDisconnectSuccess(target.getName()), SUCCESS, FLOAT_MODE); - deleteTargetRecipe(target); - } - }).catchError(new Operation() { - @Override - public void apply(PromiseError arg) throws OperationException { - notificationManager.notify(machineLocale.targetsViewDisconnectError(target.getName()), FAIL, FLOAT_MODE); - updateTargets(target.getName()); - } - }); } /** diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/machine/MachineManagerImplTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/machine/MachineManagerImplTest.java deleted file mode 100644 index da37fdbb8d9..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/machine/MachineManagerImplTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2017 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.extension.machine.client.machine; - -import com.google.web.bindery.event.shared.EventBus; - -import org.eclipse.che.api.core.model.machine.MachineConfig; -import org.eclipse.che.api.core.model.machine.MachineSource; -import org.eclipse.che.api.machine.shared.dto.MachineLimitsDto; -import org.eclipse.che.api.machine.shared.dto.MachineConfigDto; -import org.eclipse.che.api.machine.shared.dto.MachineSourceDto; -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.DevMachine; -import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineServiceClient; -import org.eclipse.che.ide.api.machine.events.MachineStateEvent; -import org.eclipse.che.ide.api.parts.PerspectiveManager; -import org.eclipse.che.ide.api.workspace.WorkspaceServiceClient; -import org.eclipse.che.ide.dto.DtoFactory; -import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; -import org.eclipse.che.ide.websocket.MessageBusProvider; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.InjectMocks; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * Check {@link MachineManagerImpl} - * - * @author Florent Benoit - */ -@RunWith(MockitoJUnitRunner.class) -public class MachineManagerImplTest { - - @Mock - private DtoUnmarshallerFactory dtoUnmarshallerFactor; - - @Mock - private MachineServiceClient machineServiceClient; - - @Mock - private WorkspaceServiceClient workspaceServiceClient; - - @Mock - private MachineStatusHandler machineStatusHandler; - - @Mock - private MessageBusProvider messageBusProvider; - - @Mock - private PerspectiveManager perspectiveManager; - - @Mock - private EventBus eventBus; - - @Mock - private AppContext appContext; - - @Mock - private DtoFactory dtoFactory; - - @Captor - private ArgumentCaptor startWorkspaceHandlerCaptor; - - @Captor - private ArgumentCaptor> operationArgumentCaptor; - - @Captor - private ArgumentCaptor machineConfigDtoArgumentCaptor; - - - @InjectMocks - private MachineManagerImpl machineManager; - - /** - * Check a valid source object is used on machine destroyed with restart flag - * - * @throws OperationException - * if restart fails - */ - @Test - public void checkUseValidSource() throws OperationException { - final String ID = "id"; - final String WORKSPACE_ID = "testWorkspaceId"; - final String DISPLAY_NAME = "my-display-name"; - final boolean IS_DEV = true; - - final String SOURCE_TYPE = "source-type"; - final String SOURCE_LOCATION = "source-location"; - final String SOURCE_CONTENT = "source-content"; - - MachineEntity machineState = mock(MachineEntity.class); - when(machineState.getId()).thenReturn(ID); - when(machineState.getWorkspaceId()).thenReturn(WORKSPACE_ID); - Promise promise = mock(Promise.class); - Promise promiseThen = mock(Promise.class); - when(machineServiceClient.destroyMachine(eq(WORKSPACE_ID), eq(ID))).thenReturn(promise); - when(promise.then(Matchers.>anyObject())).thenReturn(promiseThen); - - MachineSource machineSource = mock(MachineSource.class); - MachineConfig machineConfig = mock(MachineConfig.class); - when(machineState.getConfig()).thenReturn(machineConfig); - when(machineConfig.getSource()).thenReturn(machineSource); - when(machineConfig.getName()).thenReturn(DISPLAY_NAME); - when(machineConfig.isDev()).thenReturn(IS_DEV); - when(machineSource.getType()).thenReturn(SOURCE_TYPE); - when(machineSource.getLocation()).thenReturn(SOURCE_LOCATION); - when(machineSource.getContent()).thenReturn(SOURCE_CONTENT); - MachineSourceDto machineSourceDto = mock(MachineSourceDto.class); - when(machineSourceDto.withType(eq(SOURCE_TYPE))).thenReturn(machineSourceDto); - when(machineSourceDto.withLocation(eq(SOURCE_LOCATION))).thenReturn(machineSourceDto); - when(machineSourceDto.withContent(eq(SOURCE_CONTENT))).thenReturn(machineSourceDto); - when(dtoFactory.createDto(MachineSourceDto.class)).thenReturn(machineSourceDto); - MachineLimitsDto limitsDto = mock(MachineLimitsDto.class); - when(dtoFactory.createDto(MachineLimitsDto.class)).thenReturn(limitsDto); - when(limitsDto.withRam(anyInt())).thenReturn(limitsDto); - - MachineConfigDto machineConfigDto = mock(MachineConfigDto.class); - when(dtoFactory.createDto(MachineConfigDto.class)).thenReturn(machineConfigDto); - when(machineConfigDto.withDev(anyBoolean())).thenReturn(machineConfigDto); - when(machineConfigDto.withName(anyString())).thenReturn(machineConfigDto); - when(machineConfigDto.withSource(machineSourceDto)).thenReturn(machineConfigDto); - when(machineConfigDto.withLimits(limitsDto)).thenReturn(machineConfigDto); - when(machineConfigDto.withType(anyString())).thenReturn(machineConfigDto); - - when(appContext.getWorkspaceId()).thenReturn(ID); - DevMachine devMachine = mock(DevMachine.class); - when(appContext.getDevMachine()).thenReturn(devMachine); - when(devMachine.getId()).thenReturn(ID); - - Promise promiseEmpty = mock(Promise.class); - when(workspaceServiceClient.createMachine(anyString(), any(MachineConfigDto.class))).thenReturn(promiseEmpty); - - machineManager.restartMachine(machineState); - - verify(promiseThen).then(operationArgumentCaptor.capture()); - operationArgumentCaptor.getValue().apply(null); - - verify(workspaceServiceClient).createMachine(eq(ID), machineConfigDtoArgumentCaptor.capture()); - verify(machineSourceDto).withType(eq(SOURCE_TYPE)); - verify(machineSourceDto).withLocation(eq(SOURCE_LOCATION)); - verify(machineSourceDto).withContent(eq(SOURCE_CONTENT)); - } - -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachinePresenterTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachinePresenterTest.java deleted file mode 100644 index 383bfca31ff..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/machine/create/CreateMachinePresenterTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2017 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.extension.machine.client.machine.create; - -import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.machine.DevMachine; -import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineManager; -import org.eclipse.che.ide.api.project.ProjectTypeServiceClient; -import org.eclipse.che.ide.extension.machine.client.inject.factories.EntityFactory; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** @author Artem Zatsarynny */ -@RunWith(MockitoJUnitRunner.class) -public class CreateMachinePresenterTest { - - private final static String RECIPE_URL = "http://www.host.com/recipe"; - private final static String MACHINE_NAME = "machine"; - private final static String WORKSPACE_ID = "testWorkspace123"; - - private final static String SOME_TEXT = "someText"; - - @Mock - private CreateMachineView view; - @Mock - private MachineManager machineManager; - @Mock - private AppContext appContext; - @Mock - private ProjectTypeServiceClient projectTypeServiceClient; - @Mock - private EntityFactory entityFactory; - - @InjectMocks - private CreateMachinePresenter presenter; - - @Before - public void setUp() { - when(view.getRecipeURL()).thenReturn(RECIPE_URL); - when(view.getMachineName()).thenReturn(MACHINE_NAME); - } - - @Test - public void shouldSetActionDelegate() throws Exception { - verify(view).setDelegate(presenter); - } - - @Test - public void viewShouldBeShown() throws Exception { - presenter.showDialog(); - - verify(view).show(); - verify(view).setCreateButtonState(false); - verify(view).setReplaceButtonState(false); - verify(view).setMachineName(""); - verify(view).setRecipeURL(""); - verify(view).setErrorHint(false); - verify(view).setTags(""); - } - - @Test - public void buttonsShouldBeDisabledWhenNameIsEmpty() throws Exception { - when(view.getMachineName()).thenReturn(""); - - presenter.onNameChanged(); - - verify(view).setCreateButtonState(eq(false)); - verify(view).setReplaceButtonState(eq(false)); - } - - @Test - public void buttonsShouldBeEnabledWhenNameIsNotEmpty() throws Exception { - presenter.onNameChanged(); - - verify(view).setCreateButtonState(eq(true)); - verify(view).setReplaceButtonState(eq(true)); - } - - @Test - public void shouldCreateMachine() throws Exception { - presenter.onCreateClicked(); - - verify(view).getRecipeURL(); - verify(view).getMachineName(); - verify(machineManager).startMachine(eq(RECIPE_URL), eq(MACHINE_NAME)); - verify(view).close(); - } - - @Test - public void shouldReplaceDevMachine() throws Exception { - DevMachine devMachine = mock(DevMachine.class); - when(appContext.getDevMachine()).thenReturn(devMachine); - when(devMachine.getId()).thenReturn(SOME_TEXT); - when(devMachine.getWorkspace()).thenReturn(WORKSPACE_ID); - - presenter.onReplaceDevMachineClicked(); - - verify(view).getMachineName(); - verify(view).getRecipeURL(); - verify(appContext).getDevMachine(); - verify(machineManager).destroyMachine(devMachine); - verify(machineManager).startDevMachine(eq(RECIPE_URL), eq(MACHINE_NAME)); - verify(view).close(); - } - - @Test - public void shouldStartNewDevMachine() throws Exception { - when(appContext.getDevMachine()).thenReturn(null); - - presenter.onReplaceDevMachineClicked(); - - verify(view).getMachineName(); - verify(view).getRecipeURL(); - verify(appContext).getDevMachine(); - verify(machineManager).startDevMachine(eq(RECIPE_URL), eq(MACHINE_NAME)); - verify(view).close(); - verify(machineManager, never()).destroyMachine(any(MachineEntity.class)); - verify(machineManager).startDevMachine(eq(RECIPE_URL), eq(MACHINE_NAME)); - } - - @Test - public void shouldCloseView() throws Exception { - presenter.onCancelClicked(); - - verify(view).close(); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/machine/appliance/processes/ProcessesPresenterTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/machine/appliance/processes/ProcessesPresenterTest.java index b0a60a93df6..b9285383e38 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/machine/appliance/processes/ProcessesPresenterTest.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/machine/appliance/processes/ProcessesPresenterTest.java @@ -17,7 +17,6 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.machine.ExecAgentCommandManager; -import org.eclipse.che.ide.api.machine.MachineServiceClient; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; 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 1a0fadb58c3..37ff2506597 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 @@ -33,8 +33,6 @@ import org.eclipse.che.ide.api.machine.DevMachine; import org.eclipse.che.ide.api.machine.ExecAgentCommandManager; import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineManager; -import org.eclipse.che.ide.api.machine.MachineServiceClient; import org.eclipse.che.ide.api.machine.events.MachineStateEvent; import org.eclipse.che.ide.api.machine.events.WsAgentStateEvent; import org.eclipse.che.ide.api.macro.MacroProcessor; @@ -126,8 +124,6 @@ public class ProcessesPanelPresenterTest { @Mock private OutputConsole outputConsole; @Mock - private MachineManager machineManager; - @Mock private EntityFactory entityFactory; @Mock private WorkspaceRuntimeDto workspaceRuntime; diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/targets/categories/docker/DockerCategoryPresenterTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/targets/categories/docker/DockerCategoryPresenterTest.java index be0fbefe981..5bdd4a6c8d3 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/targets/categories/docker/DockerCategoryPresenterTest.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/targets/categories/docker/DockerCategoryPresenterTest.java @@ -19,11 +19,8 @@ import org.eclipse.che.ide.api.dialogs.ConfirmCallback; import org.eclipse.che.ide.api.dialogs.ConfirmDialog; import org.eclipse.che.ide.api.dialogs.DialogFactory; -import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineServiceClient; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; -import org.eclipse.che.ide.api.machine.events.MachineStateEvent; import org.eclipse.che.ide.extension.machine.client.targets.TargetsTreeManager; import org.junit.Before; import org.junit.Test; @@ -35,9 +32,6 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; -import static org.eclipse.che.api.core.model.machine.MachineStatus.RUNNING; -import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE; -import static org.eclipse.che.ide.api.notification.StatusNotification.Status.SUCCESS; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; @@ -55,8 +49,6 @@ public class DockerCategoryPresenterTest { @Mock private MachineLocalizationConstant machineLocale; @Mock - private MachineServiceClient machineService; - @Mock private EventBus eventBus; @@ -88,51 +80,12 @@ public void setUp() { when(promise.then(operationSuccessCapture.capture())).thenReturn(promise); - arbitraryCategoryPresenter = new DockerCategoryPresenter(dockerView, - dialogFactory, - notificationManager, - machineLocale, - machineService, - eventBus); + arbitraryCategoryPresenter = new DockerCategoryPresenter(dockerView, machineLocale); arbitraryCategoryPresenter.setTargetsTreeManager(targetsTreeManager); } - @Test - public void testOnDeleteTarget() throws Exception { - final String deletingTargetName = "deletingTargetName"; - final String deleteProposal = "Are you sure you want to delete target " + deletingTargetName + " ?"; - final String deletingMachineId = "deletingMachineId"; - final String deleteSuccessMessage = "Successfully disconnected from machine " + deletingTargetName; - final DockerMachineTarget target = Mockito.mock(DockerMachineTarget.class); - final MachineEntity machine = Mockito.mock(MachineEntity.class); - when(machineLocale.targetsViewDisconnectSuccess(deletingTargetName)).thenReturn(deleteSuccessMessage); - when(target.getName()).thenReturn(deletingTargetName); - when(targetsTreeManager.getMachineByName(deletingTargetName)).thenReturn(machine); - when(machine.getId()).thenReturn(deletingMachineId); - when(machine.getWorkspaceId()).thenReturn("WS_ID"); - when(machine.getStatus()).thenReturn(RUNNING); - when(machineLocale.targetsViewDeleteConfirm(deletingTargetName)).thenReturn(deleteProposal); - when(machineService.destroyMachine("WS_ID", deletingMachineId)).thenReturn(promise); - - - arbitraryCategoryPresenter.onDeleteClicked(target); - - verify(dialogFactory).createConfirmDialog(anyString(), eq(deleteProposal), confirmCaptor.capture(), - Matchers.anyObject()); - - confirmCaptor.getValue().accepted(); - - verify(targetsTreeManager).getMachineByName(deletingTargetName); - verify(machineService).destroyMachine("WS_ID", deletingMachineId); - - operationSuccessCapture.getValue().apply(null); - - verify(eventBus).fireEvent(Matchers.anyObject()); - verify(notificationManager).notify(eq(deleteSuccessMessage), eq(SUCCESS), eq(FLOAT_MODE)); - verify(targetsTreeManager).updateTargets(null); - } @Test public void testGetCategory() throws Exception { diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/targets/categories/ssh/SshCategoryPresenterTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/targets/categories/ssh/SshCategoryPresenterTest.java index 6838e133809..ab60a431820 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/targets/categories/ssh/SshCategoryPresenterTest.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/targets/categories/ssh/SshCategoryPresenterTest.java @@ -13,7 +13,6 @@ import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.web.bindery.event.shared.EventBus; -import org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.app.AppContext; @@ -21,7 +20,6 @@ import org.eclipse.che.ide.api.dialogs.ConfirmCallback; import org.eclipse.che.ide.api.dialogs.ConfirmDialog; import org.eclipse.che.ide.api.dialogs.DialogFactory; -import org.eclipse.che.ide.api.machine.MachineServiceClient; import org.eclipse.che.ide.api.machine.RecipeServiceClient; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.workspace.WorkspaceServiceClient; @@ -39,8 +37,6 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; -import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE; -import static org.eclipse.che.ide.api.notification.StatusNotification.Status.SUCCESS; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.never; @@ -68,8 +64,6 @@ public class SshCategoryPresenterTest { @Mock private AppContext appContext; @Mock - private MachineServiceClient machineService; - @Mock private EventBus eventBus; @Mock private EntityFactory entityFactory; @@ -114,46 +108,11 @@ public void setUp() { machineLocale, workspaceServiceClient, appContext, - machineService, eventBus); arbitraryCategoryPresenter.setTargetsTreeManager(targetsTreeManager); arbitraryCategoryPresenter.setCurrentSelection(target); } - - @Test - public void testOnDeleteTarget() throws Exception { - final String deletingTargetName = "deletingTargetName"; - final String recipeId = "deletingTargetRecipeId"; - final String deleteProposal = "Are you sure you want to delete target " + deletingTargetName + " ?"; - final String deleteSuccessMessage = "Target recipe " + deletingTargetName + " successfully deleted"; - final SshMachineTarget target = Mockito.mock(SshMachineTarget.class); - final RecipeDescriptor recipe = Mockito.mock(RecipeDescriptor.class); - when(target.getName()).thenReturn(deletingTargetName); - when(target.getRecipe()).thenReturn(recipe); - when(recipe.getId()).thenReturn(recipeId); - when(recipeServiceClient.removeRecipe(recipeId)).thenReturn(promise); - when(machineLocale.targetsViewDeleteConfirm(deletingTargetName)).thenReturn(deleteProposal); - when(machineLocale.targetsRecipeDeleteSuccess(deletingTargetName)).thenReturn(deleteSuccessMessage); - - arbitraryCategoryPresenter.onDeleteClicked(target); - - verify(dialogFactory).createConfirmDialog(anyString(), eq(deleteProposal), confirmCaptor.capture(), - Matchers.anyObject()); - - confirmCaptor.getValue().accepted(); - - verify(recipeServiceClient).removeRecipe(recipeId); - verify(promise).then(operationSuccessCapture.capture()); - - operationSuccessCapture.getValue().apply(null); - - verify(notificationManager).notify(eq(deleteSuccessMessage), eq(SUCCESS), eq(FLOAT_MODE)); - verify(target).isConnected(); - verify(targetsTreeManager).updateTargets(null); - } - - @Test public void testOnCancelClicked() throws Exception { 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 357d9d8c93b..61058609a4a 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 @@ -15,7 +15,6 @@ 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.macros.CurrentProjectPathMacro; import org.junit.Before; @@ -55,8 +54,6 @@ public class NodeJsDebuggerConfigurationPagePresenterTest { private AppContext appContext; @Mock private RecipeServiceClient recipeServiceClient; - @Mock - private MachineServiceClient machineServiceClient; @InjectMocks private NodeJsDebuggerConfigurationPagePresenter pagePresenter; 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 index f680bc01484..eab9e02e00c 100644 --- 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 @@ -21,15 +21,13 @@ import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.machine.ExecAgentCommandManager; import org.eclipse.che.ide.api.machine.execagent.ExecAgentPromise; -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 */ @@ -38,15 +36,14 @@ public class CommandManager { private final DtoFactory dtoFactory; private final ExecAgentCommandManager commandManager; - private final NotificationManager notificationManager; private final AppContext appContext; @Inject - public CommandManager(DtoFactory dtoFactory, ExecAgentCommandManager commandManager, NotificationManager notificationManager, + public CommandManager(DtoFactory dtoFactory, + ExecAgentCommandManager commandManager, AppContext appContext) { this.dtoFactory = dtoFactory; this.commandManager = commandManager; - this.notificationManager = notificationManager; this.appContext = appContext; } From 274c899606b67cd0e13f3f92ec21fb17f126282f Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Mon, 6 Mar 2017 16:18:05 +0200 Subject: [PATCH 2/3] Prevent NULL setting --- .../main/java/org/eclipse/che/ide/context/AppContextImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/context/AppContextImpl.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/context/AppContextImpl.java index 6c5b6c9d63f..2a2efce794f 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/context/AppContextImpl.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/context/AppContextImpl.java @@ -130,7 +130,9 @@ public Workspace getWorkspace() { public void setWorkspace(Workspace workspace) { if (workspace != null) { usersWorkspace = workspace; - runtime = new ActiveRuntime(workspace.getRuntime()); + if (workspace.getRuntime() != null) { + runtime = new ActiveRuntime(workspace.getRuntime()); + } } else { usersWorkspace = null; runtime = null; From ddf8cf04b8b0b7fea32717ede9b9e550e86f2e86 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Mon, 6 Mar 2017 17:33:06 +0200 Subject: [PATCH 3/3] Fix module --- .../che/plugin/docker/machine/local/LocalDockerModule.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/local/LocalDockerModule.java b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/local/LocalDockerModule.java index 12a6a3a06bb..a6765af8628 100644 --- a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/local/LocalDockerModule.java +++ b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/local/LocalDockerModule.java @@ -17,7 +17,6 @@ import com.google.inject.multibindings.Multibinder; import com.google.inject.name.Names; -import org.eclipse.che.api.environment.server.MachineService; import org.eclipse.che.api.machine.server.spi.Instance; import org.eclipse.che.api.machine.server.spi.InstanceProcess; import org.eclipse.che.plugin.docker.client.DockerConnector; @@ -42,7 +41,6 @@ public class LocalDockerModule extends AbstractModule { @Override protected void configure() { - bind(MachineService.class); install(new FactoryModuleBuilder() .implement(Instance.class, DockerInstance.class)