update IDE code in accordance to the updated workspace model
parent
e65d5435bc
commit
92eb80fd03
|
|
@ -11,7 +11,7 @@
|
|||
package org.eclipse.che.ide.api.command;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.macro.Macro;
|
||||
|
||||
/**
|
||||
|
|
@ -32,7 +32,7 @@ public interface CommandExecutor {
|
|||
* machine to execute the command
|
||||
* @see Macro
|
||||
*/
|
||||
void executeCommand(Command command, Machine machine);
|
||||
void executeCommand(Command command, MachineEntity machine);
|
||||
|
||||
/**
|
||||
* Sends the the given {@code command} for execution.
|
||||
|
|
|
|||
|
|
@ -10,16 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.api.command;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
|
||||
import java.util.Set;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
|
||||
/**
|
||||
* Defines the requirements for a component which can produce the commands from the current context.
|
||||
* <p>For every registered {@link CommandProducer} an appropriate action
|
||||
* will be added in context menus (e.g., explorer, editor tab).
|
||||
* <p>Implementor can restrict machine types where command may be executed with {@link #getMachineTypes()}.
|
||||
* In that case, sub menu will be created with separate sub actions which are correspond to each machine.
|
||||
* <p>Implementations of this interface have to be registered with
|
||||
* a GIN multibinder in order to be picked-up on application's start-up.
|
||||
*
|
||||
|
|
@ -41,11 +37,5 @@ public interface CommandProducer {
|
|||
* Target for command execution will be provided through {@code machine} parameter.
|
||||
* Called when user performs corresponded action.
|
||||
*/
|
||||
CommandImpl createCommand(Machine machine);
|
||||
|
||||
/**
|
||||
* Returns machine types for restricting machines where command may be executed.
|
||||
* If returns empty set then ws-agent will be used for executing a command.
|
||||
*/
|
||||
Set<String> getMachineTypes();
|
||||
CommandImpl createCommand(MachineEntity machine);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +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.component;
|
||||
|
||||
import com.google.gwt.core.client.Callback;
|
||||
|
||||
/**
|
||||
* Components that have to be started on application's startup
|
||||
* must implement this interface.
|
||||
* All components are registered via gin map binding.
|
||||
* For example, if you have YourComponent class, implementation of this interface, you must write in your GinModule this:
|
||||
* <code>
|
||||
* GinMapBinder<String, Component> mapBinder =
|
||||
* GinMapBinder.newMapBinder(binder(), String.class, Component.class);
|
||||
* mapBinder.addBinding("your key").to(YourComponent.class);
|
||||
* </code>
|
||||
*
|
||||
* @author Nikolay Zamosenchuk
|
||||
* @author Evgen Vidolob
|
||||
*/
|
||||
public interface Component {
|
||||
|
||||
/**
|
||||
* Starts Component.
|
||||
* Must do not throw any exceptions.
|
||||
* All exceptions must be passed in {@code Callback.onFailure(java.lang.Exception)}
|
||||
*/
|
||||
void start(Callback<Component, Exception> callback);
|
||||
}
|
||||
|
|
@ -1,35 +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.component;
|
||||
|
||||
import com.google.gwt.core.client.Callback;
|
||||
|
||||
/**
|
||||
* Defines the requirements for a component that have to be started after starting ws-agent.
|
||||
* <p>Component should be registered via GIN MapBinder:
|
||||
* <pre>
|
||||
* GinMapBinder<String, WsAgentComponent> mapBinder =
|
||||
* GinMapBinder.newMapBinder(binder(), String.class, WsAgentComponent.class);
|
||||
* mapBinder.addBinding("component key").to(YourComponent.class);
|
||||
* </pre>
|
||||
* <b>Note:</b> Ws Agent Component start order will be calculated upon component key.
|
||||
* All keys will be sorted in alphabet order.
|
||||
*
|
||||
* @author Artem Zatsarynnyi
|
||||
*/
|
||||
public interface WsAgentComponent {
|
||||
|
||||
/**
|
||||
* Starts component. Must do not throw any exceptions.
|
||||
* <p>All exceptions must be passed in {@code Callback.onFailure(Exception)}
|
||||
*/
|
||||
void start(Callback<WsAgentComponent, Exception> callback);
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ public class DevMachine extends MachineEntityImpl {
|
|||
if (url.endsWith("/")) {
|
||||
url = url.substring(0, url.length() - 1);
|
||||
}
|
||||
// FIXME: spi
|
||||
|
||||
return url + "/api";
|
||||
} else {
|
||||
//should not be
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ package org.eclipse.che.ide.api.machine.events;
|
|||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
|
||||
public class ProcessStartedEvent extends GwtEvent<ProcessStartedEvent.Handler> {
|
||||
|
||||
public static final Type<ProcessStartedEvent.Handler> TYPE = new Type<>();
|
||||
|
||||
private final int processID;
|
||||
private final Machine machine;
|
||||
private final int processID;
|
||||
private final MachineEntity machine;
|
||||
|
||||
public ProcessStartedEvent(int processID, Machine machine) {
|
||||
public ProcessStartedEvent(int processID, MachineEntity machine) {
|
||||
this.processID = processID;
|
||||
this.machine = machine;
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ public class ProcessStartedEvent extends GwtEvent<ProcessStartedEvent.Handler> {
|
|||
return processID;
|
||||
}
|
||||
|
||||
public Machine getMachine() {
|
||||
public MachineEntity getMachine() {
|
||||
return machine;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,16 +10,18 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.api.project;
|
||||
|
||||
import org.eclipse.che.api.project.shared.NewProjectConfig;
|
||||
import org.eclipse.che.api.core.model.workspace.config.SourceStorage;
|
||||
import org.eclipse.che.api.project.shared.NewProjectConfig;
|
||||
import org.eclipse.che.api.project.templates.shared.dto.ProjectTemplateDescriptor;
|
||||
import org.eclipse.che.api.project.shared.dto.NewProjectConfigDto;
|
||||
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
/**
|
||||
* Implementation of {@link NewProjectConfig} for creating project
|
||||
*
|
||||
|
|
@ -67,7 +69,7 @@ public class NewProjectConfigImpl implements NewProjectConfig {
|
|||
}
|
||||
|
||||
/** Constructor for creating configuration from DTO object */
|
||||
public NewProjectConfigImpl(NewProjectConfigDto dto) {
|
||||
public NewProjectConfigImpl(ProjectConfigDto dto) {
|
||||
this(dto.getName(),
|
||||
dto.getPath(),
|
||||
dto.getDescription(),
|
||||
|
|
@ -75,7 +77,7 @@ public class NewProjectConfigImpl implements NewProjectConfig {
|
|||
dto.getSource(),
|
||||
dto.getMixins(),
|
||||
dto.getAttributes(),
|
||||
dto.getOptions());
|
||||
emptyMap());
|
||||
}
|
||||
|
||||
public NewProjectConfigImpl(String name,
|
||||
|
|
|
|||
|
|
@ -61,6 +61,6 @@ public class RunCommandAction extends Action {
|
|||
|
||||
commandManager.getCommand(name)
|
||||
.ifPresent(command -> commandExecutor.executeCommand(command,
|
||||
appContext.getDevMachine().getDescriptor()));
|
||||
appContext.getDevMachine()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ package org.eclipse.che.ide.command;
|
|||
|
||||
import com.google.gwt.inject.client.AbstractGinModule;
|
||||
import com.google.gwt.inject.client.assistedinject.GinFactoryModuleBuilder;
|
||||
import com.google.gwt.inject.client.multibindings.GinMapBinder;
|
||||
import com.google.gwt.inject.client.multibindings.GinMultibinder;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Singleton;
|
||||
|
|
@ -25,7 +24,6 @@ import org.eclipse.che.ide.api.command.CommandGoalRegistry;
|
|||
import org.eclipse.che.ide.api.command.CommandManager;
|
||||
import org.eclipse.che.ide.api.command.CommandType;
|
||||
import org.eclipse.che.ide.api.command.CommandTypeRegistry;
|
||||
import org.eclipse.che.ide.api.component.Component;
|
||||
import org.eclipse.che.ide.api.filetypes.FileType;
|
||||
import org.eclipse.che.ide.command.editor.CommandEditorView;
|
||||
import org.eclipse.che.ide.command.editor.CommandEditorViewImpl;
|
||||
|
|
@ -100,9 +98,7 @@ public class CommandApiModule extends AbstractGinModule {
|
|||
bind(CommandManager.class).asEagerSingleton();
|
||||
bind(ExecuteCommandActionManager.class).asEagerSingleton();
|
||||
|
||||
// start-up components
|
||||
GinMapBinder<String, Component> componentBinder = GinMapBinder.newMapBinder(binder(), String.class, Component.class);
|
||||
componentBinder.addBinding("CommandProducerActionManager").to(CommandProducerActionManager.class);
|
||||
bind(CommandProducerActionManager.class).asEagerSingleton();
|
||||
|
||||
install(new GinFactoryModuleBuilder().build(ExecuteCommandActionFactory.class));
|
||||
install(new GinFactoryModuleBuilder().build(GoalPopUpGroupFactory.class));
|
||||
|
|
|
|||
|
|
@ -13,18 +13,18 @@ package org.eclipse.che.ide.command.execute;
|
|||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
import org.eclipse.che.ide.api.command.CommandExecutor;
|
||||
import org.eclipse.che.ide.api.command.CommandImpl;
|
||||
import org.eclipse.che.ide.api.machine.ExecAgentCommandManager;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.macro.MacroProcessor;
|
||||
import org.eclipse.che.ide.api.selection.Selection;
|
||||
import org.eclipse.che.ide.api.selection.SelectionAgent;
|
||||
import org.eclipse.che.ide.console.CommandConsoleFactory;
|
||||
import org.eclipse.che.ide.console.CommandOutputConsole;
|
||||
import org.eclipse.che.ide.processes.panel.ProcessesPanelPresenter;
|
||||
import org.eclipse.che.ide.machine.chooser.MachineChooser;
|
||||
import org.eclipse.che.ide.processes.panel.ProcessesPanelPresenter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ public class CommandExecutorImpl implements CommandExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(Command command, Machine machine) {
|
||||
public void executeCommand(Command command, MachineEntity machine) {
|
||||
final String name = command.getName();
|
||||
final String type = command.getType();
|
||||
final String commandLine = command.getCommandLine();
|
||||
|
|
@ -63,22 +63,21 @@ public class CommandExecutorImpl implements CommandExecutor {
|
|||
macroProcessor.expandMacros(commandLine).then(expandedCommandLine -> {
|
||||
final CommandImpl expandedCommand = new CommandImpl(name, expandedCommandLine, type, attributes);
|
||||
final CommandOutputConsole console = commandConsoleFactory.create(expandedCommand, machine);
|
||||
// FIXME: spi
|
||||
// final String machineId = machine.getId();
|
||||
//
|
||||
// processesPanelPresenter.addCommandOutput(machineId, console);
|
||||
//
|
||||
// execAgentClient.startProcess(machineId, expandedCommand)
|
||||
// .thenIfProcessStartedEvent(console.getProcessStartedConsumer())
|
||||
// .thenIfProcessDiedEvent(console.getProcessDiedConsumer())
|
||||
// .thenIfProcessStdOutEvent(console.getStdOutConsumer())
|
||||
// .thenIfProcessStdErrEvent(console.getStdErrConsumer());
|
||||
final String machineId = machine.getId();
|
||||
|
||||
processesPanelPresenter.addCommandOutput(machineId, console);
|
||||
|
||||
execAgentClient.startProcess(machineId, expandedCommand)
|
||||
.thenIfProcessStartedEvent(console.getProcessStartedConsumer())
|
||||
.thenIfProcessDiedEvent(console.getProcessDiedConsumer())
|
||||
.thenIfProcessStdOutEvent(console.getStdOutConsumer())
|
||||
.thenIfProcessStdErrEvent(console.getStdErrConsumer());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandImpl command) {
|
||||
final Machine selectedMachine = getSelectedMachine();
|
||||
final MachineEntity selectedMachine = getSelectedMachine();
|
||||
|
||||
if (selectedMachine != null) {
|
||||
executeCommand(command, selectedMachine);
|
||||
|
|
@ -91,14 +90,14 @@ public class CommandExecutorImpl implements CommandExecutor {
|
|||
|
||||
/** Returns the currently selected machine or {@code null} if none. */
|
||||
@Nullable
|
||||
private Machine getSelectedMachine() {
|
||||
private MachineEntity getSelectedMachine() {
|
||||
final Selection<?> selection = selectionAgent.getSelection();
|
||||
|
||||
if (selection != null && !selection.isEmpty() && selection.isSingleSelection()) {
|
||||
final Object possibleNode = selection.getHeadElement();
|
||||
|
||||
if (possibleNode instanceof Machine) {
|
||||
return (Machine)possibleNode;
|
||||
if (possibleNode instanceof MachineEntity) {
|
||||
return (MachineEntity)possibleNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ package org.eclipse.che.ide.command.producer;
|
|||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.action.Action;
|
||||
import org.eclipse.che.ide.api.action.ActionEvent;
|
||||
import org.eclipse.che.ide.api.command.CommandImpl;
|
||||
import org.eclipse.che.ide.api.command.CommandExecutor;
|
||||
import org.eclipse.che.ide.api.command.CommandImpl;
|
||||
import org.eclipse.che.ide.api.command.CommandProducer;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
|
||||
/**
|
||||
* Action for executing command which produced by {@link CommandProducer}.
|
||||
|
|
@ -29,13 +29,13 @@ import org.eclipse.che.ide.api.command.CommandProducer;
|
|||
public class CommandProducerAction extends Action {
|
||||
|
||||
private final CommandProducer commandProducer;
|
||||
private final Machine machine;
|
||||
private final MachineEntity machine;
|
||||
private final CommandExecutor commandExecutor;
|
||||
|
||||
@Inject
|
||||
public CommandProducerAction(@Assisted String name,
|
||||
@Assisted CommandProducer commandProducer,
|
||||
@Assisted Machine machine,
|
||||
@Assisted MachineEntity machine,
|
||||
CommandExecutor commandExecutor) {
|
||||
super(name);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.command.producer;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.command.CommandProducer;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
|
||||
/**
|
||||
* Factory for creating {@link CommandProducerAction} instances.
|
||||
|
|
@ -21,5 +21,5 @@ import org.eclipse.che.ide.api.command.CommandProducer;
|
|||
public interface CommandProducerActionFactory {
|
||||
|
||||
/** Creates action for executing command produced by the specified {@code commandProducer}. */
|
||||
CommandProducerAction create(String name, CommandProducer commandProducer, Machine machine);
|
||||
CommandProducerAction create(String name, CommandProducer commandProducer, MachineEntity machine);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,10 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.command.producer;
|
||||
|
||||
import com.google.gwt.core.client.Callback;
|
||||
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.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.Resources;
|
||||
import org.eclipse.che.ide.api.action.Action;
|
||||
import org.eclipse.che.ide.api.action.ActionEvent;
|
||||
|
|
@ -23,18 +21,11 @@ import org.eclipse.che.ide.api.action.ActionManager;
|
|||
import org.eclipse.che.ide.api.action.DefaultActionGroup;
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
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.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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.eclipse.che.ide.api.action.IdeActions.GROUP_EDITOR_TAB_CONTEXT_MENU;
|
||||
|
|
@ -45,17 +36,11 @@ import static org.eclipse.che.ide.api.constraints.Anchor.AFTER;
|
|||
/**
|
||||
* Manages actions for the commands.
|
||||
* <p>Manager gets all registered {@link CommandProducer}s and creates related actions in context menus.
|
||||
* <p>Manager listens all machines's state (running/destroyed) in order to
|
||||
* create/remove actions for the related {@link CommandProducer}s in case
|
||||
* they are applicable only for the certain machine types.
|
||||
*
|
||||
* @author Artem Zatsarynnyi
|
||||
* @see CommandProducer
|
||||
*/
|
||||
@Singleton
|
||||
public class CommandProducerActionManager implements MachineStateEvent.Handler,
|
||||
WsAgentStateHandler,
|
||||
Component {
|
||||
public class CommandProducerActionManager implements WsAgentStateHandler {
|
||||
|
||||
private final ActionManager actionManager;
|
||||
private final CommandProducerActionFactory commandProducerActionFactory;
|
||||
|
|
@ -63,11 +48,7 @@ public class CommandProducerActionManager implements MachineStateEvent.Handler,
|
|||
private final Resources resources;
|
||||
private final ProducerMessages messages;
|
||||
|
||||
private final List<Machine> machines;
|
||||
private final Set<CommandProducer> commandProducers;
|
||||
private final Map<Action, DefaultActionGroup> actionsToActionGroups;
|
||||
private final Map<Machine, List<Action>> actionsByMachines;
|
||||
private final Map<CommandProducer, DefaultActionGroup> producersToActionGroups;
|
||||
private final Set<CommandProducer> commandProducers;
|
||||
|
||||
private DefaultActionGroup commandActionsPopUpGroup;
|
||||
|
||||
|
|
@ -84,13 +65,8 @@ public class CommandProducerActionManager implements MachineStateEvent.Handler,
|
|||
this.resources = resources;
|
||||
this.messages = messages;
|
||||
|
||||
machines = new ArrayList<>();
|
||||
commandProducers = new HashSet<>();
|
||||
actionsToActionGroups = new HashMap<>();
|
||||
actionsByMachines = new HashMap<>();
|
||||
producersToActionGroups = new HashMap<>();
|
||||
|
||||
eventBus.addHandler(MachineStateEvent.TYPE, this);
|
||||
eventBus.addHandler(WsAgentStateEvent.TYPE, this);
|
||||
}
|
||||
|
||||
|
|
@ -116,34 +92,6 @@ public class CommandProducerActionManager implements MachineStateEvent.Handler,
|
|||
mainToolbarGroup.add(commandActionsToolbarGroup, new Constraints(AFTER, "changeResourceGroup"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(final Callback<Component, Exception> callback) {
|
||||
ActiveRuntime activeRuntime = appContext.getActiveRuntime();
|
||||
if (activeRuntime != null) {
|
||||
machines.addAll(activeRuntime.getMachines());
|
||||
}
|
||||
|
||||
callback.onSuccess(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineCreating(MachineStateEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineRunning(MachineStateEvent event) {
|
||||
machines.add(event.getMachine());
|
||||
|
||||
createActionsForMachine(event.getMachine());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineDestroyed(MachineStateEvent event) {
|
||||
machines.remove(event.getMachine());
|
||||
|
||||
removeActionsForMachine(event.getMachine());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWsAgentStarted(WsAgentStateEvent event) {
|
||||
for (CommandProducer commandProducer : commandProducers) {
|
||||
|
|
@ -157,69 +105,11 @@ public class CommandProducerActionManager implements MachineStateEvent.Handler,
|
|||
|
||||
/** Creates actions for the given {@link CommandProducer}. */
|
||||
private void createActionsForProducer(CommandProducer producer) {
|
||||
// FIXME: spi
|
||||
// Action action;
|
||||
Action action = commandProducerActionFactory.create(producer.getName(), producer, appContext.getDevMachine());
|
||||
|
||||
// if (producer.getMachineTypes().isEmpty()) {
|
||||
// action = commandProducerActionFactory.create(producer.getName(), producer, appContext.getDevMachine().getDescriptor());
|
||||
//
|
||||
// actionManager.registerAction(producer.getName(), action);
|
||||
// } else {
|
||||
// action = new DefaultActionGroup(producer.getName(), true, actionManager);
|
||||
//
|
||||
// producersToActionGroups.put(producer, (DefaultActionGroup)action);
|
||||
//
|
||||
// actionManager.registerAction(producer.getName(), action);
|
||||
//
|
||||
// for (Machine machine : machines) {
|
||||
// createActionsForMachine(machine);
|
||||
// }
|
||||
// }
|
||||
actionManager.registerAction(producer.getName(), action);
|
||||
|
||||
// commandActionsPopUpGroup.add(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates actions for that {@link CommandProducer}s
|
||||
* which are applicable for the given machine's type.
|
||||
*/
|
||||
private void createActionsForMachine(Machine machine) {
|
||||
// FIXME: spi
|
||||
// for (CommandProducer commandProducer : commandProducers) {
|
||||
// if (commandProducer.getMachineTypes().contains(machine.getConfig().getType())) {
|
||||
// CommandProducerAction machineAction = commandProducerActionFactory.create(machine.getConfig().getName(),
|
||||
// commandProducer,
|
||||
// machine);
|
||||
// final List<Action> actionList = actionsByMachines.computeIfAbsent(machine, key -> new ArrayList<>());
|
||||
// actionList.add(machineAction);
|
||||
//
|
||||
// actionManager.registerAction(machine.getConfig().getName(), machineAction);
|
||||
//
|
||||
// DefaultActionGroup actionGroup = producersToActionGroups.get(commandProducer);
|
||||
// if (actionGroup != null) {
|
||||
// actionGroup.add(machineAction);
|
||||
//
|
||||
// actionsToActionGroups.put(machineAction, actionGroup);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private void removeActionsForMachine(Machine machine) {
|
||||
List<Action> actions = actionsByMachines.remove(machine);
|
||||
if (actions != null) {
|
||||
for (Action action : actions) {
|
||||
DefaultActionGroup actionGroup = actionsToActionGroups.remove(action);
|
||||
if (actionGroup != null) {
|
||||
actionGroup.remove(action);
|
||||
|
||||
String id = actionManager.getId(action);
|
||||
if (id != null) {
|
||||
actionManager.unregisterAction(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
commandActionsPopUpGroup.add(action);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import com.google.inject.Provider;
|
|||
import com.google.inject.Singleton;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.command.CommandAddedEvent;
|
||||
import org.eclipse.che.ide.api.command.CommandExecutor;
|
||||
import org.eclipse.che.ide.api.command.CommandGoal;
|
||||
|
|
@ -25,6 +24,7 @@ import org.eclipse.che.ide.api.command.CommandManager;
|
|||
import org.eclipse.che.ide.api.command.CommandRemovedEvent;
|
||||
import org.eclipse.che.ide.api.command.CommandUpdatedEvent;
|
||||
import org.eclipse.che.ide.api.command.CommandsLoadedEvent;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.mvp.Presenter;
|
||||
import org.eclipse.che.ide.command.goal.DebugGoal;
|
||||
import org.eclipse.che.ide.command.goal.RunGoal;
|
||||
|
|
@ -84,7 +84,7 @@ public class ExecuteCommandPresenter implements Presenter, ExecuteCommandView.Ac
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCommandExecute(CommandImpl command, Machine machine) {
|
||||
public void onCommandExecute(CommandImpl command, MachineEntity machine) {
|
||||
commandExecutorProvider.get().executeCommand(command, machine);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.command.toolbar.commands;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.command.CommandGoal;
|
||||
import org.eclipse.che.ide.api.command.CommandImpl;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.mvp.View;
|
||||
|
||||
import java.util.Set;
|
||||
|
|
@ -35,7 +35,7 @@ public interface ExecuteCommandView extends View<ExecuteCommandView.ActionDelega
|
|||
void onCommandExecute(CommandImpl command);
|
||||
|
||||
/** Called when command execution has been requested on the specified machine. */
|
||||
void onCommandExecute(CommandImpl command, Machine machine);
|
||||
void onCommandExecute(CommandImpl command, MachineEntity machine);
|
||||
|
||||
/** Called when guide of commands creation has been requested. */
|
||||
void onGuide(CommandGoal goal);
|
||||
|
|
|
|||
|
|
@ -13,21 +13,21 @@ package org.eclipse.che.ide.command.toolbar.commands.button;
|
|||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.command.CommandImpl;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
|
||||
/** Item contains {@link CommandImpl} and {@link Machine}. */
|
||||
/** Item contains {@link CommandImpl} and {@link MachineEntity}. */
|
||||
public class MachineItem extends AbstractMenuItem {
|
||||
|
||||
private final Machine machine;
|
||||
private final String name;
|
||||
// FIXME: spi
|
||||
private final MachineEntity machine;
|
||||
private final String name;
|
||||
|
||||
@AssistedInject
|
||||
public MachineItem(@Assisted CommandImpl command, @Assisted Machine machine) {
|
||||
public MachineItem(@Assisted CommandImpl command, @Assisted MachineEntity machine) {
|
||||
super(command);
|
||||
|
||||
this.machine = machine;
|
||||
this.name = ""/*machine.getConfig().getName()*/;
|
||||
this.name = machine.getName();
|
||||
}
|
||||
|
||||
@AssistedInject
|
||||
|
|
@ -35,7 +35,7 @@ public class MachineItem extends AbstractMenuItem {
|
|||
super(item.getCommand());
|
||||
|
||||
this.machine = item.machine;
|
||||
this.name = getCommand().getName() + " on "/* + machine.getConfig().getName()*/;
|
||||
this.name = getCommand().getName() + " on " + machine.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -43,7 +43,7 @@ public class MachineItem extends AbstractMenuItem {
|
|||
return name;
|
||||
}
|
||||
|
||||
public Machine getMachine() {
|
||||
public MachineEntity getMachine() {
|
||||
return machine;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.command.toolbar.commands.button;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.command.CommandGoal;
|
||||
import org.eclipse.che.ide.api.command.CommandImpl;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.ui.menubutton.MenuItem;
|
||||
|
||||
/** Factory for {@link MenuItem}s for {@link ExecuteCommandButton}. */
|
||||
|
|
@ -22,7 +22,7 @@ public interface MenuItemsFactory {
|
|||
|
||||
CommandItem newCommandItem(CommandImpl command);
|
||||
|
||||
MachineItem newMachineItem(CommandImpl command, Machine machine);
|
||||
MachineItem newMachineItem(CommandImpl command, MachineEntity machine);
|
||||
|
||||
MachineItem newMachineItem(MachineItem item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import org.eclipse.che.api.core.model.workspace.runtime.Server;
|
|||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.machine.DevMachine;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -47,12 +46,10 @@ class PreviewUrl {
|
|||
|
||||
private String getDisplayNameForPreviewUrl(String previewUrl) {
|
||||
final DevMachine devMachine = appContext.getDevMachine();
|
||||
// FIXME: spi
|
||||
// final MachineRuntimeInfo devMachineRuntime = devMachine.getRuntime();
|
||||
|
||||
// if (devMachineRuntime == null) {
|
||||
// return previewUrl;
|
||||
// }
|
||||
if (devMachine == null) {
|
||||
return previewUrl;
|
||||
}
|
||||
|
||||
for (Entry<String, ? extends Server> entry : devMachine.getServers().entrySet()) {
|
||||
Server server = entry.getValue();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import com.google.inject.Provider;
|
|||
import com.google.inject.Singleton;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.api.machine.shared.dto.execagent.GetProcessesResponseDto;
|
||||
import org.eclipse.che.api.promises.client.Promise;
|
||||
import org.eclipse.che.api.promises.client.PromiseProvider;
|
||||
|
|
@ -26,6 +25,7 @@ import org.eclipse.che.ide.api.command.CommandImpl;
|
|||
import org.eclipse.che.ide.api.command.CommandManager;
|
||||
import org.eclipse.che.ide.api.machine.ActiveRuntime;
|
||||
import org.eclipse.che.ide.api.machine.ExecAgentCommandManager;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.machine.events.ProcessFinishedEvent;
|
||||
import org.eclipse.che.ide.api.machine.events.ProcessStartedEvent;
|
||||
import org.eclipse.che.ide.api.machine.events.WsAgentStateEvent;
|
||||
|
|
@ -91,15 +91,14 @@ public class PreviewsPresenter implements Presenter, PreviewsView.ActionDelegate
|
|||
return;
|
||||
}
|
||||
|
||||
// FIXME: spi
|
||||
// runtime.getMachines()
|
||||
// .stream()
|
||||
// .map(Machine::getId)
|
||||
// .map(id -> execAgentClient.getProcesses(id, false))
|
||||
// .forEach(promise -> promise.onSuccess(processes -> processes.stream()
|
||||
// .map(GetProcessesResponseDto::getName)
|
||||
// .map(this::getPreviewUrlByName)
|
||||
// .forEach(it -> it.then(view::addUrl))));
|
||||
runtime.getMachines()
|
||||
.stream()
|
||||
.map(MachineEntity::getId)
|
||||
.map(id -> execAgentClient.getProcesses(id, false))
|
||||
.forEach(promise -> promise.onSuccess(processes -> processes.stream()
|
||||
.map(GetProcessesResponseDto::getName)
|
||||
.map(this::getPreviewUrlByName)
|
||||
.forEach(it -> it.then(view::addUrl))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.command.toolbar.processes;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
|
||||
/** Model of the process. */
|
||||
public interface Process {
|
||||
|
|
@ -23,5 +23,5 @@ public interface Process {
|
|||
|
||||
boolean isAlive();
|
||||
|
||||
Machine getMachine();
|
||||
MachineEntity getMachine();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,20 +10,20 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.command.toolbar.processes;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/** Data object for {@link Process}. */
|
||||
public class ProcessImpl implements Process {
|
||||
|
||||
private final String commandName;
|
||||
private final String commandLine;
|
||||
private final int pid;
|
||||
private final boolean alive;
|
||||
private final Machine machine;
|
||||
private final String commandName;
|
||||
private final String commandLine;
|
||||
private final int pid;
|
||||
private final boolean alive;
|
||||
private final MachineEntity machine;
|
||||
|
||||
public ProcessImpl(String commandName, String commandLine, int pid, boolean alive, Machine machine) {
|
||||
public ProcessImpl(String commandName, String commandLine, int pid, boolean alive, MachineEntity machine) {
|
||||
this.commandName = commandName;
|
||||
this.commandLine = commandLine;
|
||||
this.pid = pid;
|
||||
|
|
@ -52,7 +52,7 @@ public class ProcessImpl implements Process {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Machine getMachine() {
|
||||
public MachineEntity getMachine() {
|
||||
return machine;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,8 +85,7 @@ class ProcessWidget extends FlowPanel {
|
|||
}
|
||||
|
||||
private Label createMachineNameLabel(Process process) {
|
||||
// FIXME: spi
|
||||
final Label label = new InlineHTML(/*process.getMachine().getConfig().getName() + */": ");
|
||||
final Label label = new InlineHTML(process.getMachine().getName() + ": ");
|
||||
|
||||
label.addStyleName(RESOURCES.commandToolbarCss().processWidgetText());
|
||||
label.addStyleName(RESOURCES.commandToolbarCss().processWidgetMachineNameLabel());
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import com.google.gwt.user.client.ui.AcceptsOneWidget;
|
|||
import com.google.inject.Provider;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.api.machine.shared.dto.execagent.GetProcessesResponseDto;
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.command.CommandExecutor;
|
||||
|
|
@ -135,9 +134,8 @@ public class ProcessesListPresenter implements Presenter, ProcessesListView.Acti
|
|||
* @param machine
|
||||
* machine where process were run or currently running
|
||||
*/
|
||||
private void addProcessToList(int pid, Machine machine) {
|
||||
// FIXME: spi
|
||||
execAgentClient.getProcess(""/*machine.getId()*/, pid).onSuccess(processDto -> {
|
||||
private void addProcessToList(int pid, MachineEntity machine) {
|
||||
execAgentClient.getProcess(machine.getId(), pid).onSuccess(processDto -> {
|
||||
final Process process = new ProcessImpl(processDto.getName(),
|
||||
processDto.getCommandLine(),
|
||||
processDto.getPid(),
|
||||
|
|
@ -167,8 +165,7 @@ public class ProcessesListPresenter implements Presenter, ProcessesListView.Acti
|
|||
|
||||
@Override
|
||||
public void onStopProcess(Process process) {
|
||||
// FIXME: spi
|
||||
execAgentClient.killProcess(""/*process.getMachine().getId()*/, process.getPid());
|
||||
execAgentClient.killProcess(process.getMachine().getId(), process.getPid());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -12,16 +12,16 @@ package org.eclipse.che.ide.console;
|
|||
|
||||
import com.google.inject.name.Named;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.outputconsole.OutputConsole;
|
||||
import org.eclipse.che.ide.api.command.CommandImpl;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.outputconsole.OutputConsole;
|
||||
|
||||
/** @author Artem Zatsarynnyi */
|
||||
public interface CommandConsoleFactory {
|
||||
|
||||
/** Create the instance of {@link CommandOutputConsole} for the given {@code command}. */
|
||||
@Named("command")
|
||||
CommandOutputConsole create(CommandImpl command, Machine machine);
|
||||
CommandOutputConsole create(CommandImpl command, MachineEntity machine);
|
||||
|
||||
/** Create the instance of {@link DefaultOutputConsole} for the given title. */
|
||||
@Named("default")
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineProcessDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.execagent.ProcessSubscribeResponseDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.execagent.event.ProcessDiedEventDto;
|
||||
|
|
@ -28,6 +27,7 @@ import org.eclipse.che.commons.annotation.Nullable;
|
|||
import org.eclipse.che.ide.api.command.CommandExecutor;
|
||||
import org.eclipse.che.ide.api.command.CommandImpl;
|
||||
import org.eclipse.che.ide.api.machine.ExecAgentCommandManager;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.machine.events.ProcessFinishedEvent;
|
||||
import org.eclipse.che.ide.api.machine.events.ProcessStartedEvent;
|
||||
import org.eclipse.che.ide.api.macro.MacroProcessor;
|
||||
|
|
@ -52,7 +52,7 @@ public class CommandOutputConsolePresenter implements CommandOutputConsole, Outp
|
|||
private final MachineResources resources;
|
||||
private final CommandImpl command;
|
||||
private final EventBus eventBus;
|
||||
private final Machine machine;
|
||||
private final MachineEntity machine;
|
||||
private final CommandExecutor commandExecutor;
|
||||
private final ExecAgentCommandManager execAgentCommandManager;
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ public class CommandOutputConsolePresenter implements CommandOutputConsole, Outp
|
|||
EventBus eventBus,
|
||||
ExecAgentCommandManager execAgentCommandManager,
|
||||
@Assisted CommandImpl command,
|
||||
@Assisted Machine machine) {
|
||||
@Assisted MachineEntity machine) {
|
||||
this.view = view;
|
||||
this.resources = resources;
|
||||
this.execAgentCommandManager = execAgentCommandManager;
|
||||
|
|
@ -204,8 +204,7 @@ public class CommandOutputConsolePresenter implements CommandOutputConsole, Outp
|
|||
|
||||
@Override
|
||||
public void stop() {
|
||||
// FIXME: spi
|
||||
execAgentCommandManager.killProcess(""/*machine.getId()*/, pid);
|
||||
execAgentCommandManager.killProcess(machine.getId(), pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -223,8 +222,7 @@ public class CommandOutputConsolePresenter implements CommandOutputConsole, Outp
|
|||
if (isFinished()) {
|
||||
commandExecutor.executeCommand(command, machine);
|
||||
} else {
|
||||
// FIXME: spi
|
||||
execAgentCommandManager.killProcess(""/*machine.getId()*/, pid)
|
||||
execAgentCommandManager.killProcess(machine.getId(), pid)
|
||||
.onSuccess(() -> commandExecutor.executeCommand(command, machine));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,9 +79,7 @@ import org.eclipse.che.ide.imageviewer.ImageViewerProvider;
|
|||
import org.eclipse.che.ide.imageviewer.PreviewImageAction;
|
||||
import org.eclipse.che.ide.machine.MachineResources;
|
||||
import org.eclipse.che.ide.macro.ServerHostNameMacro;
|
||||
import org.eclipse.che.ide.macro.ServerMacro;
|
||||
import org.eclipse.che.ide.macro.ServerPortMacro;
|
||||
import org.eclipse.che.ide.macro.ServerProtocolMacro;
|
||||
import org.eclipse.che.ide.newresource.NewFileAction;
|
||||
import org.eclipse.che.ide.newresource.NewFolderAction;
|
||||
import org.eclipse.che.ide.part.editor.actions.CloseAction;
|
||||
|
|
@ -477,13 +475,6 @@ public class StandardComponentInitializer {
|
|||
@Inject
|
||||
private TreeResourceRevealer treeResourceRevealer; //just to work with it
|
||||
|
||||
// do not remove the injections below
|
||||
@Inject
|
||||
private ServerMacro serverMacro;
|
||||
|
||||
@Inject
|
||||
private ServerProtocolMacro serverProtocolMacro;
|
||||
|
||||
@Inject
|
||||
private ServerHostNameMacro serverHostNameMacro;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +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.machine;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineDto;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntityImpl;
|
||||
|
||||
/**
|
||||
* The class which describes machine entity.
|
||||
*
|
||||
* @author Dmitry Shnurenko
|
||||
* @author Roman Nikitenko
|
||||
*/
|
||||
public class MachineItem extends MachineEntityImpl {
|
||||
|
||||
@Inject
|
||||
public MachineItem(@Assisted MachineDto descriptor) {
|
||||
// FIXME: spi
|
||||
super("", descriptor);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ package org.eclipse.che.ide.machine.chooser;
|
|||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.Runtime;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.api.promises.client.Promise;
|
||||
import org.eclipse.che.api.promises.client.PromiseProvider;
|
||||
|
|
@ -22,9 +21,10 @@ import org.eclipse.che.api.promises.client.js.JsPromiseError;
|
|||
import org.eclipse.che.api.promises.client.js.RejectFunction;
|
||||
import org.eclipse.che.api.promises.client.js.ResolveFunction;
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.machine.ActiveRuntime;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Provides a simple mechanism for the user to choose a {@link Machine}.
|
||||
|
|
@ -37,8 +37,8 @@ public class MachineChooser implements MachineChooserView.ActionDelegate {
|
|||
private final AppContext appContext;
|
||||
private final PromiseProvider promiseProvider;
|
||||
|
||||
private ResolveFunction<Machine> resolveFunction;
|
||||
private RejectFunction rejectFunction;
|
||||
private ResolveFunction<MachineEntity> resolveFunction;
|
||||
private RejectFunction rejectFunction;
|
||||
|
||||
@Inject
|
||||
public MachineChooser(MachineChooserView view,
|
||||
|
|
@ -56,33 +56,32 @@ public class MachineChooser implements MachineChooserView.ActionDelegate {
|
|||
* <p><b>Note:</b> if there is only one machine running in the workspace
|
||||
* then returned promise will be resolved with that machine without asking user.
|
||||
*
|
||||
* @return promise that will be resolved with a chosen {@link Machine}
|
||||
* @return promise that will be resolved with a chosen {@link MachineEntity}
|
||||
* or rejected in case machine selection has been cancelled.
|
||||
*/
|
||||
public Promise<Machine> show() {
|
||||
final Runtime runtime = appContext.getWorkspace().getRuntime();
|
||||
public Promise<MachineEntity> show() {
|
||||
final ActiveRuntime runtime = appContext.getActiveRuntime();
|
||||
|
||||
if (runtime != null) {
|
||||
final Map<String, ? extends Machine> machines = runtime.getMachines();
|
||||
final List<MachineEntity> machines = runtime.getMachines();
|
||||
|
||||
if (machines.size() == 1) {
|
||||
return promiseProvider.resolve(machines.get(0));
|
||||
}
|
||||
|
||||
// FIXME: spi
|
||||
// view.setMachines(machines);
|
||||
view.setMachines(machines);
|
||||
}
|
||||
|
||||
view.show();
|
||||
|
||||
return promiseProvider.create(Executor.create((ExecutorBody<Machine>)(resolve, reject) -> {
|
||||
return promiseProvider.create(Executor.create((ExecutorBody<MachineEntity>)(resolve, reject) -> {
|
||||
resolveFunction = resolve;
|
||||
rejectFunction = reject;
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineSelected(Machine machine) {
|
||||
public void onMachineSelected(MachineEntity machine) {
|
||||
view.close();
|
||||
|
||||
resolveFunction.apply(machine);
|
||||
|
|
|
|||
|
|
@ -10,12 +10,11 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.machine.chooser;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.mvp.View;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Contract for the view of the machine chooser.
|
||||
*
|
||||
|
|
@ -30,13 +29,13 @@ public interface MachineChooserView extends View<MachineChooserView.ActionDelega
|
|||
void close();
|
||||
|
||||
/** Sets the machines to display in the view. */
|
||||
void setMachines(List<? extends Machine> machines);
|
||||
void setMachines(List<MachineEntity> machines);
|
||||
|
||||
/** The action delegate for this view. */
|
||||
interface ActionDelegate {
|
||||
|
||||
/** Called when machine is selected. */
|
||||
void onMachineSelected(Machine machine);
|
||||
void onMachineSelected(MachineEntity machine);
|
||||
|
||||
/** Called when machine selection has been canceled. Note that view will be already closed. */
|
||||
void onCanceled();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import com.google.gwt.user.client.ui.ListBox;
|
|||
import com.google.gwt.user.client.ui.PopupPanel;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -36,7 +36,7 @@ public class MachineChooserViewImpl extends PopupPanel implements MachineChooser
|
|||
private static final MachineChooserViewImplUiBinder UI_BINDER = GWT.create(MachineChooserViewImplUiBinder.class);
|
||||
|
||||
/** Map that contains all shown machines. */
|
||||
private final Map<String, Machine> machinesById;
|
||||
private final Map<String, MachineEntity> machinesById;
|
||||
|
||||
@UiField
|
||||
ListBox machinesList;
|
||||
|
|
@ -70,7 +70,7 @@ public class MachineChooserViewImpl extends PopupPanel implements MachineChooser
|
|||
final String selectedMachineId = machinesList.getSelectedValue();
|
||||
|
||||
if (selectedMachineId != null) {
|
||||
final Machine selectedMachine = machinesById.get(selectedMachineId);
|
||||
final MachineEntity selectedMachine = machinesById.get(selectedMachineId);
|
||||
|
||||
if (selectedMachine != null) {
|
||||
delegate.onMachineSelected(selectedMachine);
|
||||
|
|
@ -85,7 +85,7 @@ public class MachineChooserViewImpl extends PopupPanel implements MachineChooser
|
|||
final String selectedMachineId = machinesList.getSelectedValue();
|
||||
|
||||
if (selectedMachineId != null) {
|
||||
final Machine selectedMachine = machinesById.get(selectedMachineId);
|
||||
final MachineEntity selectedMachine = machinesById.get(selectedMachineId);
|
||||
|
||||
if (selectedMachine != null) {
|
||||
delegate.onMachineSelected(selectedMachine);
|
||||
|
|
@ -120,14 +120,13 @@ public class MachineChooserViewImpl extends PopupPanel implements MachineChooser
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setMachines(List<? extends Machine> machines) {
|
||||
public void setMachines(List<MachineEntity> machines) {
|
||||
machinesList.clear();
|
||||
machinesById.clear();
|
||||
|
||||
machines.forEach(machine -> {
|
||||
// FIXME: spi
|
||||
// machinesById.put(machine.getId(), machine);
|
||||
// machinesList.addItem(machine.getConfig().getName(), machine.getId());
|
||||
machinesById.put(machine.getId(), machine);
|
||||
machinesList.addItem(machine.getName(), machine.getId());
|
||||
});
|
||||
|
||||
machinesList.setVisibleItemCount(machines.size());
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ import com.google.common.annotations.Beta;
|
|||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.macro.Macro;
|
||||
import org.eclipse.che.ide.api.macro.MacroRegistry;
|
||||
import org.eclipse.che.ide.api.machine.DevMachine;
|
||||
import org.eclipse.che.ide.api.machine.events.WsAgentStateEvent;
|
||||
import org.eclipse.che.ide.api.machine.events.WsAgentStateHandler;
|
||||
import org.eclipse.che.ide.api.macro.Macro;
|
||||
import org.eclipse.che.ide.api.macro.MacroRegistry;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -32,9 +32,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
* @see MacroRegistry
|
||||
* @see Macro
|
||||
* @see ServerHostNameMacro
|
||||
* @see ServerMacro
|
||||
* @see ServerPortMacro
|
||||
* @see ServerProtocolMacro
|
||||
* @since 4.7.0
|
||||
*/
|
||||
@Beta
|
||||
|
|
|
|||
|
|
@ -11,16 +11,20 @@
|
|||
package org.eclipse.che.ide.macro;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Sets;
|
||||
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.workspace.runtime.Server;
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.machine.DevMachine;
|
||||
import org.eclipse.che.ide.api.macro.BaseMacro;
|
||||
import org.eclipse.che.ide.api.macro.Macro;
|
||||
import org.eclipse.che.ide.api.macro.MacroRegistry;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
|
@ -51,30 +55,29 @@ public class ServerHostNameMacro extends AbstractServerMacro {
|
|||
public Set<Macro> getMacros(DevMachine devMachine) {
|
||||
final Set<Macro> macros = Sets.newHashSet();
|
||||
|
||||
// FIXME: spi
|
||||
// for (Map.Entry<String, ? extends Server> entry : devMachine.getDescriptor().getServers().entrySet()) {
|
||||
//
|
||||
// if (Strings.isNullOrEmpty(entry.getValue().getRef())) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// Macro macro = new BaseMacro(KEY.replace("%", entry.getKey()),
|
||||
// entry.getValue().getRef(),
|
||||
// "Returns hostname of a server registered by name");
|
||||
//
|
||||
// macros.add(macro);
|
||||
//
|
||||
// // register port without "/tcp" suffix
|
||||
// if (entry.getKey().endsWith("/tcp")) {
|
||||
// final String port = entry.getKey().substring(0, entry.getKey().length() - 4);
|
||||
//
|
||||
// Macro shortMacro = new BaseMacro(KEY.replace("%", port),
|
||||
// entry.getValue().getRef(),
|
||||
// "Returns hostname of a server registered by name");
|
||||
//
|
||||
// macros.add(shortMacro);
|
||||
// }
|
||||
// }
|
||||
for (Map.Entry<String, ? extends Server> entry : devMachine.getDescriptor().getServers().entrySet()) {
|
||||
|
||||
if (Strings.isNullOrEmpty(entry.getValue().getUrl())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Macro macro = new BaseMacro(KEY.replace("%", entry.getKey()),
|
||||
entry.getValue().getUrl(),
|
||||
"Returns hostname of a server registered by name");
|
||||
|
||||
macros.add(macro);
|
||||
|
||||
// register port without "/tcp" suffix
|
||||
if (entry.getKey().endsWith("/tcp")) {
|
||||
final String port = entry.getKey().substring(0, entry.getKey().length() - 4);
|
||||
|
||||
Macro shortMacro = new BaseMacro(KEY.replace("%", port),
|
||||
entry.getValue().getUrl(),
|
||||
"Returns hostname of a server registered by name");
|
||||
|
||||
macros.add(shortMacro);
|
||||
}
|
||||
}
|
||||
|
||||
return macros;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,80 +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.macro;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.machine.DevMachine;
|
||||
import org.eclipse.che.ide.api.macro.Macro;
|
||||
import org.eclipse.che.ide.api.macro.MacroRegistry;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Macro which is responsible for the retrieving the address of the registered server.
|
||||
* <p>
|
||||
* Macro provided: <code>${server.[port]}</code>
|
||||
*
|
||||
* @author Vlad Zhukovskyi
|
||||
* @see AbstractServerMacro
|
||||
* @see DevMachine
|
||||
* @since 4.7.0
|
||||
*/
|
||||
@Beta
|
||||
@Singleton
|
||||
public class ServerMacro extends AbstractServerMacro {
|
||||
|
||||
public static final String KEY = "${server.%}";
|
||||
|
||||
@Inject
|
||||
public ServerMacro(MacroRegistry macroRegistry,
|
||||
EventBus eventBus,
|
||||
AppContext appContext) {
|
||||
super(macroRegistry, eventBus, appContext);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Set<Macro> getMacros(DevMachine devMachine) {
|
||||
final Set<Macro> macros = Sets.newHashSet();
|
||||
|
||||
// FIXME: spi
|
||||
// for (Map.Entry<String, ? extends Server> entry : devMachine.getDescriptor().getRuntime().getServers().entrySet()) {
|
||||
//
|
||||
// final String prefix = isNullOrEmpty(entry.getValue().getProtocol()) ? "" : entry.getValue().getProtocol() + "://";
|
||||
// final String value = prefix + entry.getValue().getAddress() + (isNullOrEmpty(prefix) ? "" : "/");
|
||||
//
|
||||
// Macro macro = new BaseMacro(KEY.replace("%", entry.getKey()),
|
||||
// value,
|
||||
// "Returns protocol, hostname and port of an internal server");
|
||||
//
|
||||
// macros.add(macro);
|
||||
//
|
||||
// // register port without "/tcp" suffix
|
||||
// if (entry.getKey().endsWith("/tcp")) {
|
||||
// final String port = entry.getKey().substring(0, entry.getKey().length() - 4);
|
||||
//
|
||||
// Macro shortMacro = new BaseMacro(KEY.replace("%", port),
|
||||
// value,
|
||||
// "Returns protocol, hostname and port of an internal server");
|
||||
//
|
||||
// macros.add(shortMacro);
|
||||
// }
|
||||
// }
|
||||
|
||||
return macros;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,10 +18,10 @@ import com.google.web.bindery.event.shared.EventBus;
|
|||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Server;
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.machine.DevMachine;
|
||||
import org.eclipse.che.ide.api.macro.BaseMacro;
|
||||
import org.eclipse.che.ide.api.macro.Macro;
|
||||
import org.eclipse.che.ide.api.macro.MacroRegistry;
|
||||
import org.eclipse.che.ide.api.machine.DevMachine;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
|
@ -56,12 +56,11 @@ public class ServerPortMacro extends AbstractServerMacro {
|
|||
|
||||
for (Map.Entry<String, ? extends Server> entry : devMachine.getDescriptor().getServers().entrySet()) {
|
||||
|
||||
// FIXME: spi
|
||||
// if (!entry.getValue().getAddress().contains(":")) {
|
||||
// continue;
|
||||
// }
|
||||
if (!entry.getValue().getUrl().contains(":")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String externalPort = ""/*entry.getValue().getAddress().split(":")[1]*/;
|
||||
final String externalPort = entry.getValue().getUrl().split(":")[1];
|
||||
|
||||
Macro macro = new BaseMacro(KEY.replace("%", entry.getKey()),
|
||||
externalPort,
|
||||
|
|
|
|||
|
|
@ -1,81 +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.macro;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.machine.DevMachine;
|
||||
import org.eclipse.che.ide.api.macro.Macro;
|
||||
import org.eclipse.che.ide.api.macro.MacroRegistry;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Macro which is responsible for the retrieving the protocol of the registered server.
|
||||
* <p>
|
||||
* Macro provided: <code>${server.[port].protocol}</code>
|
||||
*
|
||||
* @author Vlad Zhukovskyi
|
||||
* @see AbstractServerMacro
|
||||
* @see DevMachine
|
||||
* @since 4.7.0
|
||||
*/
|
||||
@Beta
|
||||
@Singleton
|
||||
public class ServerProtocolMacro extends AbstractServerMacro {
|
||||
|
||||
public static final String KEY = "${server.%.protocol}";
|
||||
|
||||
@Inject
|
||||
public ServerProtocolMacro(MacroRegistry macroRegistry,
|
||||
EventBus eventBus,
|
||||
AppContext appContext) {
|
||||
super(macroRegistry, eventBus, appContext);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Set<Macro> getMacros(DevMachine devMachine) {
|
||||
final Set<Macro> macros = Sets.newHashSet();
|
||||
|
||||
// FIXME: spi
|
||||
// for (Map.Entry<String, ? extends Server> entry : devMachine.getDescriptor().getServers().entrySet()) {
|
||||
//
|
||||
// if (Strings.isNullOrEmpty(entry.getValue().getProtocol())) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// Macro macro = new BaseMacro(KEY.replace("%", entry.getKey()),
|
||||
// entry.getValue().getProtocol(),
|
||||
// "Returns protocol of a server registered by name");
|
||||
//
|
||||
// macros.add(macro);
|
||||
//
|
||||
// // register port without "/tcp" suffix
|
||||
// if (entry.getKey().endsWith("/tcp")) {
|
||||
// final String port = entry.getKey().substring(0, entry.getKey().length() - 4);
|
||||
//
|
||||
// Macro shortMacro = new BaseMacro(KEY.replace("%", port),
|
||||
// entry.getValue().getProtocol(),
|
||||
// "Returns protocol of a server registered by name");
|
||||
//
|
||||
// macros.add(shortMacro);
|
||||
// }
|
||||
// }
|
||||
|
||||
return macros;
|
||||
}
|
||||
}
|
||||
|
|
@ -121,14 +121,11 @@ public class ProcessTreeRenderer implements NodeRenderer<ProcessTreeNode> {
|
|||
|
||||
private SpanElement createMachineElement(final ProcessTreeNode node) {
|
||||
final MachineEntity machine = (MachineEntity)node.getData();
|
||||
// FIXME: spi
|
||||
// final String machineId = machine.getId();
|
||||
// final MachineConfig machineConfig = machine.getConfig();
|
||||
// final String machineCategory = machineConfig.isDev() ? locale.devMachineCategory() : machineConfig.getType();
|
||||
final String machineId = machine.getId();
|
||||
final String machineCategory = machine.isDev() ? locale.devMachineCategory() : "";
|
||||
|
||||
SpanElement root = Elements.createSpanElement();
|
||||
// FIXME: spi
|
||||
// root.appendChild(createMachineLabel(machineCategory));
|
||||
root.appendChild(createMachineLabel(machineCategory));
|
||||
|
||||
Element statusElement = Elements.createSpanElement(resources.getCss().machineStatus());
|
||||
root.appendChild(statusElement);
|
||||
|
|
@ -168,8 +165,7 @@ public class ProcessTreeRenderer implements NodeRenderer<ProcessTreeNode> {
|
|||
event.preventDefault();
|
||||
|
||||
if (addTerminalClickHandler != null) {
|
||||
// FIXME: spi
|
||||
// addTerminalClickHandler.onAddTerminalClick(machineId);
|
||||
addTerminalClickHandler.onAddTerminalClick(machineId);
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
|
|
@ -208,8 +204,7 @@ public class ProcessTreeRenderer implements NodeRenderer<ProcessTreeNode> {
|
|||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
if (previewSshClickHandler != null) {
|
||||
// FIXME: spi
|
||||
// previewSshClickHandler.onPreviewSshClick(machineId);
|
||||
previewSshClickHandler.onPreviewSshClick(machineId);
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
|
|
@ -223,17 +218,15 @@ public class ProcessTreeRenderer implements NodeRenderer<ProcessTreeNode> {
|
|||
Element monitorsElement = Elements.createSpanElement(resources.getCss().machineMonitors());
|
||||
root.appendChild(monitorsElement);
|
||||
|
||||
// FIXME: spi
|
||||
// Node monitorNode = (Node)machineMonitors.getMonitorWidget(machineId, this).getElement();
|
||||
// monitorsElement.appendChild(monitorNode);
|
||||
Node monitorNode = (Node)machineMonitors.getMonitorWidget(machineId, this).getElement();
|
||||
monitorsElement.appendChild(monitorNode);
|
||||
|
||||
Element nameElement = Elements.createSpanElement(resources.getCss().nameLabel());
|
||||
// FIXME: spi
|
||||
// nameElement.setTextContent(machineConfig.getName());
|
||||
// Tooltip.create(nameElement,
|
||||
// BOTTOM,
|
||||
// MIDDLE,
|
||||
// machineConfig.getName());
|
||||
nameElement.setTextContent(machine.getName());
|
||||
Tooltip.create(nameElement,
|
||||
BOTTOM,
|
||||
MIDDLE,
|
||||
machine.getName());
|
||||
root.appendChild(nameElement);
|
||||
|
||||
return root;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import com.google.inject.Provider;
|
|||
import com.google.inject.Singleton;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.Runtime;
|
||||
import org.eclipse.che.api.core.model.workspace.Workspace;
|
||||
import org.eclipse.che.api.core.model.workspace.WorkspaceConfig;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
|
|
@ -27,6 +26,7 @@ import org.eclipse.che.api.core.model.workspace.config.Environment;
|
|||
import org.eclipse.che.api.core.model.workspace.config.MachineConfig;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Server;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.execagent.GetProcessLogsResponseDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.execagent.GetProcessesResponseDto;
|
||||
import org.eclipse.che.api.promises.client.Operation;
|
||||
|
|
@ -41,8 +41,10 @@ import org.eclipse.che.ide.api.command.CommandImpl;
|
|||
import org.eclipse.che.ide.api.command.CommandTypeRegistry;
|
||||
import org.eclipse.che.ide.api.dialogs.ConfirmCallback;
|
||||
import org.eclipse.che.ide.api.dialogs.DialogFactory;
|
||||
import org.eclipse.che.ide.api.machine.ActiveRuntime;
|
||||
import org.eclipse.che.ide.api.machine.ExecAgentCommandManager;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntityImpl;
|
||||
import org.eclipse.che.ide.api.machine.events.ActivateProcessOutputEvent;
|
||||
import org.eclipse.che.ide.api.machine.events.MachineStateEvent;
|
||||
import org.eclipse.che.ide.api.machine.events.ProcessFinishedEvent;
|
||||
|
|
@ -65,6 +67,7 @@ import org.eclipse.che.ide.console.CommandConsoleFactory;
|
|||
import org.eclipse.che.ide.console.CommandOutputConsole;
|
||||
import org.eclipse.che.ide.console.CommandOutputConsolePresenter;
|
||||
import org.eclipse.che.ide.console.DefaultOutputConsole;
|
||||
import org.eclipse.che.ide.dto.DtoFactory;
|
||||
import org.eclipse.che.ide.machine.MachineResources;
|
||||
import org.eclipse.che.ide.processes.ProcessTreeNode;
|
||||
import org.eclipse.che.ide.processes.ProcessTreeNodeSelectedEvent;
|
||||
|
|
@ -138,6 +141,7 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
private final CommandTypeRegistry commandTypeRegistry;
|
||||
private final ExecAgentCommandManager execAgentCommandManager;
|
||||
private final Provider<MacroProcessor> macroProcessorProvider;
|
||||
private final DtoFactory dtoFactory;
|
||||
private final EventBus eventBus;
|
||||
|
||||
ProcessTreeNode rootNode;
|
||||
|
|
@ -161,7 +165,8 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
CommandTypeRegistry commandTypeRegistry,
|
||||
SshServiceClient sshServiceClient,
|
||||
ExecAgentCommandManager execAgentCommandManager,
|
||||
Provider<MacroProcessor> macroProcessorProvider) {
|
||||
Provider<MacroProcessor> macroProcessorProvider,
|
||||
DtoFactory dtoFactory) {
|
||||
this.view = view;
|
||||
this.localizationConstant = localizationConstant;
|
||||
this.resources = resources;
|
||||
|
|
@ -177,6 +182,7 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
this.commandTypeRegistry = commandTypeRegistry;
|
||||
this.execAgentCommandManager = execAgentCommandManager;
|
||||
this.macroProcessorProvider = macroProcessorProvider;
|
||||
this.dtoFactory = dtoFactory;
|
||||
|
||||
machineNodes = new HashMap<>();
|
||||
machines = new HashMap<>();
|
||||
|
|
@ -208,7 +214,7 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
return;
|
||||
}
|
||||
|
||||
List<MachineEntity> machines = getMachines(appContext.getWorkspace());
|
||||
List<MachineEntity> machines = getMachines();
|
||||
if (machines.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -452,13 +458,12 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
return;
|
||||
}
|
||||
|
||||
Machine machine = (Machine)machineTreeNode.getData();
|
||||
MachineEntity machine = (MachineEntity)machineTreeNode.getData();
|
||||
|
||||
final OutputConsole defaultConsole = commandConsoleFactory.create("SSH");
|
||||
addCommandOutput(machineId, defaultConsole);
|
||||
|
||||
// FIXME: spi
|
||||
final String machineName = ""/*machine.getConfig().getName()*/;
|
||||
final String machineName = machine.getName();
|
||||
String sshServiceAddress = getSshServerAddress(machine);
|
||||
final String machineHost;
|
||||
final String sshPort;
|
||||
|
|
@ -546,7 +551,6 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
private String getSshServerAddress(Machine machine) {
|
||||
Map<String, ? extends Server> servers = machine.getServers();
|
||||
final Server sshServer = servers.get(SSH_PORT + "/tcp");
|
||||
// FIXME: spi
|
||||
return sshServer != null ? sshServer.getUrl() : null;
|
||||
}
|
||||
|
||||
|
|
@ -838,7 +842,7 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
* @return <b>true</b> is the terminal url, otherwise return <b>false</b>
|
||||
*/
|
||||
private boolean hasTerminal(String machineId) {
|
||||
List<MachineEntity> wsMachines = getMachines(appContext.getWorkspace());
|
||||
List<MachineEntity> wsMachines = getMachines();
|
||||
for (MachineEntity machineEntity : wsMachines) {
|
||||
if (machineId.equals(machineEntity.getId())) {
|
||||
return false;
|
||||
|
|
@ -881,7 +885,6 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
|
||||
// create new node
|
||||
final ProcessTreeNode newMachineNode = new ProcessTreeNode(MACHINE_NODE, rootNode, machine, null, children);
|
||||
// FIXME: spi
|
||||
// newMachineNode.setRunning(RUNNING == machine.getStatus());
|
||||
newMachineNode.setHasTerminalAgent(hasAgent(machine.getDisplayName(), TERMINAL_AGENT) || hasTerminal(machineId));
|
||||
newMachineNode.setHasSSHAgent(hasAgent(machine.getDisplayName(), SSH_AGENT));
|
||||
|
|
@ -906,32 +909,18 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
return newMachineNode;
|
||||
}
|
||||
|
||||
private List<MachineEntity> getMachines(Workspace workspace) {
|
||||
Runtime workspaceRuntime = workspace.getRuntime();
|
||||
private List<MachineEntity> getMachines() {
|
||||
final ActiveRuntime workspaceRuntime = appContext.getActiveRuntime();
|
||||
if (workspaceRuntime == null) {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
Map<String, ? extends Machine> runtimeMachines = workspaceRuntime.getMachines();
|
||||
List<MachineEntity> machines = new ArrayList<>(runtimeMachines.size());
|
||||
// FIXME: spi
|
||||
// for (Machine machine : runtimeMachines.entrySet()) {
|
||||
// if (machine instanceof MachineDto) {
|
||||
// MachineEntity machineEntity = new MachineEntityImpl(machine);
|
||||
// machines.add(machineEntity);
|
||||
// }
|
||||
// }
|
||||
return machines;
|
||||
return new ArrayList<>(workspaceRuntime.getMachines());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MachineEntity getMachine(@NotNull String machineId) {
|
||||
Workspace workspace = appContext.getWorkspace();
|
||||
if (workspace == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<MachineEntity> wsMachines = getMachines(workspace);
|
||||
List<MachineEntity> wsMachines = getMachines();
|
||||
for (MachineEntity machine : wsMachines) {
|
||||
if (machineId.equals(machine.getId())) {
|
||||
return machine;
|
||||
|
|
@ -947,7 +936,7 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
|
||||
@Override
|
||||
public void onWorkspaceStarted(WorkspaceStartedEvent event) {
|
||||
List<MachineEntity> wsMachines = getMachines(event.getWorkspace());
|
||||
List<MachineEntity> wsMachines = getMachines();
|
||||
if (wsMachines.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -979,12 +968,11 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
notifyTreeNodeSelected(machineToSelect);
|
||||
}
|
||||
|
||||
// FIXME: spi
|
||||
// for (MachineEntity machine : machines.values()) {
|
||||
// if (RUNNING.equals(machine.getStatus()) && !wsMachines.contains(machine)) {
|
||||
// provideMachineNode(machine, true);
|
||||
// }
|
||||
// }
|
||||
for (MachineEntity machine : machines.values()) {
|
||||
if (/*RUNNING.equals(machine.getStatus()) && */!wsMachines.contains(machine)) {
|
||||
provideMachineNode(machine, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1033,7 +1021,7 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
|
||||
@Override
|
||||
public void onWsAgentStarted(WsAgentStateEvent event) {
|
||||
List<MachineEntity> machines = getMachines(appContext.getWorkspace());
|
||||
List<MachineEntity> machines = getMachines();
|
||||
if (machines.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1188,18 +1176,11 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
*/
|
||||
public void printMachineOutput(final String machineName, final String text) {
|
||||
// Create a temporary machine node to display outputs.
|
||||
// FIXME: spi
|
||||
// if (!consoles.containsKey(machineName)) {
|
||||
// MachineDto machineDto = dtoFactory.createDto(MachineDto.class)
|
||||
// .withId(machineName)
|
||||
// .withStatus(CREATING)
|
||||
// .withConfig(dtoFactory.createDto(MachineConfigDto.class)
|
||||
// .withDev("dev-machine".equals(machineName))
|
||||
// .withName(machineName)
|
||||
// .withType("docker")
|
||||
// );
|
||||
// provideMachineNode(new MachineItem(machineDto), true);
|
||||
// }
|
||||
|
||||
if (!consoles.containsKey(machineName)) {
|
||||
MachineDto machineDto = dtoFactory.createDto(MachineDto.class);
|
||||
provideMachineNode(new MachineEntityImpl(machineName, machineDto), true);
|
||||
}
|
||||
|
||||
OutputConsole console = consoles.get(machineName);
|
||||
if (console != null && console instanceof DefaultOutputConsole) {
|
||||
|
|
@ -1300,18 +1281,18 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
|
||||
@Override
|
||||
public void onDownloadWorkspaceOutput(DownloadWorkspaceOutputEvent event) {
|
||||
Machine devMachine = null;
|
||||
MachineEntity devMachine = null;
|
||||
|
||||
for (ProcessTreeNode machineNode : machineNodes.values()) {
|
||||
if (!(machineNode.getData() instanceof Machine)) {
|
||||
if (!(machineNode.getData() instanceof MachineEntity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Machine machine = (Machine)machineNode.getData();
|
||||
// FIXME: spi
|
||||
// if (!machine.isDev()) {
|
||||
// continue;
|
||||
// }
|
||||
MachineEntity machine = (MachineEntity)machineNode.getData();
|
||||
|
||||
if (!machine.isDev()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
devMachine = machine;
|
||||
break;
|
||||
|
|
@ -1325,8 +1306,7 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
" " + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) +
|
||||
".log";
|
||||
|
||||
// FIXME: spi
|
||||
// download(fileName, getText(devMachine.getId()));
|
||||
download(fileName, getText(devMachine.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -231,15 +231,7 @@ public class CategoriesPagePresenter extends AbstractWizardPage<MutableProjectCo
|
|||
final String templatePath = projectTemplate.getPath();
|
||||
final List<NewProjectConfig> updatedConfigs = new ArrayList<>(configDtoList.size());
|
||||
for (ProjectConfigDto configDto : configDtoList) {
|
||||
// FIXME: spi
|
||||
final NewProjectConfig newConfig = new NewProjectConfigImpl(configDto.getName(),
|
||||
configDto.getPath(),
|
||||
configDto.getDescription(),
|
||||
configDto.getType(),
|
||||
configDto.getSource(),
|
||||
configDto.getMixins(),
|
||||
configDto.getAttributes(),
|
||||
null);
|
||||
final NewProjectConfig newConfig = new NewProjectConfigImpl(configDto);
|
||||
final String projectPath = configDto.getPath();
|
||||
if (projectPath.startsWith(templatePath)) {
|
||||
final String path = projectPath.replaceFirst(templatePath, newProjectPath);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.eclipse.che.api.machine.shared.Constants.WS_MACHINE_NAME;
|
||||
|
||||
/**
|
||||
* The class contains business logic which allow to create user workspace if it doesn't exist.
|
||||
|
|
@ -199,7 +198,7 @@ public class CreateWorkspacePresenter implements CreateWorkspaceView.ActionDeleg
|
|||
|
||||
EnvironmentDto environment = dtoFactory.createDto(EnvironmentDto.class)
|
||||
.withRecipe(recipe)
|
||||
.withMachines(singletonMap(WS_MACHINE_NAME, machine));
|
||||
.withMachines(singletonMap("default", machine));
|
||||
|
||||
return dtoFactory.createDto(WorkspaceConfigDto.class)
|
||||
.withName(wsName)
|
||||
|
|
|
|||
|
|
@ -1,154 +0,0 @@
|
|||
package org.eclipse.che.ide.machine;
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
*******************************************************************************/
|
||||
|
||||
import org.eclipse.che.api.core.rest.shared.dto.Link;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineConfigDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineRuntimeInfoDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.ServerDto;
|
||||
import org.eclipse.che.ide.CoreLocalizationConstant;
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.eclipse.che.api.machine.shared.Constants.TERMINAL_REFERENCE;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Dmitry Shnurenko
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MachineItemTest {
|
||||
|
||||
private final static String SOME_TEXT = "someText";
|
||||
|
||||
@Mock
|
||||
private MachineDto descriptor;
|
||||
@Mock
|
||||
private MachineConfigDto machineConfig;
|
||||
@Mock
|
||||
private MachineRuntimeInfoDto machineRuntimeDto;
|
||||
@Mock
|
||||
private ServerDto serverDescriptor;
|
||||
@Mock
|
||||
private CoreLocalizationConstant locale;
|
||||
@Mock
|
||||
private AppContext appContext;
|
||||
|
||||
private MachineItem machine;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Map<String, ServerDto> servers = new HashMap<>();
|
||||
servers.put(SOME_TEXT, serverDescriptor);
|
||||
|
||||
when(descriptor.getRuntime()).thenReturn(machineRuntimeDto);
|
||||
when(descriptor.getConfig()).thenReturn(machineConfig);
|
||||
when(serverDescriptor.getAddress()).thenReturn(SOME_TEXT);
|
||||
when(machineRuntimeDto.getServers()).thenReturn(servers);
|
||||
|
||||
machine = new MachineItem(descriptor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructorShouldBeVerified() {
|
||||
verify(descriptor).getLinks();
|
||||
verify(descriptor).getConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayNameShouldBeReturned() {
|
||||
machine.getDisplayName();
|
||||
|
||||
verify(machineConfig).getName();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void idShouldBeReturned() {
|
||||
machine.getId();
|
||||
|
||||
verify(descriptor).getId();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stateShouldBeReturned() {
|
||||
machine.getStatus();
|
||||
|
||||
verify(descriptor).getStatus();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void typeShouldBeReturned() {
|
||||
machine.getType();
|
||||
|
||||
verify(machineConfig).getType();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void boundedStateShouldBeReturned() {
|
||||
machine.isDev();
|
||||
|
||||
verify(machineConfig).isDev();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnTerminalUrl() {
|
||||
String terminalHref = "terminalHref";
|
||||
Link someLink = mock(Link.class);
|
||||
Link terminalLink = mock(Link.class);
|
||||
List<Link> links = new ArrayList<>(2);
|
||||
links.add(someLink);
|
||||
links.add(terminalLink);
|
||||
when(terminalLink.getHref()).thenReturn(terminalHref);
|
||||
when(terminalLink.getRel()).thenReturn(TERMINAL_REFERENCE);
|
||||
when(descriptor.getLinks()).thenReturn(links);
|
||||
|
||||
machine = new MachineItem(descriptor);
|
||||
String terminalUrl = machine.getTerminalUrl();
|
||||
|
||||
assertEquals(terminalHref, terminalUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnProperties() {
|
||||
Map<String, String> properties = Collections.emptyMap();
|
||||
when(machineRuntimeDto.getProperties()).thenReturn(properties);
|
||||
|
||||
machine = new MachineItem(descriptor);
|
||||
Map<String, String> result = machine.getProperties();
|
||||
|
||||
assertEquals(properties, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldAvoidNPEWhenMachineRuntimeIsNull() {
|
||||
when(descriptor.getRuntime()).thenReturn(null);
|
||||
machine = new MachineItem(descriptor);
|
||||
|
||||
Map<String, String> result = machine.getProperties();
|
||||
|
||||
assertNull(result);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,121 +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.macro;
|
||||
|
||||
import com.google.gwtmockito.GwtMockitoTestRunner;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.Machine;
|
||||
import org.eclipse.che.api.core.model.machine.MachineRuntimeInfo;
|
||||
import org.eclipse.che.api.core.model.machine.Server;
|
||||
import org.eclipse.che.api.machine.shared.Constants;
|
||||
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.macro.BaseMacro;
|
||||
import org.eclipse.che.ide.api.macro.Macro;
|
||||
import org.eclipse.che.ide.api.macro.MacroRegistry;
|
||||
import org.eclipse.che.ide.api.machine.DevMachine;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link ServerMacro}
|
||||
*
|
||||
* @author Vlad Zhukovskyi
|
||||
*/
|
||||
@RunWith(GwtMockitoTestRunner.class)
|
||||
public class ServerMacroTest {
|
||||
|
||||
public static final String WS_AGENT_PORT = Constants.WS_AGENT_PORT; // 4401/tcp
|
||||
public static final String ADDRESS = "127.0.0.1";
|
||||
|
||||
@Mock
|
||||
private MacroRegistry macroRegistry;
|
||||
|
||||
@Mock
|
||||
private EventBus eventBus;
|
||||
|
||||
@Mock
|
||||
private AppContext appContext;
|
||||
|
||||
@Mock
|
||||
private DevMachine devMachine;
|
||||
|
||||
@Mock
|
||||
private Machine machine;
|
||||
|
||||
@Mock
|
||||
private MachineRuntimeInfo machineRuntimeInfo;
|
||||
|
||||
@Mock
|
||||
private Server server;
|
||||
|
||||
private ServerMacro provider;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
provider = new ServerMacro(macroRegistry, eventBus, appContext);
|
||||
|
||||
registerProvider();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMacros() throws Exception {
|
||||
final Set<Macro> macros = provider.getMacros(devMachine);
|
||||
|
||||
assertEquals(macros.size(), 2);
|
||||
|
||||
final Iterator<Macro> iterator = macros.iterator();
|
||||
|
||||
final Macro provider1 = iterator.next();
|
||||
|
||||
assertTrue(provider1 instanceof BaseMacro);
|
||||
assertEquals(provider1.getName(), ServerMacro.KEY.replace("%", WS_AGENT_PORT.substring(0, WS_AGENT_PORT.length() - 4)));
|
||||
|
||||
provider1.expand().then(new Operation<String>() {
|
||||
@Override
|
||||
public void apply(String address) throws OperationException {
|
||||
assertEquals(address, ADDRESS);
|
||||
}
|
||||
});
|
||||
|
||||
final Macro provider2 = iterator.next();
|
||||
|
||||
assertTrue(provider2 instanceof BaseMacro);
|
||||
assertEquals(provider2.getName(), ServerMacro.KEY.replace("%", WS_AGENT_PORT));
|
||||
|
||||
provider2.expand().then(new Operation<String>() {
|
||||
@Override
|
||||
public void apply(String address) throws OperationException {
|
||||
assertEquals(address, ADDRESS);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerProvider() {
|
||||
when(devMachine.getDescriptor()).thenReturn(machine);
|
||||
when(machine.getRuntime()).thenReturn(machineRuntimeInfo);
|
||||
doReturn(Collections.<String, Server>singletonMap(WS_AGENT_PORT, server)).when(machineRuntimeInfo).getServers();
|
||||
when(server.getAddress()).thenReturn(ADDRESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,125 +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.macro;
|
||||
|
||||
import com.google.gwtmockito.GwtMockitoTestRunner;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.Machine;
|
||||
import org.eclipse.che.api.core.model.machine.MachineRuntimeInfo;
|
||||
import org.eclipse.che.api.core.model.machine.Server;
|
||||
import org.eclipse.che.api.machine.shared.Constants;
|
||||
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.macro.BaseMacro;
|
||||
import org.eclipse.che.ide.api.macro.Macro;
|
||||
import org.eclipse.che.ide.api.macro.MacroRegistry;
|
||||
import org.eclipse.che.ide.api.machine.DevMachine;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link ServerProtocolMacro}
|
||||
*
|
||||
* @author Vlad Zhukovskyi
|
||||
*/
|
||||
@RunWith(GwtMockitoTestRunner.class)
|
||||
public class ServerProtocolMacroTest {
|
||||
|
||||
public static final String WS_AGENT_PORT = Constants.WS_AGENT_PORT; // 4401/tcp
|
||||
public static final String PORT = "1234";
|
||||
public static final String ADDRESS = "127.0.0.1" + ":" + PORT;
|
||||
public static final String PROTOCOL = "protocol";
|
||||
|
||||
@Mock
|
||||
private MacroRegistry macroRegistry;
|
||||
|
||||
@Mock
|
||||
private EventBus eventBus;
|
||||
|
||||
@Mock
|
||||
private AppContext appContext;
|
||||
|
||||
@Mock
|
||||
private DevMachine devMachine;
|
||||
|
||||
@Mock
|
||||
private Machine machine;
|
||||
|
||||
@Mock
|
||||
private MachineRuntimeInfo machineRuntimeInfo;
|
||||
|
||||
@Mock
|
||||
private Server server;
|
||||
|
||||
private ServerProtocolMacro provider;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
provider = new ServerProtocolMacro(macroRegistry, eventBus, appContext);
|
||||
|
||||
registerProvider();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMacros() throws Exception {
|
||||
final Set<Macro> macros = provider.getMacros(devMachine);
|
||||
|
||||
assertEquals(macros.size(), 2);
|
||||
|
||||
final Iterator<Macro> iterator = macros.iterator();
|
||||
|
||||
final Macro provider1 = iterator.next();
|
||||
|
||||
assertTrue(provider1 instanceof BaseMacro);
|
||||
assertEquals(provider1.getName(), ServerProtocolMacro.KEY.replace("%", WS_AGENT_PORT));
|
||||
|
||||
provider1.expand().then(new Operation<String>() {
|
||||
@Override
|
||||
public void apply(String address) throws OperationException {
|
||||
assertEquals(address, PROTOCOL);
|
||||
}
|
||||
});
|
||||
|
||||
final Macro provider2 = iterator.next();
|
||||
|
||||
assertTrue(provider2 instanceof BaseMacro);
|
||||
assertEquals(provider2.getName(), ServerProtocolMacro.KEY.replace("%", WS_AGENT_PORT.substring(0, WS_AGENT_PORT.length() - 4)));
|
||||
|
||||
provider2.expand().then(new Operation<String>() {
|
||||
@Override
|
||||
public void apply(String address) throws OperationException {
|
||||
assertEquals(address, PROTOCOL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerProvider() {
|
||||
when(devMachine.getDescriptor()).thenReturn(machine);
|
||||
when(machine.getRuntime()).thenReturn(machineRuntimeInfo);
|
||||
doReturn(Collections.<String, Server>singletonMap(WS_AGENT_PORT, server)).when(machineRuntimeInfo).getServers();
|
||||
when(server.getAddress()).thenReturn(ADDRESS);
|
||||
when(server.getProtocol()).thenReturn(PROTOCOL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,10 +15,10 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.Workspace;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
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.MachineEntity;
|
||||
import org.eclipse.che.ide.macro.CurrentProjectPathMacro;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -97,43 +97,34 @@ public class GdbConfigurationPagePresenter implements GdbConfigurationPageView.A
|
|||
view.setPortEnableState(!devHost);
|
||||
view.setHostEnableState(!devHost);
|
||||
|
||||
List<Machine> machines = getMachines();
|
||||
List<MachineEntity> machines = getMachines();
|
||||
if (!machines.isEmpty()) {
|
||||
setHosts(machines);
|
||||
}
|
||||
}
|
||||
|
||||
private void setHosts(List<Machine> machines) {
|
||||
private void setHosts(List<MachineEntity> machines) {
|
||||
Map<String, String> hosts = new HashMap<>();
|
||||
for (Machine machine : machines) {
|
||||
for (MachineEntity machine : machines) {
|
||||
String host = machine.getProperties().get("network.ipAddress");
|
||||
if (host == null) {
|
||||
continue;
|
||||
}
|
||||
// FIXME: spi
|
||||
// String description = host + " (" + machine.getConfig().getName() + ")";
|
||||
// hosts.put(host, description);
|
||||
|
||||
String description = host + " (" + machine.getName() + ")";
|
||||
hosts.put(host, description);
|
||||
}
|
||||
|
||||
view.setHostsList(hosts);
|
||||
}
|
||||
|
||||
private List<Machine> getMachines() {
|
||||
private List<MachineEntity> getMachines() {
|
||||
Workspace workspace = appContext.getWorkspace();
|
||||
if (workspace == null || workspace.getRuntime() == null) {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
Map<String, ? extends Machine> runtimeMachines = workspace.getRuntime().getMachines();
|
||||
List<Machine> machines = new ArrayList<>(runtimeMachines.size());
|
||||
// FIXME: spi
|
||||
// for (Machine currentMachine : runtimeMachines.entrySet()) {
|
||||
// if (currentMachine instanceof MachineDto) {
|
||||
// Machine machine = new MachineEntityImpl(currentMachine);
|
||||
// machines.add(machine);
|
||||
// }
|
||||
// }
|
||||
return machines;
|
||||
return new ArrayList<>(appContext.getActiveRuntime().getMachines());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -90,11 +90,10 @@ public class JavaDebugConfigurationPagePresenter implements JavaDebugConfigurati
|
|||
String port = entry.getKey();
|
||||
if (port.endsWith("/tcp")) {
|
||||
String portWithoutTcp = port.substring(0, port.length() - 4);
|
||||
// FIXME: spi
|
||||
// String description = portWithoutTcp + " (" + entry.getValue().getRef() + ")";
|
||||
// Pair<String, String> pair = new Pair<>(description, portWithoutTcp);
|
||||
String description = portWithoutTcp + " (" + entry.getValue().getUrl() + ")";
|
||||
Pair<String, String> pair = new Pair<>(description, portWithoutTcp);
|
||||
|
||||
// ports.add(pair);
|
||||
ports.add(pair);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.api.machine.shared.dto.execagent.ProcessStartResponseDto;
|
||||
import org.eclipse.che.api.promises.client.Operation;
|
||||
import org.eclipse.che.api.promises.client.OperationException;
|
||||
|
|
@ -32,6 +31,7 @@ import org.eclipse.che.ide.api.app.AppContext;
|
|||
import org.eclipse.che.ide.api.command.CommandImpl;
|
||||
import org.eclipse.che.ide.api.command.CommandManager;
|
||||
import org.eclipse.che.ide.api.machine.ExecAgentCommandManager;
|
||||
import org.eclipse.che.ide.api.machine.MachineEntity;
|
||||
import org.eclipse.che.ide.api.machine.execagent.ExecAgentConsumer;
|
||||
import org.eclipse.che.ide.api.macro.MacroProcessor;
|
||||
import org.eclipse.che.ide.api.notification.StatusNotification;
|
||||
|
|
@ -150,11 +150,11 @@ public class TestServiceClient {
|
|||
StatusNotification statusNotification,
|
||||
Promise<CommandImpl> compileCommand) {
|
||||
return compileCommand.thenPromise(command -> {
|
||||
final Machine machine;
|
||||
final MachineEntity machine;
|
||||
if (command == null) {
|
||||
machine = null;
|
||||
} else {
|
||||
machine = appContext.getDevMachine().getDescriptor();
|
||||
machine = appContext.getDevMachine();
|
||||
}
|
||||
if (machine == null) {
|
||||
if (statusNotification != null) {
|
||||
|
|
@ -182,8 +182,7 @@ public class TestServiceClient {
|
|||
command.getType(), attributes);
|
||||
|
||||
final CommandOutputConsole console = commandConsoleFactory.create(expandedCommand, machine);
|
||||
// FIXME: spi
|
||||
final String machineId = ""/*machine.getId()*/;
|
||||
final String machineId = machine.getId();
|
||||
|
||||
processesPanelPresenter.addCommandOutput(machineId, console);
|
||||
ExecAgentConsumer<ProcessStartResponseDto> processPromise = execAgentCommandManager.startProcess(machineId,
|
||||
|
|
|
|||
Loading…
Reference in New Issue