blob: 28d5a4c6e1026bd8d24de5caef6724394cdf88ab [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 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.model;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
/**
* Element wrapper class for an artifact key and its repository
*
* @since 3.4
*/
public class ArtifactElement extends ProvElement {
IArtifactKey key;
IArtifactRepository repo;
public ArtifactElement(Object parent, IArtifactKey key, IArtifactRepository repo) {
super(parent);
this.key = key;
this.repo = repo;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.internal.provisional.p2.ui.model.ProvElement#getImageID(java.lang.Object)
*/
protected String getImageId(Object obj) {
return null;
}
public String getLabel(Object o) {
return key.getId() + " [" + key.getClassifier() + "]"; //$NON-NLS-1$//$NON-NLS-2$
}
public Object[] getChildren(Object o) {
return repo.getArtifactDescriptors(key);
}
// don't suppress this warning as it will cause build-time warning
// see bug 423628. This should be possible to fix once
// the entire hierarchy adopts generics
public Object getAdapter(Class adapter) {
if (adapter == IArtifactRepository.class)
return getArtifactRepository();
if (adapter == IArtifactKey.class)
return getArtifactKey();
return super.getAdapter(adapter);
}
public IArtifactKey getArtifactKey() {
return key;
}
public IArtifactRepository getArtifactRepository() {
return repo;
}
}