]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics/src/org/simantics/NameLabelMode.java
SimanticsPlatform.startUp ensures updateness of installed feature groups
[simantics/platform.git] / bundles / org.simantics / src / org / simantics / NameLabelMode.java
1 /*******************************************************************************
2  * Copyright (c) 2013 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  *     Semamtum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics;
13
14 import org.simantics.db.Resource;
15 import org.simantics.platform.ui.PlatformUIResource;
16
17 /**
18  * @author Antti Villberg
19  * @see NameLabelUtil
20  */
21 public enum NameLabelMode {
22
23         NAME("Name"),
24         LABEL("Label"),
25         NAME_AND_LABEL("Name (Label)"),
26         LABEL_AND_NAME("Label (Name)");
27
28         private String label;
29
30         NameLabelMode(String label) {
31                 this.label = label;
32         }
33
34         public String getLabel() {
35                 return label;
36         }
37
38         public NameLabelMode cycle() {
39                 if(NAME == this) return LABEL;
40                 else if (LABEL == this) return NAME_AND_LABEL;
41                 else if (NAME_AND_LABEL == this) return LABEL_AND_NAME;
42                 else return NAME;
43         }
44
45         public Resource asResource(PlatformUIResource UI) {
46                 if(NAME == this) return UI.NameLabelMode_Name;
47                 else if (LABEL == this) return UI.NameLabelMode_Label;
48                 else if (LABEL_AND_NAME == this) return UI.NameLabelMode_LabelAndName;
49                 else return UI.NameLabelMode_NameAndLabel;
50         }
51
52         public static NameLabelMode fromString(String value) {
53                 if(value == null) return getDefault();
54                 else return valueOf(value);
55         }
56
57         public static NameLabelMode getDefault() {
58                 return NAME_AND_LABEL;
59         }
60
61 }