Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fdb8a9f7ab6c0746f192a8ca14361a3b99dbd322 (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
/*******************************************************************************
 *  Copyright (c) 2008, 2010 IBM Corporation and others.
 *
 *  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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.model;

import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.query.IUViewQueryContext;
import org.eclipse.equinox.p2.ui.Policy;
import org.eclipse.equinox.p2.ui.ProvisioningUI;

/**
 * Element class that represents the root of a viewer.  It can be configured
 * with its own ui and query context.
 * 
 * @since 3.5
 *
 */
public abstract class RootElement extends RemoteQueriedElement {

	private IUViewQueryContext queryContext;
	private ProvisioningUI ui;

	public RootElement(ProvisioningUI ui) {
		this(null, ProvUI.getQueryContext(ui.getPolicy()), ui);
	}

	public RootElement(IUViewQueryContext queryContext, ProvisioningUI ui) {
		this(null, queryContext, ui);
	}

	/*
	 * Special method for subclasses that can sometimes be a root, and sometimes not.
	 */
	protected RootElement(Object parent, IUViewQueryContext queryContext, ProvisioningUI ui) {
		super(parent);
		this.queryContext = queryContext;
		this.ui = ui;
	}

	/**
	 * Set the query context that is used when querying the receiver.
	 * 
	 * @param context the query context to use
	 */
	public void setQueryContext(IUViewQueryContext context) {
		queryContext = context;
	}

	@Override
	public IUViewQueryContext getQueryContext() {
		return queryContext;
	}

	@Override
	public Policy getPolicy() {
		return ui.getPolicy();
	}

	@Override
	public ProvisioningUI getProvisioningUI() {
		return ui;
	}
}

Back to the top