Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f22cdb8288f1c919666bfe776e42f02c734c049f (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
/*******************************************************************************
 * Copyright (c) 2018 Red Hat.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Red Hat - Initial Contribution
 *******************************************************************************/
package org.eclipse.cdt.internal.docker.launcher;

import java.util.List;
import java.util.Set;

import org.eclipse.core.databinding.observable.list.WritableList;

/**
 * @since 1.2.1
 * @author jjohnstn
 *
 */
public class ContainerTabModel extends BaseDatabindingModel {

	public static final String PUBLISH_ALL_PORTS = "publishAllPorts"; //$NON-NLS-1$

	public static final String EXPOSED_PORTS = "exposedPorts"; //$NON-NLS-1$

	public static final String SELECTED_PORTS = "selectedPorts"; //$NON-NLS-1$

	private boolean publishAllPorts = true;

	private final WritableList<ExposedPortModel> exposedPorts = new WritableList<>();

	private Set<ExposedPortModel> selectedPorts;

	public boolean isPublishAllPorts() {
		return publishAllPorts;
	}

	public void setPublishAllPorts(boolean publishAllPorts) {
		firePropertyChange(PUBLISH_ALL_PORTS, this.publishAllPorts,
				this.publishAllPorts = publishAllPorts);
	}

	public WritableList<ExposedPortModel> getExposedPorts() {
		return exposedPorts;
	}

	public void addAvailablePort(final ExposedPortModel port) {
		this.exposedPorts.add(port);
	}

	public void removeAvailablePort(final ExposedPortModel port) {
		this.exposedPorts.remove(port);
	}

	public void setExposedPorts(final List<ExposedPortModel> exposedPorts) {
		this.exposedPorts.clear();
		this.exposedPorts.addAll(exposedPorts);
		// FIXME: also add all given exposedPorts to selectedExposedPorts ?
	}

	public void addExposedPort(final ExposedPortModel exposedPort) {
		if (!this.exposedPorts.contains(exposedPort)) {
			this.exposedPorts.add(exposedPort);
		}
	}

	public void removeExposedPort(final ExposedPortModel exposedPort) {
		this.exposedPorts.remove(exposedPort);
	}

	public void removeExposedPorts() {
		this.exposedPorts.clear();
	}

	public Set<ExposedPortModel> getSelectedPorts() {
		return this.selectedPorts;
	}

	public void setSelectedPorts(final Set<ExposedPortModel> ports) {
		firePropertyChange(SELECTED_PORTS, this.selectedPorts,
				this.selectedPorts = ports);
	}

}

Back to the top