Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c173859459849dc392287d921d9dca91627085c9 (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
/*******************************************************************************
 * Copyright (c) 2014, 2015 Red Hat.
 * 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:
 *     Red Hat - Initial Contribution
 *******************************************************************************/

package org.eclipse.linuxtools.internal.docker.ui.wizards;

import java.util.List;

import org.eclipse.linuxtools.docker.core.IDockerConnection;
import org.eclipse.linuxtools.docker.core.IDockerImageSearchResult;
import org.eclipse.linuxtools.internal.docker.ui.databinding.BaseDatabindingModel;

/**
 * Databinding model for the {@link ImageSearchPage}
 * 
 * @author xcoulon
 *
 */
public class ImageSearchModel extends BaseDatabindingModel {

	public static final String TERM = "term"; //$NON-NLS-1$

	public static final String IMAGE_SEARCH_RESULT = "imageSearchResult"; //$NON-NLS-1$

	public static final String SELECTED_IMAGE = "selectedImage"; //$NON-NLS-1$

	public static final String IMAGE_TAG_SEARCH_RESULT = "imageTagSearchResult"; //$NON-NLS-1$

	public static final String SELECTED_IMAGE_TAG = "selectedImageTag"; //$NON-NLS-1$

	private final IDockerConnection selectedConnection;

	private String term = null;

	private List<IDockerImageSearchResult> imageSearchResult;

	private IDockerImageSearchResult selectedImage;

	private List<DockerImageTagSearchResult> imageTagSearchResult;

	private DockerImageTagSearchResult selectedImageTag;

	public ImageSearchModel(final IDockerConnection selectedConnection) {
		this.selectedConnection = selectedConnection;
	}

	public IDockerConnection getSelectedConnection() {
		return selectedConnection;
	}

	public String getTerm() {
		return term;
	}

	public void setTerm(final String term) {
		firePropertyChange(TERM, this.term, this.term = term);
	}

	public List<IDockerImageSearchResult> getImageSearchResult() {
		return imageSearchResult;
	}

	public void setImageSearchResult(
			final List<IDockerImageSearchResult> searchResult) {
		firePropertyChange(IMAGE_SEARCH_RESULT, this.imageSearchResult,
				this.imageSearchResult = searchResult);
		// set the first item as the selected image
		if (!this.imageSearchResult.isEmpty()) {
			setSelectedImage(this.imageSearchResult.get(0));
		}
	}

	public IDockerImageSearchResult getSelectedImage() {
		return this.selectedImage;
	}

	public void setSelectedImage(final IDockerImageSearchResult selectedImage) {
		firePropertyChange(SELECTED_IMAGE, this.selectedImage,
				this.selectedImage = selectedImage);
	}

	public List<DockerImageTagSearchResult> getImageTagSearchResult() {
		return imageTagSearchResult;
	}

	public void setImageTagSearchResult(
			final List<DockerImageTagSearchResult> searchTagResult) {
		firePropertyChange(IMAGE_TAG_SEARCH_RESULT, this.imageTagSearchResult,
				this.imageTagSearchResult = searchTagResult);
		// set the first item as the selected image
		if (!this.imageTagSearchResult.isEmpty()) {
			setSelectedImageTag(this.imageTagSearchResult.get(0));
		}
	}

	public DockerImageTagSearchResult getSelectedImageTag() {
		return this.selectedImageTag;
	}

	public void setSelectedImageTag(
			final DockerImageTagSearchResult selectedImageTag) {
		firePropertyChange(SELECTED_IMAGE_TAG, this.selectedImageTag,
				this.selectedImageTag = selectedImageTag);
	}

}

Back to the top