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