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
10 * Semamtum Oy - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics;
\r
14 import org.simantics.db.Resource;
\r
15 import org.simantics.platform.ui.PlatformUIResource;
\r
18 * @author Antti Villberg
\r
19 * @see NameLabelUtil
\r
21 public enum NameLabelMode {
\r
25 NAME_AND_LABEL("Name (Label)"),
\r
26 LABEL_AND_NAME("Label (Name)");
\r
28 private String label;
\r
30 NameLabelMode(String label) {
\r
34 public String getLabel() {
\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
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
52 public static NameLabelMode fromString(String value) {
\r
53 if(value == null) return getDefault();
\r
54 else return valueOf(value);
\r
57 public static NameLabelMode getDefault() {
\r
58 return NAME_AND_LABEL;
\r