--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semamtum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.platform.ui.PlatformUIResource;\r
+\r
+/**\r
+ * @author Antti Villberg\r
+ * @see NameLabelUtil\r
+ */\r
+public enum NameLabelMode {\r
+\r
+ NAME("Name"),\r
+ LABEL("Label"),\r
+ NAME_AND_LABEL("Name (Label)"),\r
+ LABEL_AND_NAME("Label (Name)");\r
+\r
+ private String label;\r
+\r
+ NameLabelMode(String label) {\r
+ this.label = label;\r
+ }\r
+\r
+ public String getLabel() {\r
+ return label;\r
+ }\r
+\r
+ public NameLabelMode cycle() {\r
+ if(NAME == this) return LABEL;\r
+ else if (LABEL == this) return NAME_AND_LABEL;\r
+ else if (NAME_AND_LABEL == this) return LABEL_AND_NAME;\r
+ else return NAME;\r
+ }\r
+\r
+ public Resource asResource(PlatformUIResource UI) {\r
+ if(NAME == this) return UI.NameLabelMode_Name;\r
+ else if (LABEL == this) return UI.NameLabelMode_Label;\r
+ else if (LABEL_AND_NAME == this) return UI.NameLabelMode_LabelAndName;\r
+ else return UI.NameLabelMode_NameAndLabel;\r
+ }\r
+\r
+ public static NameLabelMode fromString(String value) {\r
+ if(value == null) return getDefault();\r
+ else return valueOf(value);\r
+ }\r
+\r
+ public static NameLabelMode getDefault() {\r
+ return NAME_AND_LABEL;\r
+ }\r
+\r
+}
\ No newline at end of file