blob: 45178011827cc644f9ae537ad46ea489797b64e1 (
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
|
package org.eclipse.jst.pagedesigner.itemcreation;
import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
import org.eclipse.jst.pagedesigner.IHTMLConstants;
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
import org.eclipse.jst.pagedesigner.itemcreation.command.ContainerCreationCommand;
import org.eclipse.jst.pagedesigner.itemcreation.command.ElementCustomizationCommand;
import org.eclipse.jst.pagedesigner.itemcreation.command.SingletonContainerCreationCommand;
import org.eclipse.jst.pagedesigner.itemcreation.command.TagContainerCreationCommand;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.w3c.dom.Element;
/**
* The default advisor.
*
* Clients may extend this class.
*
* <p><b>Provisional API - subject to change</b></p>
*
* @author cbateman
*
*/
public class DefaultTagCreationAdvisor extends AbstractTagCreationAdvisor
{
/**
* @param creationData
*/
public DefaultTagCreationAdvisor(CreationData creationData)
{
super(creationData);
}
@Override
protected ElementCustomizationCommand getElementCustomizationCommand(
IDOMModel model, Element tagElement) {
return new ElementCustomizationCommand(model, tagElement, _creationData);
}
/**
* @param position the initial drop position
* @return position after creating required containers
*/
protected ContainerCreationCommand getContainerCreationCommand(final IDOMPosition position) {
if (_creationData.isJSFComponent()) {
return getJSFContainerCommand(position);
}
else if (_creationData.isHTMLFormRequired()){
return getHtmlFormCommand(position);
}
return null;
}
/**
* @param position
* @return the default container creation command for a JSF tag
*/
protected ContainerCreationCommand getJSFContainerCommand(final IDOMPosition position)
{
ContainerCreationCommand command =
new SingletonContainerCreationCommand(position, IJSFConstants.TAG_IDENTIFIER_VIEW, _creationData.getTagId());
if (_creationData.isHTMLFormRequired())
{
command.chain(new TagContainerCreationCommand(position, IJSFConstants.TAG_IDENTIFIER_FORM, _creationData.getTagId()));
}
return command;
}
/**
* @param position
* @return the default container creation command for an HTML form tag
*/
protected ContainerCreationCommand getHtmlFormCommand(final IDOMPosition position)
{
return new TagContainerCreationCommand(position, IHTMLConstants.TAG_IDENTIFIER_HTML_FORM, _creationData.getTagId());
}
}
|