Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a438b3e5378f2b9c52d27e2f3cd2a9062fff977a (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*******************************************************************************
 * Copyright (c) 2007 Oracle Corporation.
 * 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.jst.pagedesigner.jsp.core.internal.metadata;

import org.eclipse.jst.jsf.common.metadata.internal.AbstractTagLibDomainContentModelMetaDataTranslator;
import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant;
import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataTranslator;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;

/**
 * Translates a TLD CMDocument to standard metadata model entities and traits
 *
 */
public class TaglibMetaDataTLDTranslator extends AbstractTagLibDomainContentModelMetaDataTranslator implements IMetaDataTranslator {

	/* (non-Javadoc)
	 * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataTranslator#translate(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant)
	 */
	public void translate(final IMetaDataModelMergeAssistant assistant) {
		setAssistant(assistant);
		CMDocument doc = getSourceModel();
		if (doc != null && doc instanceof TLDDocument){
			doTranslate(doc);
			
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.jst.jsf.common.metadata.internal.AbstractTagLibDomainContentModelMetaDataTranslator#getURIDefaultPrefix()
	 */
	protected String getURIDefaultPrefix(){
		return getTLDDocument().getShortname();
	}
	
	/**
	 * @param tag
	 * @return the tag.getDisplayName() if available
	 */
	protected String getTagDisplayLabel(CMElementDeclaration tag){
		String label = ((TLDElementDeclaration)tag).getDisplayName();
		if (label == null)
			label = super.getTagDisplayName(tag);
		return label;		
	}
	
	/**
	 * @param tag
	 * @return the tag.getDescription() if available
	 */
	protected String getTagDescription(CMElementDeclaration tag){
		String desc = ((TLDElementDeclaration)tag).getDescription();
		if (desc == null)
			desc = super.getTagDescription(tag);
		return desc;		
	}
	
	/**
	 * @param tag
	 * @return the tag.getSmallIcon() if available
	 */
	protected String getTagSmallIcon(CMElementDeclaration tag){
		String smallIcon = ((TLDElementDeclaration)tag).getSmallIcon();
		if (smallIcon == null)
			smallIcon = super.getTagSmallIcon(tag);
		return smallIcon;		
	}
	
	/**
	 * @param tag
	 * @return the tag.getLargeIcon() if available
	 */
	protected String getTagLargeIcon(CMElementDeclaration tag){
		String largeIcon = ((TLDElementDeclaration)tag).getLargeIcon();
		if (largeIcon == null)
			largeIcon = super.getTagLargeIcon(tag);
		return largeIcon;		
	}
	
	/**
	 * @return the tag.getDescription() if available
	 */
	protected String getURIDescription() {		
		return getTLDDocument().getDescription();
	}

	/**
	 * @return the tag.getDisplayName()
	 */
	protected String getURIDisplayLabel() {		
		return getTLDDocument().getDisplayName();
	}
	
	/**
	 * @return the tld document for the source model
	 */
	protected TLDDocument getTLDDocument(){
		return (TLDDocument)getSourceModel();
	}

}

Back to the top