Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8f36fb56c64b59a369e7c35dce54f088dc692cfd (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*******************************************************************************
 *  Copyright (c) 2008, 2010 IBM Corporation and others.
 *  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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.query;

import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.QueryProvider;

/**
 * IUViewQueryContext defines the different ways 
 * IUs can be viewed.  Clients can use this context to 
 * control how the various IU views are represented and traversed.
 * 
 * @since 2.0
 */
public class IUViewQueryContext {
	public static final int AVAILABLE_VIEW_BY_CATEGORY = 1;
	public static final int AVAILABLE_VIEW_BY_REPO = 2;
	public static final int AVAILABLE_VIEW_FLAT = 3;

	// Available view settings
	// Default available view to repo as this provides the fastest information
	private int view = AVAILABLE_VIEW_BY_REPO;
	// Whether to show latest versions only, defaults to
	// true.  Clients typically use a pref setting or dialog
	// setting to initialize
	private boolean showLatestVersionsOnly = true;
	// Whether to hide things that are already installed
	// Defaults to false since we wouldn't know what profile to use
	private boolean hideAlreadyInstalled = false;
	// Whether to group items in repos by category.  Note this only makes sense when the
	// view type is AVAILABLE_VIEW_BY_REPO
	private boolean useCategories = true;
	// Whether to drill down into installed items
	private boolean showInstallChildren = true;
	// Whether to drill down into available items
	private boolean showAvailableChildren = false;
	// Whether to drill down into items in a provisioning plan
	private boolean showProvisioningPlanChildren = true;
	// Whether to filter out IUs based on the environment settings of the target profile
	private boolean filterOnEnv = false;

	private String profileId = null;

	private String hidingInstalledDescription = ProvUIMessages.IUViewQueryContext_AllAreInstalledDescription;
	private String groupingCategoriesDescription = ProvUIMessages.IUViewQueryContext_NoCategorizedItemsDescription;

	public IUViewQueryContext(int viewType) {
		this.view = viewType;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.equinox.internal.provisional.p2.ui.query.QueryContext#getQueryType()
	 */
	public int getQueryType() {
		if (view == AVAILABLE_VIEW_BY_REPO)
			return QueryProvider.METADATA_REPOS;
		return QueryProvider.AVAILABLE_IUS;
	}

	public int getViewType() {
		return view;
	}

	public void setViewType(int viewType) {
		view = viewType;
	}

	public boolean getShowLatestVersionsOnly() {
		return showLatestVersionsOnly;
	}

	public void setShowLatestVersionsOnly(boolean showLatest) {
		showLatestVersionsOnly = showLatest;
	}

	public void hideAlreadyInstalled(String installedProfileId) {
		profileId = installedProfileId;
		hideAlreadyInstalled = true;
	}

	public void showAlreadyInstalled() {
		hideAlreadyInstalled = false;
	}

	public boolean getHideAlreadyInstalled() {
		return hideAlreadyInstalled;
	}

	public String getInstalledProfileId() {
		return profileId;
	}

	public void setInstalledProfileId(String profileId) {
		this.profileId = profileId;
	}

	public void setFilterOnEnv(boolean filterOnEnv) {
		this.filterOnEnv = filterOnEnv;
	}

	public boolean getFilterOnEnv() {
		return filterOnEnv;
	}

	/**
	 * Set a boolean that indicates whether categories should be used when
	 * viewing by repository.
	 * 
	 * useCategories <code>true</code> if a site in a sites view should expand into categories,
	 * <code>false</code> if it should expand into IU's.
	 */

	public void setUseCategories(boolean useCategories) {
		this.useCategories = useCategories;
	}

	/**
	 * Return a boolean that indicates whether categories should be used when
	 * viewing by repository.
	 * 
	 * @return <code>true</code> if a site in a sites view should expand into categories,
	 * <code>false</code> if it should expand into IU's.
	 */
	public boolean getUseCategories() {
		return useCategories;
	}

	public boolean getShowInstallChildren() {
		return showInstallChildren;
	}

	public void setShowInstallChildren(boolean showChildren) {
		showInstallChildren = showChildren;
	}

	public boolean getShowAvailableChildren() {
		return showAvailableChildren;
	}

	public void setShowAvailableChildren(boolean showChildren) {
		showAvailableChildren = showChildren;
	}

	public boolean getShowProvisioningPlanChildren() {
		return showProvisioningPlanChildren;
	}

	public void setShowProvisioningPlanChildren(boolean showChildren) {
		showProvisioningPlanChildren = showChildren;
	}

	public String getHidingInstalledDescription() {
		return hidingInstalledDescription;
	}

	public void setHidingInstalledDescription(String description) {
		hidingInstalledDescription = description;
	}

	public String getUsingCategoriesDescription() {
		return groupingCategoriesDescription;
	}

	public void setUsingCategoriesDescription(String description) {
		groupingCategoriesDescription = description;
	}

	public boolean shouldGroupByCategories() {
		return view == AVAILABLE_VIEW_BY_CATEGORY || (view == AVAILABLE_VIEW_BY_REPO && useCategories);
	}
}

Back to the top