blob: 0db59537b54e870b83db3f07876db4d6bfcf6be5 (
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
|
/*******************************************************************************
* Copyright (c) 2007, 2008 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.provisional.p2.ui.model;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.model.RemoteQueriedElement;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
import org.eclipse.equinox.internal.provisional.p2.query.IQueryable;
import org.eclipse.equinox.internal.provisional.p2.ui.ProvUIImages;
import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
import org.eclipse.equinox.internal.provisional.p2.ui.query.IQueryProvider;
import org.eclipse.osgi.util.NLS;
/**
* Element wrapper class for a profile that uses the query
* mechanism to obtain its contents.
*
* @since 3.4
*/
public class ProfileElement extends RemoteQueriedElement {
String profileId;
public ProfileElement(String profileId) {
this.profileId = profileId;
}
public Object getAdapter(Class adapter) {
if (adapter == IProfile.class)
return getQueryable();
return super.getAdapter(adapter);
}
protected String getImageId(Object obj) {
return ProvUIImages.IMG_PROFILE;
}
public String getLabel(Object o) {
return profileId;
}
protected int getQueryType() {
return IQueryProvider.INSTALLED_IUS;
}
public IQueryable getQueryable() {
try {
return ProvisioningUtil.getProfile(profileId);
} catch (ProvisionException e) {
handleException(e, NLS.bind(ProvUIMessages.ProfileElement_InvalidProfile, profileId));
return null;
}
}
/*
* Overridden to check whether we know the profile id rather
* than fetch the profile from the registry using getQueryable()
* (non-Javadoc)
* @see org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement#knowsQueryable()
*/
public boolean knowsQueryable() {
return profileId != null;
}
/*
* Overridden to check the children so that profiles
* showing in profile views accurately reflect if they
* are empty. We do not cache the children because often
* this element is the input of a view and when the view
* is refreshed we want to refetch the children.
*
* (non-Javadoc)
* @see org.eclipse.equinox.internal.p2.ui.model.RemoteQueriedElement#isContainer()
*/
public boolean isContainer() {
return super.getChildren(this).length > 0;
}
}
|