Skip to main content
summaryrefslogtreecommitdiffstats
blob: 509a13eab8b7019c549fb9c9b647bdb8a44ace07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*******************************************************************************
 *  Copyright (c) 2008, 2010 Oracle. 
 *  All rights reserved.  This program and the accompanying materials 
 *  are made available under the terms of the Eclipse Public License v1.0 
 *  which accompanies this distribution, and is available at 
 *  http://www.eclipse.org/legal/epl-v10.html
 *  
 *  Contributors: 
 *  	Oracle - initial API and implementation
 *******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal;

import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin;
import org.eclipse.swt.graphics.Image;

public class JpaMappingImageHelper
{

	public static Image imageForTypeMapping(String mappingKey) {
		return JptJpaUiPlugin.getImage(iconKeyForTypeMapping(mappingKey));
	}

	public static String iconKeyForTypeMapping(String mappingKey) {
		if (Tools.valuesAreEqual(mappingKey, MappingKeys.NULL_TYPE_MAPPING_KEY)) {
			return JptUiIcons.NULL_TYPE_MAPPING;
		}
		if (Tools.valuesAreEqual(mappingKey, MappingKeys.ENTITY_TYPE_MAPPING_KEY)) {
			return JptUiIcons.ENTITY;
		}
		if (Tools.valuesAreEqual(mappingKey, MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY)) {
			return JptUiIcons.EMBEDDABLE;
		}
		if (Tools.valuesAreEqual(mappingKey, MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY)) {
			return JptUiIcons.MAPPED_SUPERCLASS;
		}
		return null;
	}

	public static Image imageForAttributeMapping(String mappingKey) {
		return JptJpaUiPlugin.getImage(iconKeyForAttributeMapping(mappingKey));
	}

	public static String iconKeyForAttributeMapping(String mappingKey) {
		if (MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY == mappingKey) {
			return JptUiIcons.NULL_ATTRIBUTE_MAPPING;
		}
		else if (MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.BASIC;
		}
		else if (MappingKeys.ID_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.ID;
		}
		else if (MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.VERSION;
		}
		else if (MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.EMBEDDED_ID;
		}
		else if (MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.EMBEDDED;
		}
		else if (MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.ONE_TO_ONE;
		}
		else if (MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.ONE_TO_MANY;
		}
		else if (MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.MANY_TO_ONE;
		}
		else if (MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.MANY_TO_MANY;
		}
		else if (MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.ELEMENT_COLLECTION;
		}
		else if (MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
			return JptUiIcons.TRANSIENT;
		}
		//return the JPA_CONTENT icon instead of null, might as well have an icon if one is not defined
		return JptUiIcons.JPA_CONTENT;
	}
}

Back to the top