blob: 7c5f06b5cf16dc1ff4b9761e3588de3b73497542 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2017 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is 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
*
* Contributor:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.eclipse.linuxtools.docker.reddeer.core.ui.wizards;
import org.jboss.reddeer.common.wait.TimePeriod;
import org.jboss.reddeer.common.wait.WaitUntil;
import org.jboss.reddeer.common.wait.WaitWhile;
import org.jboss.reddeer.core.condition.JobIsRunning;
import org.jboss.reddeer.core.condition.ShellWithTextIsAvailable;
import org.jboss.reddeer.core.matcher.WithTextMatcher;
import org.jboss.reddeer.jface.wizard.WizardPage;
import org.jboss.reddeer.swt.impl.button.CheckBox;
import org.jboss.reddeer.swt.impl.button.FinishButton;
import org.jboss.reddeer.swt.impl.button.NextButton;
import org.jboss.reddeer.swt.impl.button.OkButton;
import org.jboss.reddeer.swt.impl.button.PushButton;
import org.jboss.reddeer.swt.impl.combo.LabeledCombo;
import org.jboss.reddeer.swt.impl.shell.DefaultShell;
import org.jboss.reddeer.swt.impl.text.LabeledText;
/**
*
* @author jkopriva@redhat.com
*
*/
public class ImageRunSelectionPage extends WizardPage {
public ImageRunSelectionPage() {
super();
new WaitUntil(new ShellWithTextIsAvailable("Run a Docker Image"), TimePeriod.LONG);
}
public void finish() {
if (new FinishButton().isEnabled()) {
new FinishButton().click();
new WaitWhile(new JobIsRunning(), TimePeriod.VERY_LONG);
} else {
throw new RuntimeException("Image cannot be run! (Duplicate name?)");
}
}
public void next() {
new NextButton().click();
}
public void setContainerName(String name) {
new LabeledText("Container Name:").setText(name);
}
public void setEntrypoint(String Entrypoint) {
new LabeledText("Entrypoint:").setText(Entrypoint);
}
public void setCommand(String command) {
new LabeledText("Command:").setText(command);
}
public void setPublishAllExposedPorts(boolean checked) {
new CheckBox("Publish all exposed ports to random ports on the host interfaces").toggle(checked);
}
public void setPublishAllExposedPorts() {
setPublishAllExposedPorts(true);
}
public void setKeepSTDINOpen(boolean checked) {
new CheckBox("Keep STDIN open to Console even if not attached (-i)").toggle(checked);
}
public void setKeepSTDINOpen() {
setKeepSTDINOpen(true);
}
public void setAllocatePseudoTTY(boolean checked) {
new CheckBox("Allocate pseudo-TTY from Console (-t)").toggle(checked);
}
public void setAllocatePseudoTTY() {
setAllocatePseudoTTY(true);
}
public void setAutomaticalyRemove(boolean checked) {
new CheckBox("Automatically remove the container when it exits (--rm)").toggle(checked);
}
public void setAutomaticalyRemove() {
setAutomaticalyRemove(true);
}
public void setGiveExtendedPrivileges(boolean checked) {
new CheckBox("Give extended privileges to this container (--privileged)").toggle(checked);
}
public void setGiveExtendedPrivileges() {
setGiveExtendedPrivileges(true);
}
public void addExposedPort(String containerPort, String hostAddress, String hostPort) {
new PushButton(0, new WithTextMatcher("Add...")).click();
new DefaultShell("Exposing a Container Port");
new LabeledText("Container port:").setText(containerPort);
new LabeledText("Host address:").setText(hostAddress);
new LabeledText("Host port:").setText(hostPort);
new OkButton().click();
}
public void addLinkToContainer(String containerName, String alias) {
new PushButton(1, new WithTextMatcher("Add...")).click();
new DefaultShell("Container Linking");
new LabeledCombo("Container:").setText(containerName);
new LabeledText("Alias:").setText(alias);
new OkButton().click();
}
}