Lines 1-23
Link Here
|
1 |
package org.eclipse.jst.pagedesigner.itemcreation.command; |
1 |
package org.eclipse.jst.pagedesigner.itemcreation.command; |
2 |
|
2 |
|
3 |
import java.util.HashMap; |
3 |
import java.util.HashMap; |
4 |
import java.util.Iterator; |
4 |
import java.util.List; |
5 |
import java.util.Map; |
5 |
import java.util.Map; |
6 |
|
6 |
|
7 |
import org.eclipse.core.resources.IFile; |
7 |
import org.eclipse.core.resources.IFile; |
8 |
import org.eclipse.core.resources.IProject; |
8 |
import org.eclipse.core.resources.IProject; |
9 |
import org.eclipse.emf.common.util.EList; |
|
|
10 |
import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; |
9 |
import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; |
11 |
import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; |
10 |
import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; |
12 |
import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.ResolverUtil; |
11 |
import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.ResolverUtil; |
13 |
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationAttribute; |
12 |
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationAttribute; |
14 |
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationInfo; |
|
|
15 |
import org.eclipse.jst.pagedesigner.PDPlugin; |
13 |
import org.eclipse.jst.pagedesigner.PDPlugin; |
16 |
import org.eclipse.jst.pagedesigner.dom.DOMPosition; |
14 |
import org.eclipse.jst.pagedesigner.dom.DOMPosition; |
17 |
import org.eclipse.jst.pagedesigner.dom.IDOMPosition; |
15 |
import org.eclipse.jst.pagedesigner.dom.IDOMPosition; |
18 |
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry; |
16 |
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData; |
|
|
17 |
import org.eclipse.jst.pagedesigner.editors.palette.MetadataTagDropSourceData; |
18 |
import org.eclipse.jst.pagedesigner.editors.palette.TagToolCreationAdapter; |
19 |
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteItemManager; |
19 |
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteItemManager; |
20 |
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer; |
|
|
21 |
import org.eclipse.jst.pagedesigner.itemcreation.CreationData; |
20 |
import org.eclipse.jst.pagedesigner.itemcreation.CreationData; |
22 |
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData; |
21 |
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData; |
23 |
import org.eclipse.jst.pagedesigner.utils.JSPUtil; |
22 |
import org.eclipse.jst.pagedesigner.utils.JSPUtil; |
Lines 70-83
Link Here
|
70 |
if (_creationData.getDropCustomizationData() != null) |
69 |
if (_creationData.getDropCustomizationData() != null) |
71 |
{ |
70 |
{ |
72 |
final ICustomizationData data = (ICustomizationData) _creationData.getDropCustomizationData().getAdapter(ICustomizationData.class); |
71 |
final ICustomizationData data = (ICustomizationData) _creationData.getDropCustomizationData().getAdapter(ICustomizationData.class); |
73 |
|
72 |
|
74 |
if (data.getChildrenData() != null) |
73 |
if (data.getChildrenData() != null) |
75 |
{ |
74 |
{ |
76 |
int childCount = 0; |
75 |
int childCount = 0; |
77 |
CHILDREN_LOOP: for (ICustomizationData child : data.getChildrenData().getChildList()) |
76 |
CHILDREN_LOOP: for (ICustomizationData child : data.getChildrenData().getChildList()) |
78 |
{ |
77 |
{ |
79 |
assert (_element.getOwnerDocument() != null); |
78 |
assert (_element.getOwnerDocument() != null); |
80 |
|
79 |
|
81 |
// Setup child node |
80 |
// Setup child node |
82 |
Element childNode = _element.getOwnerDocument().createElement(child.getTagIdentifier().getTagName()); |
81 |
Element childNode = _element.getOwnerDocument().createElement(child.getTagIdentifier().getTagName()); |
83 |
String prefix = JSPUtil.getOrCreatePrefix(_model, child.getTagIdentifier().getUri(), null); |
82 |
String prefix = JSPUtil.getOrCreatePrefix(_model, child.getTagIdentifier().getUri(), null); |
Lines 90-136
Link Here
|
90 |
String attrValue = attrMap.get(attrName); |
89 |
String attrValue = attrMap.get(attrName); |
91 |
childNode.setAttribute(attrName, attrValue); |
90 |
childNode.setAttribute(attrName, attrValue); |
92 |
} |
91 |
} |
93 |
|
92 |
|
94 |
// Attach child node to element |
93 |
// Attach child node to element |
95 |
_element.appendChild(childNode); |
94 |
_element.appendChild(childNode); |
96 |
|
95 |
|
97 |
// Set up other attributes and child tags for this child |
96 |
// Set up other attributes and child tags for this child |
98 |
IFile fileForDocument = ResolverUtil.getFileForDocument(_model.getStructuredDocument()); |
97 |
IFile fileForDocument = ResolverUtil.getFileForDocument(_model.getStructuredDocument()); |
99 |
if (fileForDocument == null) |
98 |
if (fileForDocument == null) |
100 |
{ |
99 |
{ |
101 |
PDPlugin.log("File not found for model: "+_model.toString(), new Exception("Stack trace only")); //$NON-NLS-1$//$NON-NLS-2$ |
100 |
PDPlugin.log("File not found for model: "+_model.toString(), new Exception("Stack trace only")); //$NON-NLS-1$//$NON-NLS-2$ |
102 |
continue CHILDREN_LOOP; |
101 |
continue CHILDREN_LOOP; |
103 |
} |
102 |
} |
104 |
final IProject project = fileForDocument.getProject(); |
103 |
final IProject project = fileForDocument.getProject(); |
105 |
PaletteItemManager paletteManager = PaletteItemManager.getInstance(project); |
104 |
PaletteItemManager itemManager = PaletteItemManager.getInstance(project); |
106 |
|
|
|
107 |
if (paletteManager == null) |
108 |
{ |
109 |
PDPlugin.log("paletteManager not found for project: "+project.toString(), new Exception("Stack trace only")); //$NON-NLS-1$ //$NON-NLS-2$ |
110 |
continue CHILDREN_LOOP; |
111 |
} |
112 |
|
113 |
TaglibPaletteDrawer drawer = paletteManager.findCategoryByURI(child.getTagIdentifier().getUri()); |
114 |
|
115 |
if (drawer == null) |
116 |
{ |
117 |
PDPlugin.log("Drawer not found for uri: "+child.getTagIdentifier().getUri(), new Exception("Stack trace only")); //$NON-NLS-1$ //$NON-NLS-2$ |
118 |
continue CHILDREN_LOOP; |
119 |
} |
120 |
|
105 |
|
121 |
TagToolPaletteEntry paletteEntry = drawer.getTagPaletteEntryByTagName(child.getTagIdentifier().getTagName()); |
106 |
if (itemManager == null) |
122 |
|
|
|
123 |
if (paletteEntry == null) |
124 |
{ |
107 |
{ |
125 |
PDPlugin.log("Palette entry not found for drawer: "+drawer.toString(), new Exception("Stack trace only")); //$NON-NLS-1$ //$NON-NLS-2$ |
108 |
PDPlugin.log("paletteManager not found for project: "+project.toString(), new Exception("Stack trace only")); //$NON-NLS-1$ //$NON-NLS-2$ |
126 |
continue CHILDREN_LOOP; |
109 |
continue CHILDREN_LOOP; |
127 |
} |
110 |
} |
|
|
111 |
|
112 |
final String uri = child.getTagIdentifier().getUri(); |
113 |
final String tagName = child.getTagIdentifier().getTagName(); |
114 |
final ITagDropSourceData creationProvider = |
115 |
TagToolCreationAdapter.findProviderForContainer(uri, tagName, itemManager); |
128 |
final ITaglibDomainMetaDataModelContext modelContext = |
116 |
final ITaglibDomainMetaDataModelContext modelContext = |
129 |
TaglibDomainMetaDataQueryHelper |
117 |
TaglibDomainMetaDataQueryHelper |
130 |
.createMetaDataModelContext(project, child.getTagIdentifier().getUri()); |
118 |
.createMetaDataModelContext(project, child.getTagIdentifier().getUri()); |
131 |
IDOMPosition domPosition = new DOMPosition(_element, childCount++); |
119 |
IDOMPosition domPosition = new DOMPosition(_element, childCount++); |
132 |
CreationData creationData = new CreationData(paletteEntry,_model, domPosition, modelContext, child); |
120 |
CreationData creationData = new CreationData(creationProvider,_model, domPosition, modelContext, child); |
133 |
|
121 |
|
134 |
ElementCustomizationCommand command = new UserCustomizedElementCustomizationCommand(_model, childNode, creationData); |
122 |
ElementCustomizationCommand command = new UserCustomizedElementCustomizationCommand(_model, childNode, creationData); |
135 |
command.execute(); |
123 |
command.execute(); |
136 |
} |
124 |
} |
Lines 184-199
Link Here
|
184 |
|
172 |
|
185 |
private void addAttributesFromPaletteMetadata(Map<String, String> attributes) |
173 |
private void addAttributesFromPaletteMetadata(Map<String, String> attributes) |
186 |
{ |
174 |
{ |
187 |
final TagCreationInfo info = _creationData.getTagCreationInfo(); |
175 |
final ITagDropSourceData info = _creationData.getTagCreationProvider(); |
188 |
if (info != null) |
176 |
if (info != null) |
189 |
{ |
177 |
{ |
190 |
final EList list = info.getAttributes(); |
178 |
final MetadataTagDropSourceData provider = |
|
|
179 |
TagToolCreationAdapter.createMdTagCreationProvider(info, _model); |
180 |
|
181 |
final List<TagCreationAttribute> list = provider.getAttributes(); |
191 |
if (list != null) |
182 |
if (list != null) |
192 |
{ |
183 |
{ |
193 |
for (final Iterator it = list.iterator(); it.hasNext();) |
184 |
for (final TagCreationAttribute attr : list) |
194 |
{ |
185 |
{ |
195 |
final TagCreationAttribute attr = (TagCreationAttribute) it |
|
|
196 |
.next(); |
197 |
attributes.put(attr.getId(), (attr.getValue() == null ? "" //$NON-NLS-1$ |
186 |
attributes.put(attr.getId(), (attr.getValue() == null ? "" //$NON-NLS-1$ |
198 |
: attr.getValue())); |
187 |
: attr.getValue())); |
199 |
} |
188 |
} |