X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2Fmanagement%2FBundleInfo.java;fp=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2Fmanagement%2FBundleInfo.java;h=6df8dfad8c521eb012a0444f360bac3367d98332;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/BundleInfo.java b/bundles/org.simantics.project/src/org/simantics/project/management/BundleInfo.java new file mode 100644 index 000000000..6df8dfad8 --- /dev/null +++ b/bundles/org.simantics.project/src/org/simantics/project/management/BundleInfo.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * 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: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.project.management; + +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IVersionedId; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionedId; + +public class BundleInfo implements Comparable, IVersionedId { + + public static BundleInfo read(IInstallableUnit iu) { + String name = iu.getProperty("org.eclipse.equinox.p2.name"); + String description = iu.getProperty("org.eclipse.equinox.p2.description"); + return new BundleInfo(iu, name, description); + } + + public IVersionedId vid; + public String name; + public String description; + + public BundleInfo(String id, String version, String name, String description) { + vid = new VersionedId(id, version); + this.name = name; + this.description = description; + } + + public BundleInfo(IVersionedId vid, String name, String description) { + this.vid = vid; + this.name = name; + this.description = description; + } + + @Override + public String toString() { + return name; + } + + public String toVersionString() { + return Version.emptyVersion.equals(vid.getVersion()) ? vid.getId() : vid.getId() + '/' + vid.getVersion().toString(); + } + + @Override + public int compareTo(BundleInfo o) { + return name.compareTo( o.name ); + } + + public String getId() { + return vid.getId(); + } + + public void setId(IVersionedId vid) { + this.vid = vid; + } + + public Version getVersion() { + return vid.getVersion(); + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public int hashCode() { + return vid.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return vid.equals(obj); + } + +} +