]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.project/src/org/simantics/project/management/BundleInfo.java
Support ontology install option trueWhenDeployed also during development
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / management / BundleInfo.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.project.management;
13
14 import org.eclipse.equinox.p2.metadata.IInstallableUnit;
15 import org.eclipse.equinox.p2.metadata.IVersionedId;
16 import org.eclipse.equinox.p2.metadata.Version;
17 import org.eclipse.equinox.p2.metadata.VersionedId;
18
19 public class BundleInfo implements Comparable<BundleInfo>, IVersionedId {
20
21         public static BundleInfo read(IInstallableUnit iu) {
22         String name = iu.getProperty("org.eclipse.equinox.p2.name");
23         String description = iu.getProperty("org.eclipse.equinox.p2.description");
24         return new BundleInfo(iu, name, description);
25         }
26         
27         public IVersionedId vid;
28         public String name;
29         public String description;
30         
31         public BundleInfo(String id, String version, String name, String description) {
32                 vid = new VersionedId(id, version);
33                 this.name = name;
34                 this.description = description;
35         }
36         
37         public BundleInfo(IVersionedId vid, String name, String description) {
38                 this.vid = vid;
39                 this.name = name;
40                 this.description = description;          
41         }
42
43         @Override
44         public String toString() {
45                 return name;
46         }
47         
48         public String toVersionString() {               
49                 return Version.emptyVersion.equals(vid.getVersion()) ? vid.getId() : vid.getId() + '/' + vid.getVersion().toString();
50         }
51         
52         @Override
53         public int compareTo(BundleInfo o) {            
54                 return name.compareTo( o.name );
55         }
56
57         public String getId() {
58                 return vid.getId();
59         }
60
61         public void setId(IVersionedId vid) {
62                 this.vid = vid;
63         }
64
65         public Version getVersion() {
66                 return vid.getVersion();
67         }
68
69         public String getDescription() {
70                 return description;
71         }
72
73         public void setDescription(String description) {
74                 this.description = description;
75         }
76
77         public String getName() {
78                 return name;
79         }
80
81         public void setName(String name) {
82                 this.name = name;
83         }
84         
85         @Override
86         public int hashCode() {
87                 return vid.hashCode();
88         }
89         
90         @Override
91         public boolean equals(Object obj) {
92                 return vid.equals(obj);
93         }
94         
95 }
96