use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class DockerCategoryPresenter method onRestoreTargetFields.
@Override
public boolean onRestoreTargetFields(DockerMachineTarget target) {
if (target == null) {
return false;
}
final MachineEntity machine = this.getMachineByName(target.getName());
if (machine == null) {
return false;
}
target.setOwner(machine.getOwner());
target.setType(machine.getConfig().getType());
target.setSourceType(machine.getConfig().getSource().getType());
target.setSourceContent(machine.getConfig().getSource().getContent());
target.setSource(machine.getConfig().getSource().getLocation());
return true;
}
use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class ProcessTreeRenderer method createMachineElement.
private SpanElement createMachineElement(final ProcessTreeNode node) {
final MachineEntity machine = (MachineEntity) node.getData();
final String machineId = machine.getId();
final MachineConfig machineConfig = machine.getConfig();
final String machineCategory = machineConfig.isDev() ? locale.devMachineCategory() : machineConfig.getType();
SpanElement root = Elements.createSpanElement();
root.appendChild(createMachineLabel(machineCategory));
Element statusElement = Elements.createSpanElement(resources.getCss().machineStatus());
root.appendChild(statusElement);
if (node.isRunning()) {
statusElement.appendChild(Elements.createDivElement(resources.getCss().machineStatusRunning()));
} else {
statusElement.appendChild(Elements.createDivElement(resources.getCss().machineStatusPausedLeft()));
statusElement.appendChild(Elements.createDivElement(resources.getCss().machineStatusPausedRight()));
}
Tooltip.create(statusElement, BOTTOM, MIDDLE, locale.viewMachineRunningTooltip());
/***************************************************************************
*
* New terminal button
*
***************************************************************************/
if (node.isRunning() && node.hasTerminalAgent()) {
SpanElement newTerminalButton = Elements.createSpanElement(resources.getCss().newTerminalButton());
newTerminalButton.appendChild((Node) new SVGImage(resources.addTerminalIcon()).getElement());
root.appendChild(newTerminalButton);
Tooltip.create(newTerminalButton, BOTTOM, MIDDLE, locale.viewNewTerminalTooltip());
newTerminalButton.addEventListener(Event.CLICK, new EventListener() {
@Override
public void handleEvent(Event event) {
event.stopPropagation();
event.preventDefault();
if (addTerminalClickHandler != null) {
addTerminalClickHandler.onAddTerminalClick(machineId);
}
}
}, true);
/**
* This listener cancels mouse events on '+' button and prevents the jitter of the selection in the tree.
*/
EventListener blockMouseListener = new EventListener() {
@Override
public void handleEvent(Event event) {
event.stopPropagation();
event.preventDefault();
}
};
/**
* Prevent jitter when pressing mouse on '+' button.
*/
newTerminalButton.addEventListener(Event.MOUSEDOWN, blockMouseListener, true);
newTerminalButton.addEventListener(Event.MOUSEUP, blockMouseListener, true);
newTerminalButton.addEventListener(Event.CLICK, blockMouseListener, true);
newTerminalButton.addEventListener(Event.DBLCLICK, blockMouseListener, true);
}
/***************************************************************************
*
* SSH button
*
***************************************************************************/
if (node.isRunning() && node.hasSSHAgent()) {
SpanElement sshButton = Elements.createSpanElement(resources.getCss().sshButton());
sshButton.setTextContent("SSH");
root.appendChild(sshButton);
sshButton.addEventListener(Event.CLICK, new EventListener() {
@Override
public void handleEvent(Event event) {
if (previewSshClickHandler != null) {
previewSshClickHandler.onPreviewSshClick(machineId);
}
}
}, true);
Tooltip.create(sshButton, BOTTOM, MIDDLE, locale.connectViaSSH());
}
Element monitorsElement = Elements.createSpanElement(resources.getCss().machineMonitors());
root.appendChild(monitorsElement);
Node monitorNode = (Node) machineMonitors.getMonitorWidget(machineId, this).getElement();
monitorsElement.appendChild(monitorNode);
Element nameElement = Elements.createSpanElement(resources.getCss().nameLabel());
nameElement.setTextContent(machineConfig.getName());
Tooltip.create(nameElement, BOTTOM, MIDDLE, machineConfig.getName());
root.appendChild(nameElement);
return root;
}
use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class SelectCommandComboBox method getMachines.
private List<MachineEntity> getMachines(Workspace workspace) {
WorkspaceRuntime workspaceRuntime = workspace.getRuntime();
if (workspaceRuntime == null) {
return emptyList();
}
List<? extends Machine> runtimeMachines = workspaceRuntime.getMachines();
List<MachineEntity> machines = new ArrayList<>(runtimeMachines.size());
for (Machine machine : runtimeMachines) {
if (machine instanceof MachineDto) {
MachineEntity machineEntity = entityFactory.createMachine((MachineDto) machine);
machines.add(machineEntity);
}
}
return machines;
}
use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class MachineStatusHandler method handleMachineCreating.
private void handleMachineCreating(final String machineId, final WorkspaceRuntimeDto workspaceRuntime) {
final MachineEntity machine = getMachine(machineId, workspaceRuntime);
if (machine == null) {
return;
}
eventBus.fireEvent(new MachineStateEvent(machine, CREATING));
}
use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class MachinePanelPresenter method getMachines.
private List<MachineEntity> getMachines(Workspace workspace) {
WorkspaceRuntime workspaceRuntime = workspace.getRuntime();
if (workspaceRuntime == null) {
return emptyList();
}
List<? extends Machine> runtimeMachines = workspaceRuntime.getMachines();
List<MachineEntity> machines = new ArrayList<>(runtimeMachines.size());
for (Machine machine : runtimeMachines) {
if (machine instanceof MachineDto) {
MachineEntity machineEntity = entityFactory.createMachine((MachineDto) machine);
machines.add(machineEntity);
}
}
return machines;
}
Aggregations