From 9bb90c37f29a16a0e6b09d9ec20bafcb971b694b Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Thu, 23 Mar 2017 10:50:48 +0200 Subject: [PATCH] CHE-3659: Remove GDB debug configuration (#4513) --- .../GdbConfigurationPagePresenter.java | 66 +++---------------- 1 file changed, 10 insertions(+), 56 deletions(-) diff --git a/plugins/plugin-gdb/che-plugin-gdb-ide/src/main/java/org/eclipse/che/plugin/gdb/ide/configuration/GdbConfigurationPagePresenter.java b/plugins/plugin-gdb/che-plugin-gdb-ide/src/main/java/org/eclipse/che/plugin/gdb/ide/configuration/GdbConfigurationPagePresenter.java index 4578545ca44..0e6bf949df6 100644 --- a/plugins/plugin-gdb/che-plugin-gdb-ide/src/main/java/org/eclipse/che/plugin/gdb/ide/configuration/GdbConfigurationPagePresenter.java +++ b/plugins/plugin-gdb/che-plugin-gdb-ide/src/main/java/org/eclipse/che/plugin/gdb/ide/configuration/GdbConfigurationPagePresenter.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.che.plugin.gdb.ide.configuration; -import com.google.gwt.core.client.JsArrayMixed; import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -18,19 +17,11 @@ import org.eclipse.che.api.core.model.machine.Machine; import org.eclipse.che.api.core.model.workspace.Workspace; import org.eclipse.che.api.machine.shared.dto.MachineDto; -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.api.promises.client.Promise; -import org.eclipse.che.api.promises.client.js.Promises; 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.RecipeServiceClient; -import org.eclipse.che.ide.dto.DtoFactory; -import org.eclipse.che.ide.extension.machine.client.inject.factories.EntityFactory; import org.eclipse.che.ide.extension.machine.client.command.macros.CurrentProjectPathMacro; -import org.eclipse.che.ide.json.JsonHelper; +import org.eclipse.che.ide.extension.machine.client.inject.factories.EntityFactory; import java.util.ArrayList; import java.util.HashMap; @@ -53,8 +44,6 @@ public class GdbConfigurationPagePresenter implements GdbConfigurationPageView.A private final GdbConfigurationPageView view; private final AppContext appContext; private final EntityFactory entityFactory; - private final RecipeServiceClient recipeServiceClient; - private final DtoFactory dtoFactory; private final CurrentProjectPathMacro currentProjectPathMacro; private DebugConfiguration editedConfiguration; @@ -66,15 +55,11 @@ public class GdbConfigurationPagePresenter implements GdbConfigurationPageView.A @Inject public GdbConfigurationPagePresenter(GdbConfigurationPageView view, AppContext appContext, - DtoFactory dtoFactory, EntityFactory entityFactory, - RecipeServiceClient recipeServiceClient, CurrentProjectPathMacro currentProjectPathMacro) { this.view = view; this.appContext = appContext; this.entityFactory = entityFactory; - this.recipeServiceClient = recipeServiceClient; - this.dtoFactory = dtoFactory; this.currentProjectPathMacro = currentProjectPathMacro; view.setDelegate(this); @@ -124,16 +109,18 @@ public void go(AcceptsOneWidget container) { } private void setHosts(List machines) { - List> recipePromises = new ArrayList<>(machines.size()); + Map hosts = new HashMap<>(); for (Machine machine : machines) { - String location = machine.getConfig().getSource().getLocation(); - String recipeId = getRecipeId(location); - recipePromises.add(recipeServiceClient.getRecipe(recipeId)); + String host = machine.getRuntime().getProperties().get("network.ipAddress"); + if (host == null) { + continue; + } + + String description = host + " (" + machine.getConfig().getName() + ")"; + hosts.put(host, description); } - @SuppressWarnings("unchecked") - final Promise[] recipePromisesArray = (Promise[])recipePromises.toArray(); - setHostsList(recipePromisesArray, machines); + view.setHostsList(hosts); } private List getMachines() { @@ -153,34 +140,6 @@ private List getMachines() { return machines; } - private void setHostsList(final Promise[] recipePromises, final List machines) { - Promises.all(recipePromises).then(new Operation() { - @Override - public void apply(JsArrayMixed recipes) throws OperationException { - Map hosts = new HashMap<>(); - - for (int i = 0; i < recipes.length(); i++) { - String recipeJson = recipes.getObject(i).toString(); - RecipeDescriptor recipeDescriptor = dtoFactory.createDtoFromJson(recipeJson, RecipeDescriptor.class); - - String script = recipeDescriptor.getScript(); - - String host; - try { - Map m = JsonHelper.toMap(script); - host = m.containsKey("host") ? m.get("host") : "localhost"; - } catch (Exception e) { - host = "localhost"; - } - String description = host + " (" + machines.get(i).getConfig().getName() + ")"; - hosts.put(host, description); - } - - view.setHostsList(hosts); - } - }); - } - @Override public boolean isDirty() { return !originHost.equals(editedConfiguration.getHost()) @@ -228,9 +187,4 @@ public void onDevHostChanged(boolean value) { listener.onDirtyStateChanged(); } } - - private String getRecipeId(String location) { - location = location.substring(0, location.lastIndexOf("/")); - return location.substring(location.lastIndexOf("/") + 1); - } }