]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/SubscriptionItem.java
Fixed ComponentTypeCommands.setUnit to support unit == null
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / subscription / SubscriptionItem.java
1 /*******************************************************************************
2  * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     VTT Technical Research Centre of Finland - initial API and implementation
10  *******************************************************************************/
11 package org.simantics.modeling.subscription;
12
13 import org.simantics.databoard.annotations.Identifier;
14 import org.simantics.databoard.annotations.Optional;
15 import org.simantics.databoard.util.Bean;
16 import org.simantics.utils.strings.AlphanumComparator;
17
18 /**
19  * @author Antti Villberg
20  */
21 public class SubscriptionItem extends Bean {
22         
23         // Normal Label (eg. The label in CSV file)
24         public @Optional String simpleLabel;
25         // Variable reference in user friendly format
26         public @Optional String variableReference;
27         
28         // GroupId in the history
29         public @Identifier String groupId;
30         // ItemId in the group
31         public @Identifier String groupItemId;
32         // Variable id in format understood by org.simantics.simulation.data.Datasource
33         public @Identifier String variableId;
34         
35         public @Optional String unit;
36         
37         public SubscriptionItem() {
38         }
39         
40         @Override
41         public int compareTo(Bean o) {
42                 if ( o instanceof SubscriptionItem == false ) return 0;
43                 SubscriptionItem other = (SubscriptionItem) o;
44                 
45                 String myLabel2 = simpleLabel!=null?simpleLabel:"";
46                 String otLabel2 = other.simpleLabel!=null?other.simpleLabel:"";
47                 int c = AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(myLabel2, otLabel2);
48                 if ( c!=0 ) return c;
49                 
50                 String mySid = groupId!=null?groupId:""; 
51                 String otSid = other.groupId!=null?other.groupId:""; 
52                 c = mySid.compareTo(otSid);
53                 if ( c!=0 ) return c;
54
55                 String myGiid = groupItemId!=null?groupItemId:""; 
56                 String otGiid = other.groupItemId!=null?other.groupItemId:""; 
57                 c = myGiid.compareTo(otGiid);
58                 if ( c!=0 ) return c;
59
60                 String myVid = variableId!=null?variableId:""; 
61                 String otVid = other.variableId!=null?other.variableId:""; 
62                 c = myVid.compareTo(otVid);
63                 if ( c!=0 ) return c;
64                 
65                 return c;               
66         }
67         
68 }
69