blob: f684537b289290a01ce08060623b45789d21944c (
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
|
/*******************************************************************************
* Copyright (c) 2007, 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.*;
import org.eclipse.equinox.internal.p2.ui.query.IUViewQueryContext;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* Element class that represents some collection of metadata repositories. It
* can be configured so that it retrieves its children in different ways. The
* default query type will return the metadata repositories specified in this
* element. Other query types can be used to query each repository and aggregate
* the children.
*
* @since 3.4
*
*/
public class MetadataRepositories extends RootElement {
private boolean includeDisabled = false;
public MetadataRepositories(ProvisioningUI ui) {
this(ProvUI.getQueryContext(ui.getPolicy()), ui, null);
}
public MetadataRepositories(IUViewQueryContext queryContext, ProvisioningUI ui,
QueryableMetadataRepositoryManager queryable) {
super(queryContext, ui);
this.queryable = queryable;
}
/**
* Get whether disabled repositories should be included in queries when no
* repositories have been specified. This boolean is used because the flags
* specified when getting repositories from a repository manager are treated as
* an AND, and we want to permit aggregating disabled repositories along with
* other flags.
*
* @return includeDisabled <code>true</code> if disabled repositories should be
* included and <code>false</code> if they should not be included.
*/
public boolean getIncludeDisabledRepositories() {
return includeDisabled;
}
/**
* Set whether disabled repositories should be included in queries when no
* repositories have been specified. This boolean is used because the flags
* specified when getting repositories from a repository manager are treated as
* an AND, and we want to permit aggregating disabled repositories along with
* other flags.
*
* @param includeDisabled <code>true</code> if disabled repositories should be
* included and <code>false</code> if they should not be
* included.
*/
public void setIncludeDisabledRepositories(boolean includeDisabled) {
this.includeDisabled = includeDisabled;
}
/*
* Overridden to check the query context. We might be showing repositories, or
* we might be flattening the view to some other element
*/
@Override
public int getQueryType() {
if (getQueryContext() == null)
return getDefaultQueryType();
return getQueryContext().getQueryType();
}
@Override
protected int getDefaultQueryType() {
return QueryProvider.METADATA_REPOS;
}
@Override
public String getLabel(Object o) {
return ProvUIMessages.Label_Repositories;
}
/*
* Overridden because we might be iterating sites (type = METADATA_REPOSITORIES)
* rather than loading repos. If this is the case, we only care whether we have
* a queryable or not.
*/
@Override
public boolean hasQueryable() {
if (getQueryType() == QueryProvider.METADATA_REPOS)
return queryable != null;
return super.hasQueryable();
}
}
|