]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics/src/org/simantics/NameLabelMode.java
Include acorn db in db.client feature and make it the default db driver
[simantics/platform.git] / bundles / org.simantics / src / org / simantics / NameLabelMode.java
1 /*******************************************************************************\r
2  * Copyright (c) 2013 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     Semamtum Oy - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics;\r
13 \r
14 import org.simantics.db.Resource;\r
15 import org.simantics.platform.ui.PlatformUIResource;\r
16 \r
17 /**\r
18  * @author Antti Villberg\r
19  * @see NameLabelUtil\r
20  */\r
21 public enum NameLabelMode {\r
22 \r
23         NAME("Name"),\r
24         LABEL("Label"),\r
25         NAME_AND_LABEL("Name (Label)"),\r
26         LABEL_AND_NAME("Label (Name)");\r
27 \r
28         private String label;\r
29 \r
30         NameLabelMode(String label) {\r
31                 this.label = label;\r
32         }\r
33 \r
34         public String getLabel() {\r
35                 return label;\r
36         }\r
37 \r
38         public NameLabelMode cycle() {\r
39                 if(NAME == this) return LABEL;\r
40                 else if (LABEL == this) return NAME_AND_LABEL;\r
41                 else if (NAME_AND_LABEL == this) return LABEL_AND_NAME;\r
42                 else return NAME;\r
43         }\r
44 \r
45         public Resource asResource(PlatformUIResource UI) {\r
46                 if(NAME == this) return UI.NameLabelMode_Name;\r
47                 else if (LABEL == this) return UI.NameLabelMode_Label;\r
48                 else if (LABEL_AND_NAME == this) return UI.NameLabelMode_LabelAndName;\r
49                 else return UI.NameLabelMode_NameAndLabel;\r
50         }\r
51 \r
52         public static NameLabelMode fromString(String value) {\r
53                 if(value == null) return getDefault();\r
54                 else return valueOf(value);\r
55         }\r
56 \r
57         public static NameLabelMode getDefault() {\r
58                 return NAME_AND_LABEL;\r
59         }\r
60 \r
61 }