Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1e9f4942b55b30cc1ea486ae5d3a97e880ffe589 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*******************************************************************************
 * Copyright (c) 2017, 2018 Red Hat, Inc.
 * 
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributor:
 *     Red Hat, Inc. - initial API and implementation
 ******************************************************************************/

package org.eclipse.linuxtools.docker.reddeer.core.ui.wizards;

import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.core.matcher.WithTextMatcher;
import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.jface.wizard.WizardPage;
import org.eclipse.reddeer.swt.impl.button.CheckBox;
import org.eclipse.reddeer.swt.impl.button.FinishButton;
import org.eclipse.reddeer.swt.impl.button.NextButton;
import org.eclipse.reddeer.swt.impl.button.OkButton;
import org.eclipse.reddeer.swt.impl.button.PushButton;
import org.eclipse.reddeer.swt.impl.button.RadioButton;
import org.eclipse.reddeer.swt.impl.combo.DefaultCombo;
import org.eclipse.reddeer.swt.impl.text.LabeledText;
import org.eclipse.reddeer.workbench.core.condition.JobIsRunning;

public class ImageRunResourceVolumesVariablesPage extends WizardPage {

	public ImageRunResourceVolumesVariablesPage(ReferencedComposite referencedComposite) {
		super(referencedComposite);
	}

	public void finish() {
		new FinishButton().click();
		new WaitWhile(new JobIsRunning(), TimePeriod.VERY_LONG);
	}
	
	public void next() {
		new NextButton().click();
	}

	public void addDataVolumeNoExternalMount(String containerPath) {
		new PushButton(0, new WithTextMatcher("Add...")).click();
		new LabeledText("Container path:").setText(containerPath);
		new RadioButton("No external mount").click();
		new OkButton().click();
	}

	public void addDataVolumeToHost(String containerPath, String path) {
		addDataVolumeToHost(containerPath, path, false);
	}

	public void addDataVolumeToHost(String containerPath, String path, boolean readOnly) {
		new PushButton(0, new WithTextMatcher("Add...")).click();
		new LabeledText("Container path:").setText(containerPath);
		new RadioButton("Mount a host directory or host file").click();
		new LabeledText("Path:").setText(path);
		new CheckBox("Read-only access").toggle(readOnly);
		;
		new OkButton().click();
	}

	public void addDataVolumeToContainer(String containerPath, String containerName) {
		new PushButton(0, new WithTextMatcher("Add...")).click();
		new LabeledText("Container path:").setText(containerPath);
		new RadioButton("Mount a data volume container").click();
		new DefaultCombo("Container").setText(containerName);
		new OkButton().click();
	}

	public void addEnviromentVariable(String name, String value) {
		new PushButton(1, new WithTextMatcher("Add...")).click();
		new LabeledText("Name:").setText(name);
		new LabeledText("Value:").setText(value);
		new OkButton().click();
	}

	public void addLabel(String name, String value) {
		new PushButton(2, new WithTextMatcher("Add...")).click();
		new LabeledText("Name:").setText(name);
		new LabeledText("Value:").setText(value);
		new OkButton().click();
	}

	public void setResourceLimitation(String CPU, String memoryLimit) {
		new CheckBox("Enable resource limitations").click();

		switch (CPU) {
		case "Low":
			new RadioButton("Low").click();
			break;
		case "Medium":
			new RadioButton("Medium").click();
			break;
		case "High":
			new RadioButton("High").click();
			break;
		default:
			new RadioButton("Medium").click();
		}

		new LabeledText("Memory limit:").setText(memoryLimit);
	}

	public void setEntrypoint(String Entrypoint) {
		new LabeledText("Entrypoint:").setText(Entrypoint);
	}

	public void setCommand(String command) {
		new LabeledText("Command:").setText(command);
	}

	public void setPublishAllExposedPorts() {
		new CheckBox("Publish all exposed ports to random ports on the host interfaces").click();
	}

	public void setKeepSTDINOpen() {
		new CheckBox("Keep STDIN open to Console even if not attached (-i)").click();
	}

	public void setAllocatePseudoTTY() {
		new CheckBox("Allocate pseudo-TTY from Console (-t)").click();
	}

	public void setAutomaticalyRemove() {
		new CheckBox("Automatically remove the container when it exits (--rm)").click();
	}

}

Back to the top