View | Details | Raw Unified | Return to bug 267962 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/TestDefaultTagCreatorJSP.java (-3 / +2 lines)
Lines 11-17 Link Here
11
package org.eclipse.jst.pagedesigner.tests.tagcreator;
11
package org.eclipse.jst.pagedesigner.tests.tagcreator;
12
12
13
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
13
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
14
import org.eclipse.jst.pagedesigner.tests.tagcreator.base.BaseTagCreatorTestCase;
15
14
16
public class TestDefaultTagCreatorJSP extends BaseDefaultTagCreatorTestCase 
15
public class TestDefaultTagCreatorJSP extends BaseDefaultTagCreatorTestCase 
17
{
16
{
Lines 34-40 Link Here
34
33
35
    public void testIncludeDirective() throws Exception
34
    public void testIncludeDirective() throws Exception
36
    {
35
    {
37
        doCreateTest(TagIdentifierFactory.createJSPTagWrapper("jsp11", "jsp:directive.include"), "jsp", "jsp", 349,false);
36
        doCreateTest(TagIdentifierFactory.createJSPTagWrapper("jsp11", "jsp:directive.include"), "jsp", "jsp", 349,false, null);
38
        doCreateTest(TagIdentifierFactory.createJSPTagWrapper("jsp11", "jsp:directive.include"), "jspx", "jspx", 492,false);
37
        doCreateTest(TagIdentifierFactory.createJSPTagWrapper("jsp11", "jsp:directive.include"), "jspx", "jspx", 492,false, null);
39
    }
38
    }
40
}
39
}
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/TestUserCustomizedTagCreatorForJSFHTML_ParentCustomization.java (-8 / +6 lines)
Lines 1-8 Link Here
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
2
2
3
import org.eclipse.core.runtime.IAdaptable;
4
import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
3
import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
5
import org.eclipse.jst.pagedesigner.itemcreation.customizer.CustomizationDataImpl;
4
import org.eclipse.jst.pagedesigner.itemcreation.customizer.CustomizationDataImpl;
5
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData;
6
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IWritableCustomizationData;
6
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IWritableCustomizationData;
7
import org.eclipse.jst.pagedesigner.tests.tagcreatorPlugin.UserCustomizedElementEditFactory;
7
import org.eclipse.jst.pagedesigner.tests.tagcreatorPlugin.UserCustomizedElementEditFactory;
8
8
Lines 24-37 Link Here
24
24
25
	public void testParentTagInsertion() throws Exception
25
	public void testParentTagInsertion() throws Exception
26
    {
26
    {
27
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358, false);
27
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358, false, getCustomizationData());
28
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495, false);
28
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495, false, getCustomizationData());
29
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350, false);
29
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350, false, getCustomizationData());
30
    }
30
    }
31
31
32
	
32
    protected ICustomizationData getCustomizationData()
33
    @Override
34
    protected IAdaptable getCustomizationData()
35
    {
33
    {
36
    	// Setup tag
34
    	// Setup tag
37
    	IWritableCustomizationData data = new CustomizationDataImpl(getTagIdentifier());
35
    	IWritableCustomizationData data = new CustomizationDataImpl(getTagIdentifier());
Lines 63-69 Link Here
63
    	IWritableCustomizationData parent2 = new CustomizationDataImpl(UserCustomizedElementEditFactory.TAG3);
61
    	IWritableCustomizationData parent2 = new CustomizationDataImpl(UserCustomizedElementEditFactory.TAG3);
64
    	data.addParentData(parent2);
62
    	data.addParentData(parent2);
65
63
66
    	return (IAdaptable) data;
64
    	return data;
67
    }
65
    }
68
66
69
    
67
    
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/TestUserCustomizedTagCreatorForJSFHTML_GeneralCustomization.java (-6 / +5 lines)
Lines 1-8 Link Here
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
2
2
3
import org.eclipse.core.runtime.IAdaptable;
4
import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
3
import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
5
import org.eclipse.jst.pagedesigner.itemcreation.customizer.CustomizationDataImpl;
4
import org.eclipse.jst.pagedesigner.itemcreation.customizer.CustomizationDataImpl;
5
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData;
6
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IWritableCustomizationData;
6
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IWritableCustomizationData;
7
import org.eclipse.jst.pagedesigner.tests.tagcreatorPlugin.UserCustomizedElementEditFactory;
7
import org.eclipse.jst.pagedesigner.tests.tagcreatorPlugin.UserCustomizedElementEditFactory;
8
8
Lines 25-38 Link Here
25
	
25
	
26
	public void testGeneralCustomization() throws Exception
26
	public void testGeneralCustomization() throws Exception
27
    {
27
    {
28
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358, false);
28
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358, false, getCustomizationData());
29
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495, false);
29
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495, false, getCustomizationData());
30
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350, false);
30
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350, false, getCustomizationData());
31
    }
31
    }
32
	
32
	
33
33
34
    @Override
34
    protected ICustomizationData getCustomizationData()
35
    protected IAdaptable getCustomizationData()
36
    {
35
    {
37
    	IWritableCustomizationData tagDropped = new CustomizationDataImpl(UserCustomizedElementEditFactory.TAG1);
36
    	IWritableCustomizationData tagDropped = new CustomizationDataImpl(UserCustomizedElementEditFactory.TAG1);
38
        tagDropped.addAttribute("attr1", "value1");
37
        tagDropped.addAttribute("attr1", "value1");
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/TestTagCreationFactory.java (-36 / +37 lines)
Lines 4-10 Link Here
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Oracle Corporation - initial API and implementation
9
 *     Oracle Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
Lines 38-51 Link Here
38
 * @author cbateman
38
 * @author cbateman
39
 *
39
 *
40
 */
40
 */
41
public class TestTagCreationFactory extends BaseTestClass 
41
public class TestTagCreationFactory extends BaseTestClass
42
{
42
{
43
    public TestTagCreationFactory() {
43
    public TestTagCreationFactory() {
44
        super("jsf");
44
        super("jsf");
45
    }
45
    }
46
46
47
    @Override
47
    @Override
48
    protected void setUp() throws Exception 
48
    protected void setUp() throws Exception
49
    {
49
    {
50
        super.setUp();
50
        super.setUp();
51
51
Lines 58-64 Link Here
58
    }
58
    }
59
59
60
    @Override
60
    @Override
61
    protected void tearDown() throws Exception 
61
    protected void tearDown() throws Exception
62
    {
62
    {
63
        super.tearDown();
63
        super.tearDown();
64
    }
64
    }
Lines 72-79 Link Here
72
72
73
        CreationData creationData =
73
        CreationData creationData =
74
            getCreationData(TestCreationFactory.TAGCREATOR_URI_1
74
            getCreationData(TestCreationFactory.TAGCREATOR_URI_1
75
                   , "tagWithRequiredAttr", "test", jspFile, 501);
75
                   , "tagWithRequiredAttr", "test", jspFile, 501, null);
76
        Element element = CommandUtil.excuteInsertion(creationData.getTagEntry()
76
        Element element = CommandUtil.executeInsertion(creationData.getTagCreationProvider()
77
                                    , creationData.getModel()
77
                                    , creationData.getModel()
78
                                    , creationData.getDomPosition()
78
                                    , creationData.getDomPosition()
79
                                    , creationData.getDropCustomizationData());
79
                                    , creationData.getDropCustomizationData());
Lines 96-113 Link Here
96
                ,"/testEnsureRequiredAttributes2.jsp");
96
                ,"/testEnsureRequiredAttributes2.jsp");
97
        creationData =
97
        creationData =
98
            getCreationData(TestCreationFactory.TAGCREATOR_URI_1
98
            getCreationData(TestCreationFactory.TAGCREATOR_URI_1
99
                   , "tagWithRequiredAttr2", "test", jspFile, 501);
99
                   , "tagWithRequiredAttr2", "test", jspFile, 501, null);
100
        element = CommandUtil.excuteInsertion(creationData.getTagEntry()
100
        element = CommandUtil.executeInsertion(creationData.getTagCreationProvider()
101
                                    , creationData.getModel()
101
                                    , creationData.getModel()
102
                                    , creationData.getDomPosition()
102
                                    , creationData.getDomPosition()
103
                                    , creationData.getDropCustomizationData());
103
                                    , creationData.getDropCustomizationData());
104
        
104
105
        // on this tag, the first required attr is set by metadata
105
        // on this tag, the first required attr is set by metadata
106
        assertEquals("foobar", element.getAttribute(TestCreationFactory.REQUIRED_ATTR_1));
106
        assertEquals("foobar", element.getAttribute(TestCreationFactory.REQUIRED_ATTR_1));
107
        // the second one is not set by meta-data, but is required and ensure is called
107
        // the second one is not set by meta-data, but is required and ensure is called
108
        // by the custom advisor, so it should be set to empty
108
        // by the custom advisor, so it should be set to empty
109
        assertEquals("", element.getAttribute(TestCreationFactory.REQUIRED_ATTR_2));
109
        assertEquals("", element.getAttribute(TestCreationFactory.REQUIRED_ATTR_2));
110
        
110
111
        // the optional attribute is not set by meta-data and since it's not required,
111
        // the optional attribute is not set by meta-data and since it's not required,
112
        // the ensure method should not touch it either.
112
        // the ensure method should not touch it either.
113
        assertNull(element.getAttribute("notRequiredAttr1"));
113
        assertNull(element.getAttribute("notRequiredAttr1"));
Lines 115-129 Link Here
115
115
116
    public void testTagCreationMetadata() throws Exception
116
    public void testTagCreationMetadata() throws Exception
117
    {
117
    {
118
        IFile jspFile = (IFile) _webProjectTestEnv.loadResourceInWebRoot(
118
        final IFile jspFile = (IFile) _webProjectTestEnv.loadResourceInWebRoot(
119
                PageDesignerTestsPlugin.getDefault().getBundle()
119
                PageDesignerTestsPlugin.getDefault().getBundle()
120
                ,"/testdata/tagcreator/testTagCreation.jsp.data"
120
                ,"/testdata/tagcreator/testTagCreation.jsp.data"
121
                ,"/testTagCreationMetadata.jsp");
121
                ,"/testTagCreationMetadata.jsp");
122
122
123
        CreationData creationData =
123
        final CreationData creationData =
124
            getCreationData(TestCreationFactory.TAGCREATOR_URI_1
124
            getCreationData(TestCreationFactory.TAGCREATOR_URI_1
125
                   , "tagWithMetadata", "test", jspFile, 501);
125
                   , "tagWithMetadata", "test", jspFile, 501, null);
126
        Element element = CommandUtil.excuteInsertion(creationData.getTagEntry()
126
        final Element element = CommandUtil.executeInsertion(
127
                creationData.getTagCreationProvider()
127
                                    , creationData.getModel()
128
                                    , creationData.getModel()
128
                                    , creationData.getDomPosition()
129
                                    , creationData.getDomPosition()
129
                                    , creationData.getDropCustomizationData());
130
                                    , creationData.getDropCustomizationData());
Lines 155-180 Link Here
155
     */
156
     */
156
    public void testBug197042() throws Exception
157
    public void testBug197042() throws Exception
157
    {
158
    {
158
        IFile jspFile = (IFile) _webProjectTestEnv.loadResourceInWebRoot(
159
        final IFile jspFile = (IFile) _webProjectTestEnv.loadResourceInWebRoot(
159
                PageDesignerTestsPlugin.getDefault().getBundle()
160
                PageDesignerTestsPlugin.getDefault().getBundle()
160
                ,"/testdata/tagcreator/tagCreator.jspx.data"
161
                ,"/testdata/tagcreator/tagCreator.jspx.data"
161
                ,"/testTagCreationMetadata.jsp");
162
                ,"/testTagCreationMetadata.jsp");
162
163
163
        final String uri = 
164
        final String uri =
164
            IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON.getUri();
165
            IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON.getUri();
165
        final String tagName = 
166
        final String tagName =
166
            IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON.getTagName();
167
            IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON.getTagName();
167
        CreationData creationData =
168
        final CreationData creationData =
168
            getCreationData(uri,tagName,"h", jspFile, 495);
169
            getCreationData(uri,tagName,"h", jspFile, 495, null);
169
170
170
        ITagCreator tagCreator = TagCreationFactory.getInstance()
171
        final ITagCreator tagCreator = TagCreationFactory.getInstance()
171
            .createTagCreator(creationData.getTagId());
172
            .createTagCreator(creationData.getTagId());
172
173
173
        Element element = tagCreator.createTag(creationData);
174
        final Element element = tagCreator.createTag(creationData);
174
175
175
        System.out.println(element.toString());
176
        System.out.println(element.toString());
176
177
177
        ByteArrayOutputStream resultStream = new ByteArrayOutputStream();
178
        final ByteArrayOutputStream resultStream = new ByteArrayOutputStream();
178
        getDocumentContext(0, jspFile).getModel().save(resultStream);
179
        getDocumentContext(0, jspFile).getModel().save(resultStream);
179
180
180
        final IPath expectedPath = JSFTestUtil.getAbsolutePath(
181
        final IPath expectedPath = JSFTestUtil.getAbsolutePath(
Lines 188-201 Link Here
188
189
189
    public void testDropCustomizerThatCancels() throws Exception
190
    public void testDropCustomizerThatCancels() throws Exception
190
    {
191
    {
191
        IFile jspFile = (IFile) _webProjectTestEnv.loadResourceInWebRoot(
192
        final IFile jspFile = (IFile) _webProjectTestEnv.loadResourceInWebRoot(
192
                PageDesignerTestsPlugin.getDefault().getBundle()
193
                PageDesignerTestsPlugin.getDefault().getBundle()
193
                ,"/testdata/tagcreator/tagCreator.jsp.data"
194
                ,"/testdata/tagcreator/tagCreator.jsp.data"
194
                ,"/testCustomizerCancel.jsp");
195
                ,"/testCustomizerCancel.jsp");
195
196
196
        TestCreationFactory.setTestParametersForDropCustomer(Status.CANCEL_STATUS, null);
197
        TestCreationFactory.setTestParametersForDropCustomer(Status.CANCEL_STATUS, null);
197
198
198
        MockItemCreationTool tool = 
199
        final MockItemCreationTool tool =
199
            createMockItemCreationTool(jspFile, 358, TestCreationFactory.TAG_WITH_REQUIRED_ATTR, IStatus.CANCEL);
200
            createMockItemCreationTool(jspFile, 358, TestCreationFactory.TAG_WITH_REQUIRED_ATTR, IStatus.CANCEL);
200
201
201
        tool.customizeDropAndMaybeExecute(0);
202
        tool.customizeDropAndMaybeExecute(0);
Lines 206-222 Link Here
206
    @SuppressWarnings("unchecked")
207
    @SuppressWarnings("unchecked")
207
    public void testDropCustomizationDataAcquistion() throws Exception
208
    public void testDropCustomizationDataAcquistion() throws Exception
208
    {
209
    {
209
        IFile jspFile = (IFile) _webProjectTestEnv.loadResourceInWebRoot(
210
        final IFile jspFile = (IFile) _webProjectTestEnv.loadResourceInWebRoot(
210
                PageDesignerTestsPlugin.getDefault().getBundle()
211
                PageDesignerTestsPlugin.getDefault().getBundle()
211
                ,"/testdata/tagcreator/tagCreator.jsp.data"
212
                ,"/testdata/tagcreator/tagCreator.jsp.data"
212
                ,"/testCustomizerCancel.jsp");
213
                ,"/testCustomizerCancel.jsp");
213
214
214
        IAdaptable adaptable = new IAdaptable()
215
        final IAdaptable adaptable = new IAdaptable()
215
        {
216
        {
216
            public Object getAdapter(Class adapter) {
217
            public Object getAdapter(final Class adapter) {
217
                if (Map.class == adapter)
218
                if (Map.class == adapter)
218
                {
219
                {
219
                    HashMap<String, String> map = new HashMap<String, String>();
220
                    final HashMap<String, String> map = new HashMap<String, String>();
220
                    map.put("color", "red");
221
                    map.put("color", "red");
221
                    return map;
222
                    return map;
222
                }
223
                }
Lines 226-252 Link Here
226
227
227
        TestCreationFactory.setTestParametersForDropCustomer(Status.OK_STATUS, adaptable);
228
        TestCreationFactory.setTestParametersForDropCustomer(Status.OK_STATUS, adaptable);
228
229
229
        MockItemCreationTool tool = 
230
        final MockItemCreationTool tool =
230
            createMockItemCreationTool(jspFile, 358, TestCreationFactory.TAG_WITH_REQUIRED_ATTR, IStatus.CANCEL);
231
            createMockItemCreationTool(jspFile, 358, TestCreationFactory.TAG_WITH_REQUIRED_ATTR, IStatus.CANCEL);
231
232
232
        tool.customizeDropAndMaybeExecute(0);
233
        tool.customizeDropAndMaybeExecute(0);
233
        Object[] commands = tool.getDomain().getCommandStack().getCommands();
234
        final Object[] commands = tool.getDomain().getCommandStack().getCommands();
234
        assertEquals(1, commands.length);
235
        assertEquals(1, commands.length);
235
        assertTrue(commands[0] instanceof MockCreateItemCommand);
236
        assertTrue(commands[0] instanceof MockCreateItemCommand);
236
        
237
237
        IAdaptable value = ((MockCreateItemCommand)commands[0]).getCustomizationDataTesting();
238
        final IAdaptable value = ((MockCreateItemCommand)commands[0]).getCustomizationDataTesting();
238
        assertEquals(adaptable, value);
239
        assertEquals(adaptable, value);
239
        Map map = (Map) value.getAdapter(Map.class);
240
        final Map map = (Map) value.getAdapter(Map.class);
240
        assertNotNull(map);
241
        assertNotNull(map);
241
        assertEquals("red", map.get("color"));
242
        assertEquals("red", map.get("color"));
242
    }
243
    }
243
    
244
244
    private void assertExpectedResult(IFile file, String outExt) throws Exception
245
    private void assertExpectedResult(final IFile file, final String outExt) throws Exception
245
    {
246
    {
246
        final ByteArrayOutputStream resultStream = new ByteArrayOutputStream();
247
        final ByteArrayOutputStream resultStream = new ByteArrayOutputStream();
247
        getDocumentContext(0, file).getModel().save(resultStream);
248
        getDocumentContext(0, file).getModel().save(resultStream);
248
249
249
        final String expected = 
250
        final String expected =
250
            getExpectedResult("/testdata/tagcreator/tagCreator."+outExt+".data").trim();
251
            getExpectedResult("/testdata/tagcreator/tagCreator."+outExt+".data").trim();
251
        final String result = resultStream.toString("ISO-8859-1").trim();
252
        final String result = resultStream.toString("ISO-8859-1").trim();
252
253
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/TestDefaultTagCreatorHTML.java (-3 / +2 lines)
Lines 11-17 Link Here
11
package org.eclipse.jst.pagedesigner.tests.tagcreator;
11
package org.eclipse.jst.pagedesigner.tests.tagcreator;
12
12
13
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
13
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
14
import org.eclipse.jst.pagedesigner.tests.tagcreator.base.BaseTagCreatorTestCase;
15
import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMDocType;
14
import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMDocType;
16
15
17
/**
16
/**
Lines 40-46 Link Here
40
39
41
    public void testCreateButton() throws Exception
40
    public void testCreateButton() throws Exception
42
    {
41
    {
43
        doCreateTest(TagIdentifierFactory.createJSPTagWrapper(CMDocType.HTML_DOC_TYPE, "INPUT.BUTTON"), "html", "html", 358,false);
42
        doCreateTest(TagIdentifierFactory.createJSPTagWrapper(CMDocType.HTML_DOC_TYPE, "INPUT.BUTTON"), "html", "html", 358,false, null);
44
        doCreateTest(TagIdentifierFactory.createJSPTagWrapper(CMDocType.HTML_DOC_TYPE, "INPUT.BUTTON"), "xhtml", "xhtml", 350,false);
43
        doCreateTest(TagIdentifierFactory.createJSPTagWrapper(CMDocType.HTML_DOC_TYPE, "INPUT.BUTTON"), "xhtml", "xhtml", 350,false, null);
45
    }
44
    }
46
}
45
}
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/BaseUserCustomizedTagCreatorTestCase.java (-16 / +24 lines)
Lines 1-6 Link Here
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
2
2
3
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
3
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
4
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
5
import org.eclipse.jst.pagedesigner.editors.palette.TagToolCreationAdapter;
4
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
6
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
5
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteItemManager;
7
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteItemManager;
6
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer;
8
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer;
Lines 63-82 Link Here
63
		return new UserCustomizedTagCreator();
65
		return new UserCustomizedTagCreator();
64
	}
66
	}
65
67
66
	
68
67
	/**
69
    /**
68
	 * Adds a tag to a section in the tool palette.
70
     * Adds a tag to a section in the tool palette.
69
	 * 
71
     * 
70
	 * @param tagId
72
     * @param tagId
71
	 *            TagIdentifier of tag to add
73
     *            TagIdentifier of tag to add
72
	 * @param category
74
     * @param category
73
	 *            Category in the tool palette
75
     *            Category in the tool palette
74
	 * 
76
     * 
75
	 */
77
     */
76
	private final void addTagToPaletteCategory(final TagIdentifier tagId, final TaglibPaletteDrawer category)
78
    @SuppressWarnings("unchecked")
77
	{
79
    private final void addTagToPaletteCategory(final TagIdentifier tagId,
78
		final TagToolPaletteEntry paletteItem = new TagToolPaletteEntry(tagId.getTagName(), TAG_LABEL, TAG_DESCRIPTION_SHORT, null, null);
80
            final TaglibPaletteDrawer category)
79
		category.getChildren().add(paletteItem);
81
    {
80
		paletteItem.setParent(category);
82
        final ITagDropSourceData tagDropSourceData = new TagToolCreationAdapter(
81
	}
83
                tagId.getUri(), tagId.getTagName(),
84
                category.getDefaultPrefix(), tagId.getTagName());
85
        final TagToolPaletteEntry paletteItem = new TagToolPaletteEntry(
86
                tagDropSourceData, TAG_LABEL, TAG_DESCRIPTION_SHORT, null, null);
87
        category.getChildren().add(paletteItem);
88
        paletteItem.setParent(category);
89
    }
82
}
90
}
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/TestDefaultTagCreatorForJSFHTML.java (-25 / +25 lines)
Lines 33-151 Link Here
33
33
34
    public void testCreateButton() throws Exception
34
    public void testCreateButton() throws Exception
35
    {
35
    {
36
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358,false);
36
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358,false, null);
37
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495,false);
37
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495,false, null);
38
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350,false);
38
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350,false, null);
39
    }
39
    }
40
40
41
    public void testCreateCommandLink() throws Exception
41
    public void testCreateCommandLink() throws Exception
42
    {
42
    {
43
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDLINK, "jsp", "jsp", 358,false);
43
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDLINK, "jsp", "jsp", 358,false, null);
44
    }
44
    }
45
45
46
    public void testCreatePanelGrid() throws Exception
46
    public void testCreatePanelGrid() throws Exception
47
    {
47
    {
48
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_PANEL_GRID, "jsp", "jsp", 358,false);
48
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_PANEL_GRID, "jsp", "jsp", 358,false, null);
49
    }
49
    }
50
    
50
    
51
    public void testCreateDataTable() throws Exception
51
    public void testCreateDataTable() throws Exception
52
    {
52
    {
53
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_DATA_TABLE, "jsp", "jsp", 358,false);
53
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_DATA_TABLE, "jsp", "jsp", 358,false, null);
54
    }
54
    }
55
    
55
    
56
    public void testCreateForm() throws Exception
56
    public void testCreateForm() throws Exception
57
    {
57
    {
58
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_FORM, "jsp", "jsp", 358,false);
58
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_FORM, "jsp", "jsp", 358,false, null);
59
    }
59
    }
60
    
60
    
61
    public void testCreateGraphicImage() throws  Exception
61
    public void testCreateGraphicImage() throws  Exception
62
    {
62
    {
63
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_GRAPHICIMAGE, "jsp", "jsp", 358,false);
63
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_GRAPHICIMAGE, "jsp", "jsp", 358,false, null);
64
    }
64
    }
65
    
65
    
66
    public void testCreateInputHidden() throws Exception
66
    public void testCreateInputHidden() throws Exception
67
    {
67
    {
68
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_INPUTHIDDEN, "jsp", "jsp", 358,false);
68
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_INPUTHIDDEN, "jsp", "jsp", 358,false, null);
69
    }
69
    }
70
    
70
    
71
    public void testCreateMessage() throws Exception
71
    public void testCreateMessage() throws Exception
72
    {
72
    {
73
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_MESSAGE, "jsp", "jsp", 358,false);
73
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_MESSAGE, "jsp", "jsp", 358,false, null);
74
    }
74
    }
75
    
75
    
76
    public void testCreateMessages() throws Exception
76
    public void testCreateMessages() throws Exception
77
    {
77
    {
78
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_MESSAGES, "jsp", "jsp", 358,false);
78
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_MESSAGES, "jsp", "jsp", 358,false, null);
79
    }
79
    }
80
    
80
    
81
    public void testCreateOutputFormat() throws Exception
81
    public void testCreateOutputFormat() throws Exception
82
    {
82
    {
83
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_OUTPUTFORMAT, "jsp", "jsp", 358,true);
83
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_OUTPUTFORMAT, "jsp", "jsp", 358,true, null);
84
    }
84
    }
85
    
85
    
86
    public void testCreateOutputLabel() throws Exception
86
    public void testCreateOutputLabel() throws Exception
87
    {
87
    {
88
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_OUTPUTLABEL, "jsp", "jsp", 358,false);
88
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_OUTPUTLABEL, "jsp", "jsp", 358,false, null);
89
    }
89
    }
90
    
90
    
91
    public void testCreateOutputText() throws Exception
91
    public void testCreateOutputText() throws Exception
92
    {
92
    {
93
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_OUTPUTTEXT, "jsp", "jsp", 358,false);
93
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_OUTPUTTEXT, "jsp", "jsp", 358,false, null);
94
    }
94
    }
95
95
96
    public void testCreatePanelGroup() throws Exception
96
    public void testCreatePanelGroup() throws Exception
97
    {
97
    {
98
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_PANEL_GROUP, "jsp", "jsp", 358,false);
98
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_PANEL_GROUP, "jsp", "jsp", 358,false, null);
99
    }
99
    }
100
100
101
    public void testCreateInputSecret() throws Exception
101
    public void testCreateInputSecret() throws Exception
102
    {
102
    {
103
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_INPUTSECRET, "jsp", "jsp", 358,false);
103
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_INPUTSECRET, "jsp", "jsp", 358,false, null);
104
    }
104
    }
105
    
105
    
106
    public void testCreateSelectBooleanCheckbox() throws Exception
106
    public void testCreateSelectBooleanCheckbox() throws Exception
107
    {
107
    {
108
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTBOOLEANCHECKBOX, "jsp", "jsp", 358,false);
108
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTBOOLEANCHECKBOX, "jsp", "jsp", 358,false, null);
109
    }
109
    }
110
110
111
    public void testCreateSelectManyCheckbox() throws Exception
111
    public void testCreateSelectManyCheckbox() throws Exception
112
    {
112
    {
113
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTMANYCHECKBOX, "jsp", "jsp", 358,false);
113
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTMANYCHECKBOX, "jsp", "jsp", 358,false, null);
114
    }
114
    }
115
    
115
    
116
    public void testCreateSelectManyListbox() throws Exception
116
    public void testCreateSelectManyListbox() throws Exception
117
    {
117
    {
118
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTMANYLISTBOX, "jsp", "jsp", 358,false);
118
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTMANYLISTBOX, "jsp", "jsp", 358,false, null);
119
    }
119
    }
120
120
121
    public void testCreateSelectManyMenu() throws Exception
121
    public void testCreateSelectManyMenu() throws Exception
122
    {
122
    {
123
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTMANYMENU, "jsp", "jsp", 358,false);
123
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTMANYMENU, "jsp", "jsp", 358,false, null);
124
    }
124
    }
125
125
126
    public void testCreateSelectOneListbox() throws Exception
126
    public void testCreateSelectOneListbox() throws Exception
127
    {
127
    {
128
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTONELISTBOX, "jsp", "jsp", 358,false);
128
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTONELISTBOX, "jsp", "jsp", 358,false, null);
129
    }
129
    }
130
130
131
    public void testCreateSelectOneMenu() throws Exception
131
    public void testCreateSelectOneMenu() throws Exception
132
    {
132
    {
133
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTONEMENU, "jsp", "jsp", 358,false);
133
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTONEMENU, "jsp", "jsp", 358,false, null);
134
    }
134
    }
135
135
136
    public void testCreateSelectOneRadio() throws Exception
136
    public void testCreateSelectOneRadio() throws Exception
137
    {
137
    {
138
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTONERADIO, "jsp", "jsp", 358,false);
138
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTONERADIO, "jsp", "jsp", 358,false, null);
139
    }
139
    }
140
140
141
    public void testCreateInputText() throws Exception
141
    public void testCreateInputText() throws Exception
142
    {
142
    {
143
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_INPUTTEXT, "jsp", "jsp", 358,false);
143
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_INPUTTEXT, "jsp", "jsp", 358,false, null);
144
    }
144
    }
145
145
146
    public void testCreateInputTextArea() throws Exception
146
    public void testCreateInputTextArea() throws Exception
147
    {
147
    {
148
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_INPUTTEXTAREA, "jsp", "jsp", 358,false);
148
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_INPUTTEXTAREA, "jsp", "jsp", 358,false, null);
149
    }
149
    }
150
150
151
}
151
}
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/TestUserCustomizedTagCreatorForJSFHTML_AttributeCustomization.java (-7 / +6 lines)
Lines 1-8 Link Here
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
2
2
3
import org.eclipse.core.runtime.IAdaptable;
4
import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
3
import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
5
import org.eclipse.jst.pagedesigner.itemcreation.customizer.CustomizationDataImpl;
4
import org.eclipse.jst.pagedesigner.itemcreation.customizer.CustomizationDataImpl;
5
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData;
6
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IWritableCustomizationData;
6
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IWritableCustomizationData;
7
7
8
/**
8
/**
Lines 23-42 Link Here
23
	
23
	
24
	public void testAttributeInsertion() throws Exception
24
	public void testAttributeInsertion() throws Exception
25
    {
25
    {
26
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358, false);
26
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358, false, getCustomizationData());
27
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495, false);
27
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495, false, getCustomizationData());
28
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350, false);
28
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350, false, getCustomizationData());
29
    }
29
    }
30
	
30
	
31
31
32
    @Override
32
    protected ICustomizationData getCustomizationData()
33
    protected IAdaptable getCustomizationData()
34
    {
33
    {
35
    	// Setup tag
34
    	// Setup tag
36
    	IWritableCustomizationData data = new CustomizationDataImpl(getTagIdentifier());
35
    	IWritableCustomizationData data = new CustomizationDataImpl(getTagIdentifier());
37
    	data.addAttribute("attr1", "value1");
36
    	data.addAttribute("attr1", "value1");
38
37
39
    	return (IAdaptable) data;
38
    	return data;
40
    }
39
    }
41
40
42
    
41
    
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/TestUserCustomizedTagCreatorForJSFHTML_ChildCustomization.java (-6 / +5 lines)
Lines 1-8 Link Here
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
1
package org.eclipse.jst.pagedesigner.tests.tagcreator;
2
2
3
import org.eclipse.core.runtime.IAdaptable;
4
import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
3
import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
5
import org.eclipse.jst.pagedesigner.itemcreation.customizer.CustomizationDataImpl;
4
import org.eclipse.jst.pagedesigner.itemcreation.customizer.CustomizationDataImpl;
5
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData;
6
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IWritableCustomizationData;
6
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IWritableCustomizationData;
7
import org.eclipse.jst.pagedesigner.tests.tagcreatorPlugin.UserCustomizedElementEditFactory;
7
import org.eclipse.jst.pagedesigner.tests.tagcreatorPlugin.UserCustomizedElementEditFactory;
8
8
Lines 24-37 Link Here
24
	
24
	
25
	public void testChildTagInsertion() throws Exception
25
	public void testChildTagInsertion() throws Exception
26
    {
26
    {
27
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358, false);
27
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jsp", "jsp", 358, false, getCustomizationData());
28
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495, false);
28
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "jspx", "jspx", 495, false, getCustomizationData());
29
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350, false);
29
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_COMMANDBUTTON, "xhtml", "xhtml", 350, false, getCustomizationData());
30
    }
30
    }
31
	
31
	
32
32
33
    @Override
33
    protected ICustomizationData getCustomizationData()
34
    protected IAdaptable getCustomizationData()
35
    {
34
    {
36
    	// Setup tag
35
    	// Setup tag
37
    	IWritableCustomizationData tagDropped = new CustomizationDataImpl(getTagIdentifier());
36
    	IWritableCustomizationData tagDropped = new CustomizationDataImpl(getTagIdentifier());
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/TestDefaultTagCreatorForJSFCore.java (-18 / +18 lines)
Lines 33-53 Link Here
33
33
34
    public void testCreateActionListener() throws Exception
34
    public void testCreateActionListener() throws Exception
35
    {
35
    {
36
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_ACTIONLISTENER, "jsp", "jsp", 358, false);
36
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_ACTIONLISTENER, "jsp", "jsp", 358, false, null);
37
    }
37
    }
38
    
38
    
39
    public void testCreateAttribute() throws Exception
39
    public void testCreateAttribute() throws Exception
40
    {
40
    {
41
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_ATTRIBUTE, "jsp", "jsp", 358, false);
41
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_ATTRIBUTE, "jsp", "jsp", 358, false, null);
42
    }
42
    }
43
43
44
    public void testCreateConvertDateTime() throws Exception
44
    public void testCreateConvertDateTime() throws Exception
45
    {
45
    {
46
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_CONVERTDATETIME, "jsp", "jsp", 358,false);
46
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_CONVERTDATETIME, "jsp", "jsp", 358,false, null);
47
    }
47
    }
48
    public void testCreateConvertNumber() throws Exception
48
    public void testCreateConvertNumber() throws Exception
49
    {
49
    {
50
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_CONVERTNUMBER, "jsp", "jsp", 358,false);
50
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_CONVERTNUMBER, "jsp", "jsp", 358,false, null);
51
    }
51
    }
52
52
53
    /**
53
    /**
Lines 55-61 Link Here
55
     */
55
     */
56
    public void testCreateConverter() throws Exception
56
    public void testCreateConverter() throws Exception
57
    {
57
    {
58
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_CONVERTER, "jsp", "jsp", 358,false);
58
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_CONVERTER, "jsp", "jsp", 358,false, null);
59
    }
59
    }
60
60
61
    /**
61
    /**
Lines 63-69 Link Here
63
     */
63
     */
64
    public void testCreateFacet() throws Exception
64
    public void testCreateFacet() throws Exception
65
    {
65
    {
66
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_FACET, "jsp", "jsp", 358,false);
66
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_FACET, "jsp", "jsp", 358,false, null);
67
    }
67
    }
68
68
69
    /**
69
    /**
Lines 71-77 Link Here
71
     */
71
     */
72
    public void testCreateLoadBundle() throws Exception
72
    public void testCreateLoadBundle() throws Exception
73
    {
73
    {
74
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_LOADBUNDLE, "jsp", "jsp", 358,false);
74
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_LOADBUNDLE, "jsp", "jsp", 358,false, null);
75
    }
75
    }
76
76
77
    /**
77
    /**
Lines 79-85 Link Here
79
     */
79
     */
80
    public void testCreateParam() throws Exception
80
    public void testCreateParam() throws Exception
81
    {
81
    {
82
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_PARAM, "jsp", "jsp", 358,true);
82
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_PARAM, "jsp", "jsp", 358,true, null);
83
    }
83
    }
84
84
85
    /**
85
    /**
Lines 87-93 Link Here
87
     */
87
     */
88
    public void testCreateSelectItem() throws Exception
88
    public void testCreateSelectItem() throws Exception
89
    {
89
    {
90
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTITEM, "jsp", "jsp", 358,false);
90
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTITEM, "jsp", "jsp", 358,false, null);
91
    }
91
    }
92
92
93
    /**
93
    /**
Lines 95-101 Link Here
95
     */
95
     */
96
    public void testCreateSelectItems() throws Exception
96
    public void testCreateSelectItems() throws Exception
97
    {
97
    {
98
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTITEMS, "jsp", "jsp", 358,false);
98
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SELECTITEMS, "jsp", "jsp", 358,false, null);
99
    }
99
    }
100
100
101
    /**
101
    /**
Lines 103-109 Link Here
103
     */
103
     */
104
    public void testCreateSubview() throws Exception
104
    public void testCreateSubview() throws Exception
105
    {
105
    {
106
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SUBVIEW, "jsp", "jsp", 358,false);
106
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_SUBVIEW, "jsp", "jsp", 358,false, null);
107
    }
107
    }
108
108
109
    /**
109
    /**
Lines 111-117 Link Here
111
     */
111
     */
112
    public void testCreateValidateDoubleRange() throws Exception
112
    public void testCreateValidateDoubleRange() throws Exception
113
    {
113
    {
114
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALIDATEDOUBLERANGE, "jsp", "jsp", 358,true);
114
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALIDATEDOUBLERANGE, "jsp", "jsp", 358,true, null);
115
    }
115
    }
116
116
117
    /**
117
    /**
Lines 119-125 Link Here
119
     */
119
     */
120
    public void testCreateValidateLength() throws Exception
120
    public void testCreateValidateLength() throws Exception
121
    {
121
    {
122
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALIDATELENGTH, "jsp", "jsp", 358,true);
122
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALIDATELENGTH, "jsp", "jsp", 358,true, null);
123
    }
123
    }
124
    
124
    
125
    /**
125
    /**
Lines 127-133 Link Here
127
     */
127
     */
128
    public void testCreateValidateLongRange() throws Exception
128
    public void testCreateValidateLongRange() throws Exception
129
    {
129
    {
130
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALIDATELONGRANGE, "jsp", "jsp", 358,true);
130
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALIDATELONGRANGE, "jsp", "jsp", 358,true, null);
131
    }
131
    }
132
132
133
    /**
133
    /**
Lines 135-141 Link Here
135
     */
135
     */
136
    public void testCreateValidator() throws Exception
136
    public void testCreateValidator() throws Exception
137
    {
137
    {
138
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALIDATOR, "jsp", "jsp", 358,false);
138
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALIDATOR, "jsp", "jsp", 358,false, null);
139
    }
139
    }
140
    
140
    
141
    /**
141
    /**
Lines 143-149 Link Here
143
     */
143
     */
144
    public void testCreateValueChangeListener() throws Exception
144
    public void testCreateValueChangeListener() throws Exception
145
    {
145
    {
146
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALUECHANGELISTENER, "jsp", "jsp", 358,false);
146
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VALUECHANGELISTENER, "jsp", "jsp", 358,false, null);
147
    }
147
    }
148
148
149
    /**
149
    /**
Lines 151-157 Link Here
151
     */
151
     */
152
    public void testCreateVerbatim() throws Exception
152
    public void testCreateVerbatim() throws Exception
153
    {
153
    {
154
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VERBATIM, "jsp", "jsp", 358,false);
154
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VERBATIM, "jsp", "jsp", 358,false, null);
155
    }
155
    }
156
156
157
    /**
157
    /**
Lines 159-165 Link Here
159
     */
159
     */
160
    public void testCreateView() throws Exception
160
    public void testCreateView() throws Exception
161
    {
161
    {
162
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VIEW, "jsp", "jsp", 358,false);
162
        doCreateTest(IJSFConstants.TAG_IDENTIFIER_VIEW, "jsp", "jsp", 358,false, null);
163
    }
163
    }
164
164
165
}
165
}
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/base/BaseTestClass.java (-38 / +10 lines)
Lines 18-24 Link Here
18
18
19
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IFolder;
20
import org.eclipse.core.resources.IFolder;
21
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.gef.EditDomain;
23
import org.eclipse.gef.EditDomain;
Lines 41-46 Link Here
41
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteItemManager;
40
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteItemManager;
42
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer;
41
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer;
43
import org.eclipse.jst.pagedesigner.itemcreation.CreationData;
42
import org.eclipse.jst.pagedesigner.itemcreation.CreationData;
43
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData;
44
import org.eclipse.jst.pagedesigner.tests.PageDesignerTestsPlugin;
44
import org.eclipse.jst.pagedesigner.tests.PageDesignerTestsPlugin;
45
import org.eclipse.wst.html.core.internal.document.DOMStyleModelImpl;
45
import org.eclipse.wst.html.core.internal.document.DOMStyleModelImpl;
46
import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl;
46
import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl;
Lines 49-56 Link Here
49
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
49
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
50
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
50
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
51
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
51
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
52
import org.w3c.dom.Element;
53
import org.w3c.dom.NamedNodeMap;
54
import org.w3c.dom.Node;
52
import org.w3c.dom.Node;
55
53
56
public class BaseTestClass extends TestCase
54
public class BaseTestClass extends TestCase
Lines 90-105 Link Here
90
                .getTestProject());
88
                .getTestProject());
91
    }
89
    }
92
90
93
    
94
    protected IAdaptable getCustomizationData()
95
    {
96
    	return null;
97
    }
98
    
99
    
100
    protected CreationData getCreationData(final String uri,
91
    protected CreationData getCreationData(final String uri,
101
            final String tagName, final String defaultPrefix, final IFile file,
92
            final String tagName, final String defaultPrefix, final IFile file,
102
            final int offset) throws Exception
93
            final int offset, final ICustomizationData customizationData) throws Exception
103
    {
94
    {
104
        final ITaglibDomainMetaDataModelContext modelContext = TaglibDomainMetaDataQueryHelper
95
        final ITaglibDomainMetaDataModelContext modelContext = TaglibDomainMetaDataQueryHelper
105
                .createMetaDataModelContext(
96
                .createMetaDataModelContext(
Lines 116-127 Link Here
116
        assertEquals(Node.TEXT_NODE, node.getNodeType());
107
        assertEquals(Node.TEXT_NODE, node.getNodeType());
117
108
118
        final DOMPosition domPosition = new DOMPosition(node, 0);
109
        final DOMPosition domPosition = new DOMPosition(node, 0);
119
110
        final IDOMModel model =(IDOMModel) context.getModel();
120
          return new CreationData(entry, (IDOMModel) context.getModel(),
111
        return new CreationData(entry.getTemplate(), model,
121
              domPosition, modelContext, getCustomizationData());
112
                domPosition, modelContext, customizationData);
122
    }
113
    }
123
114
124
    protected TagToolPaletteEntry createPaletteEntry(final String uri,
115
    private TagToolPaletteEntry createPaletteEntry(final String uri,
125
            final String tagName)
116
            final String tagName)
126
    {
117
    {
127
        final TaglibPaletteDrawer drawer = _manager
118
        final TaglibPaletteDrawer drawer = _manager
Lines 140-146 Link Here
140
        return entry;
131
        return entry;
141
    }
132
    }
142
133
143
    protected TagToolPaletteEntry createNonNullPaletteEntry(final String uri,
134
    private TagToolPaletteEntry createNonNullPaletteEntry(final String uri,
144
            final String tagName)
135
            final String tagName)
145
    {
136
    {
146
        final TagToolPaletteEntry entry = createPaletteEntry(uri, tagName);
137
        final TagToolPaletteEntry entry = createPaletteEntry(uri, tagName);
Lines 284-293 Link Here
284
            final int offset, final TagIdentifier tagId,
275
            final int offset, final TagIdentifier tagId,
285
            final int expectedResult) throws Exception
276
            final int expectedResult) throws Exception
286
    {
277
    {
278
287
        final TagToolPaletteEntry toolEntry = createNonNullPaletteEntry(tagId
279
        final TagToolPaletteEntry toolEntry = createNonNullPaletteEntry(tagId
288
                .getUri(), tagId.getTagName());
280
                .getUri(), tagId.getTagName());
289
281
        final MockItemCreationTool tool = new MockItemCreationTool(toolEntry.getTemplate());
290
        final MockItemCreationTool tool = new MockItemCreationTool(toolEntry);
291
282
292
        final ContextWrapper wrapper = getDocumentContext(offset, file);
283
        final ContextWrapper wrapper = getDocumentContext(offset, file);
293
        final IDOMContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
284
        final IDOMContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
Lines 297-303 Link Here
297
        final DOMPosition domPosition = new DOMPosition(resolver.getNode(), 0);
288
        final DOMPosition domPosition = new DOMPosition(resolver.getNode(), 0);
298
289
299
        final MockCreateItemCommand command = new MockCreateItemCommand(
290
        final MockCreateItemCommand command = new MockCreateItemCommand(
300
                "Test Command", (IDOMModel) model, domPosition, toolEntry);
291
                "Test Command", (IDOMModel) model, domPosition, toolEntry.getTemplate());
301
292
302
        tool.setEditDomain(new EditDomain());
293
        tool.setEditDomain(new EditDomain());
303
        tool.setCurrentCommand(command);
294
        tool.setCurrentCommand(command);
Lines 323-347 Link Here
323
            (element).setEmptyTag(true);
314
            (element).setEmptyTag(true);
324
            (element).removeChildNodes();
315
            (element).removeChildNodes();
325
            final Node copy = (element).cloneNode(false);
316
            final Node copy = (element).cloneNode(false);
326
327
            /*
328
             * ElementImpl.cloneNode(...) seems to have started creating
329
             * attributes that display differently than the cloned Node's
330
             * (attr='' rather than attr=""), breaking textual comparisons.
331
             * By overwriting the existing attributes after cloning, we get the
332
             * expected form (double quotes instead of single quotes).
333
             * 
334
             *  - Ian Trimble, 20090305
335
             */
336
            if (element.hasAttributes() && copy instanceof Element) {
337
	            NamedNodeMap attrMap = element.getAttributes();
338
                for (int i = 0; i < attrMap.getLength(); i++) {
339
                    Node attrNode = attrMap.item(i);
340
                    ((Element)copy).setAttribute(
341
                            attrNode.getNodeName(), attrNode.getNodeValue());
342
                }
343
            }
344
345
            element.getParentNode().replaceChild(copy, element);
317
            element.getParentNode().replaceChild(copy, element);
346
        }
318
        }
347
    }
319
    }
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/base/MockCreateItemCommand.java (-3 / +3 lines)
Lines 16-22 Link Here
16
import org.eclipse.core.runtime.IAdaptable;
16
import org.eclipse.core.runtime.IAdaptable;
17
import org.eclipse.jst.pagedesigner.commands.CreateItemCommand;
17
import org.eclipse.jst.pagedesigner.commands.CreateItemCommand;
18
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
18
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
19
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
19
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
20
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
20
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
21
import org.w3c.dom.Element;
21
import org.w3c.dom.Element;
22
import org.w3c.dom.Node;
22
import org.w3c.dom.Node;
Lines 24-31 Link Here
24
public class MockCreateItemCommand extends CreateItemCommand
24
public class MockCreateItemCommand extends CreateItemCommand
25
{
25
{
26
    public MockCreateItemCommand(String label, IDOMModel model,
26
    public MockCreateItemCommand(String label, IDOMModel model,
27
            IDOMPosition position, TagToolPaletteEntry tagItem) {
27
            IDOMPosition position, ITagDropSourceData tagDropSourceData) {
28
        super(label, model, position, tagItem);
28
        super(label, model, position, tagDropSourceData);
29
    }
29
    }
30
30
31
    @Override
31
    @Override
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/base/BaseTagCreatorTestCase.java (-9 / +11 lines)
Lines 13-18 Link Here
13
import org.eclipse.core.resources.IFile;
13
import org.eclipse.core.resources.IFile;
14
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
14
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
15
import org.eclipse.jst.pagedesigner.itemcreation.ITagCreator;
15
import org.eclipse.jst.pagedesigner.itemcreation.ITagCreator;
16
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData;
16
import org.eclipse.jst.pagedesigner.tests.PageDesignerTestsPlugin;
17
import org.eclipse.jst.pagedesigner.tests.PageDesignerTestsPlugin;
17
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
18
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
18
import org.w3c.dom.Element;
19
import org.w3c.dom.Element;
Lines 50-65 Link Here
50
51
51
	/**
52
	/**
52
     * @param tagId
53
     * @param tagId
53
     * @param inExt
54
	 * @param inExt
54
     * @param outExt
55
	 * @param outExt
55
     * @param offset
56
	 * @param offset
56
     * @param forceResultTagEmpty this is a workaround flag due to the fact that some
57
	 * @param forceResultTagEmpty this is a workaround flag due to the fact that some
57
     * TLD body definitions differ between RI and MyFaces, causing some tags to be
58
     * TLD body definitions differ between RI and MyFaces, causing some tags to be
58
     * generated as <tag></tag> in RI and <tag/> in MyFaces.  NEVER SET TO TRUE ON A TAG ID
59
     * generated as <tag></tag> in RI and <tag/> in MyFaces.  NEVER SET TO TRUE ON A TAG ID
59
     * whose instances may have child elements.
60
     * whose instances may have child elements.
61
	 * @param customizationData TODO
60
     * @throws Exception
62
     * @throws Exception
61
     */
63
     */
62
    protected final void doCreateTest(final TagIdentifier tagId, final String inExt, final String outExt, int offset, boolean forceResultTagEmpty) throws Exception 
64
    protected final void doCreateTest(final TagIdentifier tagId, final String inExt, final String outExt, int offset, boolean forceResultTagEmpty, ICustomizationData customizationData) throws Exception 
63
    {
65
    {
64
        final String uri = tagId.getUri();
66
        final String uri = tagId.getUri();
65
        final String tagName = tagId.getTagName();
67
        final String tagName = tagId.getTagName();
Lines 69-80 Link Here
69
                "/testdata/tagcreator/tagCreator."+inExt+".data", "/tagCreator_"+tagName+"."+inExt);
71
                "/testdata/tagcreator/tagCreator."+inExt+".data", "/tagCreator_"+tagName+"."+inExt);
70
72
71
        setTagIdentifier(tagId);
73
        setTagIdentifier(tagId);
72
        
74
73
        ITagCreator tagCreator = getTagCreator(getTagIdentifier());
75
        ITagCreator tagCreator = getTagCreator(getTagIdentifier());
74
        
76
75
        Element element = tagCreator.createTag(getCreationData(uri, tagName,
77
        Element element = tagCreator.createTag(getCreationData(uri, tagName,
76
                _defaultPrefix, file, offset));
78
                _defaultPrefix, file, offset, customizationData));
77
        
79
78
        // this is a hack that is required because we do a literal comparison
80
        // this is a hack that is required because we do a literal comparison
79
        // between the modified source file and test data file on a character
81
        // between the modified source file and test data file on a character
80
        // by character basis.  However, the MyFaces and RI (and possibly other)
82
        // by character basis.  However, the MyFaces and RI (and possibly other)
(-)src/org/eclipse/jst/pagedesigner/tests/tagcreator/base/MockItemCreationTool.java (-3 / +3 lines)
Lines 16-30 Link Here
16
import org.eclipse.gef.EditDomain;
16
import org.eclipse.gef.EditDomain;
17
import org.eclipse.gef.commands.Command;
17
import org.eclipse.gef.commands.Command;
18
import org.eclipse.jst.pagedesigner.commands.CreateItemCommand;
18
import org.eclipse.jst.pagedesigner.commands.CreateItemCommand;
19
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
19
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
20
import org.eclipse.jst.pagedesigner.itemcreation.ItemCreationTool;
20
import org.eclipse.jst.pagedesigner.itemcreation.ItemCreationTool;
21
21
22
public class MockItemCreationTool extends ItemCreationTool
22
public class MockItemCreationTool extends ItemCreationTool
23
{
23
{
24
    private Command     _cached = null;
24
    private Command     _cached = null;
25
25
26
    public MockItemCreationTool(TagToolPaletteEntry tagToolPaletteEntryItem) {
26
    public MockItemCreationTool(ITagDropSourceData tagDropSourceData) {
27
        super(tagToolPaletteEntryItem);
27
        super(tagDropSourceData);
28
    }
28
    }
29
29
30
    @Override
30
    @Override
(-)src/org/eclipse/jst/pagedesigner/tests/tabbed/properties/sections/BasicTabbedPropertyPageTests.java (-1 / +1 lines)
Lines 50-56 Link Here
50
            ISelection sel = getSelection(node);
50
            ISelection sel = getSelection(node);
51
            view.getViewSite().getSelectionProvider().setSelection(sel);
51
            view.getViewSite().getSelectionProvider().setSelection(sel);
52
            ISelection selection = view.getViewSite().getSelectionProvider().getSelection();
52
            ISelection selection = view.getViewSite().getSelectionProvider().getSelection();
53
            assertEquals(sel, selection);                        
53
            assertEquals(sel, selection);
54
            
54
            
55
		} catch(Exception ex) {
55
		} catch(Exception ex) {
56
			ex.printStackTrace();
56
			ex.printStackTrace();
(-)src/org/eclipse/jst/pagedesigner/utils/CommandUtil.java (-44 / +82 lines)
Lines 22-28 Link Here
22
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
22
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
23
import org.eclipse.jst.pagedesigner.PDPlugin;
23
import org.eclipse.jst.pagedesigner.PDPlugin;
24
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
24
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
25
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
25
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceData;
26
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
26
import org.eclipse.jst.pagedesigner.itemcreation.CreationData;
27
import org.eclipse.jst.pagedesigner.itemcreation.CreationData;
27
import org.eclipse.jst.pagedesigner.itemcreation.ITagCreator;
28
import org.eclipse.jst.pagedesigner.itemcreation.ITagCreator;
28
import org.eclipse.jst.pagedesigner.itemcreation.internal.TagCreationFactory;
29
import org.eclipse.jst.pagedesigner.itemcreation.internal.TagCreationFactory;
Lines 34-85 Link Here
34
 * @author mengbo
35
 * @author mengbo
35
 * @version 1.5
36
 * @version 1.5
36
 */
37
 */
37
public class CommandUtil {
38
public class CommandUtil
38
	private static final Logger _log = PDPlugin.getLogger(CommandUtil.class);
39
{
39
40
    private static final Logger _log = PDPlugin.getLogger(CommandUtil.class);
40
	/**
41
41
	 * @param tagItem
42
    /**
42
	 * @param model
43
     * @param dropSourceData
43
	 * @param domPosition
44
     * @param model
44
	 * @param customizationData 
45
     * @param domPosition
45
	 * @return the element inserted or null if failed
46
     * @param customizationData
46
	 */
47
     * @return the element inserted or null if failed
47
	public static Element excuteInsertion(TagToolPaletteEntry tagItem,
48
     */
48
			IDOMModel model, IDOMPosition domPosition, IAdaptable customizationData) {
49
    public static Element executeInsertion(
49
		try 
50
            final IDropSourceData dropSourceData, final IDOMModel model,
50
		{	
51
            final IDOMPosition domPosition, final IAdaptable customizationData)
51
		    IStructuredDocument doc = model.getDocument().getStructuredDocument();
52
    {
52
		    
53
        try
53
		    IStructuredDocumentContext context =
54
        {
54
		        IStructuredDocumentContextFactory.INSTANCE.getContext(doc, -1);
55
            final ITaglibDomainMetaDataModelContext modelContext = getMetadataContext(
55
		    IWorkspaceContextResolver  resolver =
56
                    dropSourceData.getURI(), model);
56
		        IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(context);
57
57
		    
58
            ITagDropSourceData tagDropSourceData = null;
58
		    IProject project = resolver.getProject();
59
59
		    
60
            if (dropSourceData instanceof ITagDropSourceData)
60
            final ITaglibDomainMetaDataModelContext modelContext = 
61
            {
61
                TaglibDomainMetaDataQueryHelper
62
                tagDropSourceData = (ITagDropSourceData) dropSourceData;
62
                    .createMetaDataModelContext(project, tagItem.getURI());
63
            } else if (customizationData != null)
64
            {
65
                tagDropSourceData = (ITagDropSourceData) customizationData
66
                        .getAdapter(ITagDropSourceData.class);
67
            }
68
69
            if (tagDropSourceData == null)
70
            {
71
                PDPlugin
72
                        .log(
73
                                "Could not down cast dropSourceData to tagDropSourceData", new Exception("for stack trace only")); //$NON-NLS-1$//$NON-NLS-2$
74
            }
63
75
64
            // TODO: note that the constructor currently causes the prefix defn
76
            // TODO: note that the constructor currently causes the prefix defn
65
            // to be added to the target doc.  This should be moved into
77
            // to be added to the target doc. This should be moved into
66
            // an ensure method in the AbstractTagCreator
78
            // an ensure method in the AbstractTagCreator
67
            final CreationData creationData = 
79
            final CreationData creationData = new CreationData(
68
                new CreationData(tagItem, model, domPosition, modelContext, customizationData);
80
                    tagDropSourceData, model, domPosition, modelContext,
69
81
                    customizationData);
70
		    ITagCreator tagCreator = 
82
71
			    TagCreationFactory.getInstance().createTagCreator(creationData.getTagId());
83
            final ITagCreator tagCreator = TagCreationFactory.getInstance()
72
			
84
                    .createTagCreator(creationData.getTagId());
73
			if (tagCreator == null)
85
74
			{
86
            if (tagCreator == null)
75
				return null;//should never get here!
87
            {
76
			}
88
                return null;// should never get here!
77
89
            }
78
			return tagCreator.createTag(creationData);
90
79
		} catch (Exception e) {
91
            return tagCreator.createTag(creationData);
80
			_log.error("Problem creating tag "+tagItem.getTagName()+" at:" + domPosition + "\n", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
92
        } catch (Exception e)
81
		}
93
        {
94
            _log
95
                    .error(
96
                            "Problem creating tag " + dropSourceData.getTagName() + " at:" + domPosition + "\n", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
97
        }
82
        return null;
98
        return null;
83
	}
99
    }
84
100
101
    /**
102
     * @param uri
103
     * @param model
104
     * @return the metadata context for uri in the DOM model or null if none.
105
     */
106
    public static ITaglibDomainMetaDataModelContext getMetadataContext(
107
            final String uri, final IDOMModel model)
108
    {
109
        final IStructuredDocument doc = model.getDocument()
110
                .getStructuredDocument();
111
112
        final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
113
                .getContext(doc, -1);
114
        final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
115
                .getWorkspaceContextResolver(context);
116
117
        final IProject project = resolver.getProject();
118
119
        final ITaglibDomainMetaDataModelContext modelContext = TaglibDomainMetaDataQueryHelper
120
                .createMetaDataModelContext(project, uri);
121
        return modelContext;
122
    }
85
}
123
}
(-)src/org/eclipse/jst/pagedesigner/itemcreation/CreationData.java (-49 / +16 lines)
Lines 20-30 Link Here
20
import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper;
20
import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper;
21
import org.eclipse.jst.jsf.core.internal.tld.ITLDConstants;
21
import org.eclipse.jst.jsf.core.internal.tld.ITLDConstants;
22
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
22
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
23
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.PaletteInfo;
24
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.PaletteInfos;
25
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationInfo;
26
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
23
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
27
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
24
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
28
import org.eclipse.jst.pagedesigner.utils.JSPUtil;
25
import org.eclipse.jst.pagedesigner.utils.JSPUtil;
29
import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMDocType;
26
import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMDocType;
30
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
27
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
Lines 39-50 Link Here
39
 */
36
 */
40
public final class CreationData
37
public final class CreationData
41
{
38
{
42
    private final TagToolPaletteEntry   _tagEntry;
39
    private final ITagDropSourceData  _creationProvider;
43
    private final String                _prefix; 
40
    private final String                _prefix; 
44
    private final IDOMPosition          _domPosition;
41
    private final IDOMPosition          _domPosition;
45
    private final IDOMModel             _model;
42
    private final IDOMModel             _model;
46
    private final IAdaptable            _customizationData;
43
    private final IAdaptable            _customizationData;
47
    
44
48
    private TagIdentifier               _tagId; // = null; lazy init on creation 
45
    private TagIdentifier               _tagId; // = null; lazy init on creation 
49
    
46
    
50
    /**
47
    /**
Lines 63-78 Link Here
63
60
64
    
61
    
65
    /**
62
    /**
66
     * @param tagEntry  TODO: remove this direct dependence on the palette
63
     * @param creationProvider 
67
     * @param model 
64
     * @param model 
68
     * @param domPosition 
65
     * @param domPosition 
69
     * @param taglibMetaDataContext 
66
     * @param taglibMetaDataContext 
70
     * @param customizationData 
67
     * @param customizationData 
71
     */
68
     */
72
    public CreationData(final TagToolPaletteEntry tagEntry, final IDOMModel model, final IDOMPosition domPosition, final ITaglibDomainMetaDataModelContext taglibMetaDataContext, final IAdaptable customizationData) 
69
    public CreationData(final ITagDropSourceData creationProvider,
70
            final IDOMModel model, final IDOMPosition domPosition,
71
            final ITaglibDomainMetaDataModelContext taglibMetaDataContext,
72
            final IAdaptable customizationData)
73
    {
73
    {
74
        super();
74
        super();
75
        this._tagEntry = tagEntry;
75
        this._creationProvider = creationProvider;
76
        this._prefix = getPrefix(getUri(), model, getDefaultPrefix());
76
        this._prefix = getPrefix(getUri(), model, getDefaultPrefix());
77
        this._taglibMetaDataContext = taglibMetaDataContext;
77
        this._taglibMetaDataContext = taglibMetaDataContext;
78
        this._domPosition = domPosition;
78
        this._domPosition = domPosition;
Lines 105-118 Link Here
105
     * @return the tag identifier uri
105
     * @return the tag identifier uri
106
     */
106
     */
107
    public String getUri() {
107
    public String getUri() {
108
        return _tagEntry.getURI();
108
        return _creationProvider.getURI();
109
    }
109
    }
110
110
111
    /**
111
    /**
112
     * @return the default prefix
112
     * @return the default prefix
113
     */
113
     */
114
    public String getDefaultPrefix() {
114
    public String getDefaultPrefix() {
115
        return _tagEntry.getDefaultPrefix();
115
        return _creationProvider.getDefaultPrefix();
116
    }
116
    }
117
117
118
    /**
118
    /**
Lines 126-175 Link Here
126
     * @return the tag name
126
     * @return the tag name
127
     */
127
     */
128
    public String getTagName() {
128
    public String getTagName() {
129
        return _tagEntry.getTagName();
129
        return _creationProvider.getTagName();
130
    }
130
    }
131
131
132
    /**
132
    /**
133
     * @return the id
133
     * @return the creation provider
134
     */
135
    private String getItemId() {
136
        return _tagEntry.getId();
137
    }
138
139
    /**
140
     * @return the palette entry that this creation info is based on
141
     */
142
    public TagToolPaletteEntry getTagEntry() {
143
        return _tagEntry;
144
    }
145
    
146
    /**
147
     * @return {@link TagCreationInfo} for the tag entity
148
     */
134
     */
149
    public TagCreationInfo getTagCreationInfo(){
135
    public ITagDropSourceData getTagCreationProvider()
150
        Model model = TaglibDomainMetaDataQueryHelper.getModel(_taglibMetaDataContext);
136
    {
151
        if (model != null){
137
        return _creationProvider;
152
            Trait trait = TaglibDomainMetaDataQueryHelper.getTrait(model, PaletteInfos.TRAIT_ID);
153
            if (trait != null){
154
                PaletteInfos pis = (PaletteInfos)trait.getValue();
155
                PaletteInfo pi = pis.findPaletteInfoById(getItemId());
156
                if (pi != null){
157
                    return pi.getTagCreation();                 
158
                }
159
            }
160
            //tag-creation trait on entity directly?
161
            Entity tag = getTagEntity();
162
            if (tag != null){//metadata exists
163
                trait = TaglibDomainMetaDataQueryHelper.getTrait(tag, "tag-create"); //$NON-NLS-1$
164
                if (trait != null && trait.getValue() != null){
165
                    return (TagCreationInfo)trait.getValue();                   
166
                }
167
            }
168
        }
169
        return null;
170
    }
138
    }
171
139
172
    
173
    /**
140
    /**
174
     * @return the {@link Entity} for this tag element being created
141
     * @return the {@link Entity} for this tag element being created
175
     */
142
     */
(-)src/org/eclipse/jst/pagedesigner/itemcreation/ItemCreationTool.java (-7 / +7 lines)
Lines 18-24 Link Here
18
import org.eclipse.gef.commands.Command;
18
import org.eclipse.gef.commands.Command;
19
import org.eclipse.gef.tools.TargetingTool;
19
import org.eclipse.gef.tools.TargetingTool;
20
import org.eclipse.jst.pagedesigner.commands.CreateItemCommand;
20
import org.eclipse.jst.pagedesigner.commands.CreateItemCommand;
21
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
21
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
22
import org.eclipse.jst.pagedesigner.itemcreation.customizer.DropCustomizationController;
22
import org.eclipse.jst.pagedesigner.itemcreation.customizer.DropCustomizationController;
23
import org.eclipse.swt.graphics.Cursor;
23
import org.eclipse.swt.graphics.Cursor;
24
24
Lines 32-48 Link Here
32
 * @author mengbo
32
 * @author mengbo
33
 */
33
 */
34
public class ItemCreationTool extends TargetingTool {
34
public class ItemCreationTool extends TargetingTool {
35
	TagToolPaletteEntry _tagPaletteItem; //can we get rid of this?
35
    private final ITagDropSourceData _tagDropSourceData; //can we get rid of this?
36
36
37
	/**
37
	/**
38
	 * Default constructor. Sets the default and disabled cursors.
38
	 * Default constructor. Sets the default and disabled cursors.
39
	 * @param tagToolPaletteEntryItem 
39
	 * @param tagDropSourceData 
40
	 */
40
	 */
41
	public ItemCreationTool(TagToolPaletteEntry tagToolPaletteEntryItem) {
41
	public ItemCreationTool(ITagDropSourceData tagDropSourceData) {
42
		setDefaultCursor(SharedCursors.CURSOR_TREE_ADD);
42
		setDefaultCursor(SharedCursors.CURSOR_TREE_ADD);
43
		setDisabledCursor(SharedCursors.NO);
43
		setDisabledCursor(SharedCursors.NO);
44
44
45
		this._tagPaletteItem = tagToolPaletteEntryItem;  
45
		this._tagDropSourceData = tagDropSourceData;  
46
	}
46
	}
47
47
48
	/**
48
	/**
Lines 69-75 Link Here
69
	 */
69
	 */
70
	protected Request createTargetRequest() {
70
	protected Request createTargetRequest() {
71
		ItemCreationRequest request = new ItemCreationRequest();
71
		ItemCreationRequest request = new ItemCreationRequest();
72
		request.setTagToolPaletteEntry(_tagPaletteItem);
72
		request.setTagCreationProvider(_tagDropSourceData);
73
		return request;
73
		return request;
74
	}
74
	}
75
75
Lines 168-174 Link Here
168
        if (command instanceof CreateItemCommand)
168
        if (command instanceof CreateItemCommand)
169
        {
169
        {
170
            status = new DropCustomizationController((CreateItemCommand) command,
170
            status = new DropCustomizationController((CreateItemCommand) command,
171
                    _tagPaletteItem.getURI(), _tagPaletteItem.getTagName(), 
171
                    _tagDropSourceData, 
172
                    ((CreateItemCommand)command).getDocument(),
172
                    ((CreateItemCommand)command).getDocument(),
173
                    ((CreateItemCommand)command).getPosition()).
173
                    ((CreateItemCommand)command).getPosition()).
174
                performCustomization();
174
                performCustomization();
(-)src/org/eclipse/jst/pagedesigner/itemcreation/ItemCreationRequest.java (-17 / +10 lines)
Lines 14-20 Link Here
14
import org.eclipse.draw2d.geometry.Point;
14
import org.eclipse.draw2d.geometry.Point;
15
import org.eclipse.gef.Request;
15
import org.eclipse.gef.Request;
16
import org.eclipse.gef.requests.DropRequest;
16
import org.eclipse.gef.requests.DropRequest;
17
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
17
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceData;
18
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
18
19
19
/**
20
/**
20
 * Tag tool item creation request class
21
 * Tag tool item creation request class
Lines 29-35 Link Here
29
	/**
30
	/**
30
	 * Constant used for tag tool item
31
	 * Constant used for tag tool item
31
	 */
32
	 */
32
	public static final String TAG_TOOL_PALETTE_ENTRY = "TagToolPaletteEntry"; //$NON-NLS-1$
33
	private static final String DROP_SOURCE_DATA = "TagToolPaletteEntry"; //$NON-NLS-1$
33
	/**
34
	/**
34
	 * Constant used for location during creation request
35
	 * Constant used for location during creation request
35
	 */
36
	 */
Lines 43-56 Link Here
43
		super(REQ_ITEM_CREATION);
44
		super(REQ_ITEM_CREATION);
44
	}
45
	}
45
46
46
	/**
47
	 * Constructor
48
	 * @param type
49
	 */
50
	public ItemCreationRequest(Object type) {
51
		super(type);
52
	}
53
54
	/*
47
	/*
55
	 * (non-Javadoc)
48
	 * (non-Javadoc)
56
	 * 
49
	 * 
Lines 73-90 Link Here
73
66
74
	/**
67
	/**
75
	 * Set the tag tool item for creation request
68
	 * Set the tag tool item for creation request
76
	 * @param tagToolPaletteEntryItem
69
	 * @param creationProvider
77
	 */
70
	 */
78
	public void setTagToolPaletteEntry(TagToolPaletteEntry tagToolPaletteEntryItem) {
71
	public void setTagCreationProvider(final IDropSourceData creationProvider) {
79
		getExtendedData().remove(TAG_TOOL_PALETTE_ENTRY);
72
		getExtendedData().remove(DROP_SOURCE_DATA);
80
		getExtendedData().put(TAG_TOOL_PALETTE_ENTRY, tagToolPaletteEntryItem);
73
		getExtendedData().put(DROP_SOURCE_DATA, creationProvider);
81
	}
74
	}
82
75
83
	/**
76
	/**
84
	 * @return {@link TagToolPaletteEntry} requesting creation
77
	 * @return {@link ITagDropSourceData} requesting creation
85
	 */
78
	 */
86
	public TagToolPaletteEntry getTagToolPaletteEntry() {
79
	public IDropSourceData getTagCreationProvider() {
87
		return (TagToolPaletteEntry)getExtendedData().get(TAG_TOOL_PALETTE_ENTRY);
80
		return (IDropSourceData)getExtendedData().get(DROP_SOURCE_DATA);
88
	}
81
	}
89
82
90
}
83
}
(-)src/org/eclipse/jst/pagedesigner/itemcreation/UserCustomizedTagCreationAdvisor.java (-2 / +2 lines)
Lines 72-83 Link Here
72
                
72
                
73
                if (isFirstParent) 
73
                if (isFirstParent) 
74
                {
74
                {
75
                    command = new UserCustomizedContainerCreationCommand(position, parentTagIdentifier, _creationData.getTagId(), (IAdaptable) parentCustomizationData);
75
                    command = new UserCustomizedContainerCreationCommand(position, parentTagIdentifier, _creationData.getTagId(), parentCustomizationData);
76
                    isFirstParent = false;
76
                    isFirstParent = false;
77
                }
77
                }
78
                else
78
                else
79
                {
79
                {
80
                    command.chain(new UserCustomizedContainerCreationCommand(position, parentTagIdentifier, _creationData.getTagId(), (IAdaptable) parentCustomizationData));
80
                    command.chain(new UserCustomizedContainerCreationCommand(position, parentTagIdentifier, _creationData.getTagId(), parentCustomizationData));
81
                }
81
                }
82
            }
82
            }
83
            return command;
83
            return command;
(-)src/org/eclipse/jst/pagedesigner/itemcreation/ItemCreationEditPolicy.java (-1 / +2 lines)
Lines 53-62 Link Here
53
			if (domposition == null) {
53
			if (domposition == null) {
54
				return null;
54
				return null;
55
			}
55
			}
56
//			TagToolCreationAdapter tagToolCreationAdapter = new TagToolCreationAdapter(r.getTagToolPaletteEntry(), getViewer(getHost()).getModel());
56
			return new CreateItemCommand(
57
			return new CreateItemCommand(
57
					PDPlugin
58
					PDPlugin
58
							.getResourceString("ItemCreationEditPolicy.CommandLabel.CreateItem"),//$NON-NLS-1$
59
							.getResourceString("ItemCreationEditPolicy.CommandLabel.CreateItem"),//$NON-NLS-1$
59
					getViewer(getHost()).getModel(), domposition, r.getTagToolPaletteEntry());
60
					getViewer(getHost()).getModel(), domposition, r.getTagCreationProvider());
60
		}
61
		}
61
		return null;
62
		return null;
62
	}
63
	}
(-)src/org/eclipse/jst/pagedesigner/dnd/internal/DesignerTemplateTransferDragSourceListener.java (-49 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 Sybase, Inc. and others.
3
 *
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
8
 *
9
 * Contributors:
10
 *     Sybase, Inc. - initial API and implementation
11
 *******************************************************************************/
12
package org.eclipse.jst.pagedesigner.dnd.internal;
13
14
import java.util.List;
15
16
import org.eclipse.gef.EditPart;
17
import org.eclipse.gef.EditPartViewer;
18
import org.eclipse.gef.dnd.TemplateTransferDragSourceListener;
19
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
20
21
/**
22
 * @author mengbo
23
 */
24
public class DesignerTemplateTransferDragSourceListener extends
25
		TemplateTransferDragSourceListener {
26
27
	/**
28
	 * @param viewer
29
	 */
30
	public DesignerTemplateTransferDragSourceListener(EditPartViewer viewer) {
31
		super(viewer);
32
	}
33
34
	protected Object getTemplate() {
35
		Object object = super.getTemplate();
36
		if (object == null) {
37
			List selection = getViewer().getSelectedEditParts();
38
			if (selection.size() == 1) {
39
				EditPart editpart = (EditPart) getViewer()
40
						.getSelectedEditParts().get(0);
41
				Object model = editpart.getModel();
42
				if (model instanceof TagToolPaletteEntry) {
43
					return model;
44
				}
45
			}
46
		}
47
		return null;
48
	}
49
}
(-)src/org/eclipse/jst/pagedesigner/dnd/internal/DesignerSourceDropTargetListener.java (-4 / +5 lines)
Lines 15-21 Link Here
15
import org.eclipse.gef.dnd.TemplateTransfer;
15
import org.eclipse.gef.dnd.TemplateTransfer;
16
import org.eclipse.jst.pagedesigner.commands.PaletteDropInsertCommand;
16
import org.eclipse.jst.pagedesigner.commands.PaletteDropInsertCommand;
17
import org.eclipse.jst.pagedesigner.editors.pagedesigner.PageDesignerResources;
17
import org.eclipse.jst.pagedesigner.editors.pagedesigner.PageDesignerResources;
18
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
18
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceDataProvider;
19
import org.eclipse.swt.custom.StyledText;
19
import org.eclipse.swt.custom.StyledText;
20
import org.eclipse.swt.dnd.DropTargetEvent;
20
import org.eclipse.swt.dnd.DropTargetEvent;
21
import org.eclipse.swt.dnd.TextTransfer;
21
import org.eclipse.swt.dnd.TextTransfer;
Lines 125-138 Link Here
125
				event.currentDataType)) {
125
				event.currentDataType)) {
126
			Object data = event.data;
126
			Object data = event.data;
127
			PaletteDropInsertCommand command = null;
127
			PaletteDropInsertCommand command = null;
128
			if (data instanceof TagToolPaletteEntry) {
128
			if (data instanceof IDropSourceDataProvider) {
129
				TagToolPaletteEntry tagItem = (TagToolPaletteEntry) data;
129
			    IDropSourceDataProvider provider = (IDropSourceDataProvider) data;
130
130
				// "Create new item"
131
				// "Create new item"
131
				command = new PaletteDropInsertCommand(
132
				command = new PaletteDropInsertCommand(
132
						PageDesignerResources
133
						PageDesignerResources
133
								.getInstance()
134
								.getInstance()
134
								.getString(
135
								.getString(
135
										"DesignerSourceDropTargetListener.InserCommandLabel"), _textEditor, tagItem, _location); //$NON-NLS-1$
136
										"DesignerSourceDropTargetListener.InserCommandLabel"), _textEditor, provider.getDropSourceData(), _location); //$NON-NLS-1$
136
			}
137
			}
137
			return command;
138
			return command;
138
		}
139
		}
(-)src/org/eclipse/jst/pagedesigner/dnd/internal/DesignerSourceMouseTrackAdapter.java (-8 / +7 lines)
Lines 16-22 Link Here
16
import org.eclipse.jst.pagedesigner.commands.PaletteDropInsertCommand;
16
import org.eclipse.jst.pagedesigner.commands.PaletteDropInsertCommand;
17
import org.eclipse.jst.pagedesigner.commands.SourceViewerCommand;
17
import org.eclipse.jst.pagedesigner.commands.SourceViewerCommand;
18
import org.eclipse.jst.pagedesigner.editors.pagedesigner.PageDesignerResources;
18
import org.eclipse.jst.pagedesigner.editors.pagedesigner.PageDesignerResources;
19
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
19
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceDataProvider;
20
import org.eclipse.swt.custom.StyledText;
20
import org.eclipse.swt.custom.StyledText;
21
import org.eclipse.swt.events.MouseEvent;
21
import org.eclipse.swt.events.MouseEvent;
22
import org.eclipse.swt.events.MouseListener;
22
import org.eclipse.swt.events.MouseListener;
Lines 102-112 Link Here
102
	 * @see org.eclipse.gef.palette.PaletteListener#activeToolChanged(org.eclipse.gef.ui.palette.PaletteViewer,
102
	 * @see org.eclipse.gef.palette.PaletteListener#activeToolChanged(org.eclipse.gef.ui.palette.PaletteViewer,
103
	 *      org.eclipse.gef.palette.ToolEntry)
103
	 *      org.eclipse.gef.palette.ToolEntry)
104
	 */
104
	 */
105
	private Object getPaletteObject() {
105
	private IDropSourceDataProvider getPaletteObject() {
106
		if (_domain.getPaletteViewer() != null) {
106
		if (_domain.getPaletteViewer() != null) {
107
			Object tool = _domain.getPaletteViewer().getActiveTool();
107
			Object tool = _domain.getPaletteViewer().getActiveTool();
108
			if (tool instanceof TagToolPaletteEntry) {
108
			if (tool instanceof IDropSourceDataProvider) {
109
				return tool;
109
				return (IDropSourceDataProvider) tool;
110
			}
110
			}
111
		}
111
		}
112
		return null;
112
		return null;
Lines 131-147 Link Here
131
	}
131
	}
132
132
133
	private PaletteDropInsertCommand getCommand(MouseEvent event) {
133
	private PaletteDropInsertCommand getCommand(MouseEvent event) {
134
		Object data = getPaletteObject();
134
	    IDropSourceDataProvider data = getPaletteObject();
135
		PaletteDropInsertCommand command = null;
135
		PaletteDropInsertCommand command = null;
136
		if (data instanceof TagToolPaletteEntry) {
136
		if (data != null) {
137
			TagToolPaletteEntry descriptor = (TagToolPaletteEntry) data;
138
			// "Create new item"
137
			// "Create new item"
139
			command = new PaletteDropInsertCommand(
138
			command = new PaletteDropInsertCommand(
140
					PageDesignerResources
139
					PageDesignerResources
141
							.getInstance()
140
							.getInstance()
142
							.getString(
141
							.getString(
143
									"DesignerSourceDropTargetListener.InserCommandLabel"), //$NON-NLS-1$
142
									"DesignerSourceDropTargetListener.InserCommandLabel"), //$NON-NLS-1$
144
					_textEditor, descriptor, _location);
143
					_textEditor, data.getDropSourceData(), _location);
145
		}
144
		}
146
		return command;
145
		return command;
147
	}
146
	}
(-)src/org/eclipse/jst/pagedesigner/dnd/internal/PDTemplateTransferDropTargetListener.java (-9 / +4 lines)
Lines 19-25 Link Here
19
import org.eclipse.gef.dnd.TemplateTransfer;
19
import org.eclipse.gef.dnd.TemplateTransfer;
20
import org.eclipse.jst.pagedesigner.PDPlugin;
20
import org.eclipse.jst.pagedesigner.PDPlugin;
21
import org.eclipse.jst.pagedesigner.commands.CreateItemCommand;
21
import org.eclipse.jst.pagedesigner.commands.CreateItemCommand;
22
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
22
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceData;
23
import org.eclipse.jst.pagedesigner.itemcreation.ItemCreationRequest;
23
import org.eclipse.jst.pagedesigner.itemcreation.ItemCreationRequest;
24
import org.eclipse.jst.pagedesigner.itemcreation.customizer.DropCustomizationController;
24
import org.eclipse.jst.pagedesigner.itemcreation.customizer.DropCustomizationController;
25
import org.eclipse.swt.dnd.DND;
25
import org.eclipse.swt.dnd.DND;
Lines 92-103 Link Here
92
			ItemCreationRequest request = (ItemCreationRequest) getCreateRequest();
92
			ItemCreationRequest request = (ItemCreationRequest) getCreateRequest();
93
            Object transferObj = TemplateTransfer.getInstance().getObject();
93
            Object transferObj = TemplateTransfer.getInstance().getObject();
94
            
94
            
95
            if (transferObj instanceof TagToolPaletteEntry)
95
            if (transferObj instanceof IDropSourceData)
96
            {
96
            {
97
            	TagToolPaletteEntry tagItem = 
97
                request.setTagCreationProvider((IDropSourceData) transferObj);
98
                    (TagToolPaletteEntry) transferObj;
99
100
                request.setTagToolPaletteEntry(tagItem);
101
                request.setLocation(getDropLocation());
98
                request.setLocation(getDropLocation());
102
            }
99
            }
103
            else
100
            else
Lines 140-150 Link Here
140
        if (command instanceof CreateItemCommand)
137
        if (command instanceof CreateItemCommand)
141
        {
138
        {
142
            final ItemCreationRequest request = (ItemCreationRequest) getCreateRequest();
139
            final ItemCreationRequest request = (ItemCreationRequest) getCreateRequest();
143
            final String name = request.getTagToolPaletteEntry().getTagName();
144
            final String uri = request.getTagToolPaletteEntry().getURI();
145
            final CreateItemCommand createCommand = (CreateItemCommand) command;
140
            final CreateItemCommand createCommand = (CreateItemCommand) command;
146
            final IStatus status  = 
141
            final IStatus status  = 
147
                new DropCustomizationController(createCommand, uri, name, createCommand.getDocument(), createCommand.getPosition())
142
                new DropCustomizationController(createCommand, request.getTagCreationProvider(), createCommand.getDocument(), createCommand.getPosition())
148
                    .performCustomization();
143
                    .performCustomization();
149
            
144
            
150
            return status.getSeverity() == IStatus.OK;
145
            return status.getSeverity() == IStatus.OK;
(-)src/org/eclipse/jst/pagedesigner/itemcreation/command/ElementCustomizationCommand.java (-10 / +16 lines)
Lines 13-24 Link Here
13
import java.util.Collection;
13
import java.util.Collection;
14
import java.util.Collections;
14
import java.util.Collections;
15
import java.util.Iterator;
15
import java.util.Iterator;
16
import java.util.List;
16
17
17
import org.eclipse.emf.common.command.Command;
18
import org.eclipse.emf.common.command.Command;
18
import org.eclipse.emf.common.util.EList;
19
import org.eclipse.jst.jsf.core.internal.tld.CMUtil;
19
import org.eclipse.jst.jsf.core.internal.tld.CMUtil;
20
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationAttribute;
20
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationAttribute;
21
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationInfo;
21
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
22
import org.eclipse.jst.pagedesigner.editors.palette.MetadataTagDropSourceData;
23
import org.eclipse.jst.pagedesigner.editors.palette.TagToolCreationAdapter;
22
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteElementTemplateHelper;
24
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteElementTemplateHelper;
23
import org.eclipse.jst.pagedesigner.itemcreation.CreationData;
25
import org.eclipse.jst.pagedesigner.itemcreation.CreationData;
24
import org.eclipse.jst.pagedesigner.itemcreation.internal.AbstractCreationCommand;
26
import org.eclipse.jst.pagedesigner.itemcreation.internal.AbstractCreationCommand;
Lines 97-107 Link Here
97
     */
99
     */
98
    protected void applyChildElementCustomization()
100
    protected void applyChildElementCustomization()
99
    {
101
    {
100
        final TagCreationInfo tagCreationInfo = _creationData.getTagCreationInfo();
102
        final ITagDropSourceData tagDropSourceData = 
101
        if (tagCreationInfo != null)
103
            _creationData.getTagCreationProvider();
104
        if (tagDropSourceData != null)
102
        {
105
        {
106
            MetadataTagDropSourceData provider =
107
                TagToolCreationAdapter.createMdTagCreationProvider(tagDropSourceData, _model);
103
            PaletteElementTemplateHelper.applyTemplate(_model, _element,
108
            PaletteElementTemplateHelper.applyTemplate(_model, _element,
104
                    _creationData.getTagEntry(), tagCreationInfo);
109
                    provider);
105
        }
110
        }
106
    }
111
    }
107
112
Lines 117-122 Link Here
117
     * @param element
122
     * @param element
118
     * @param creationData
123
     * @param creationData
119
     */
124
     */
125
    @SuppressWarnings("deprecation")
120
    protected final void ensureRequiredAttrs(final Element element,
126
    protected final void ensureRequiredAttrs(final Element element,
121
            final CreationData creationData)
127
            final CreationData creationData)
122
    {
128
    {
Lines 150-165 Link Here
150
     */
156
     */
151
    protected void applyAttributeCustomization()
157
    protected void applyAttributeCustomization()
152
    {
158
    {
153
        final TagCreationInfo info = _creationData.getTagCreationInfo();
159
        final ITagDropSourceData info = _creationData.getTagCreationProvider();
154
        if (info != null)
160
        if (info != null)
155
        {
161
        {
156
            final EList list = info.getAttributes();
162
            final MetadataTagDropSourceData provider =
163
                TagToolCreationAdapter.createMdTagCreationProvider(info, _model);
164
            final List<TagCreationAttribute> list = provider.getAttributes();
157
            if (list != null)
165
            if (list != null)
158
            {
166
            {
159
                for (final Iterator it = list.iterator(); it.hasNext();)
167
                for (final TagCreationAttribute attr : list)
160
                {
168
                {
161
                    final TagCreationAttribute attr = (TagCreationAttribute) it
162
                            .next();
163
                    _element.setAttribute(attr.getId(),
169
                    _element.setAttribute(attr.getId(),
164
                            (attr.getValue() == null ? "" : attr.getValue())); //$NON-NLS-1$
170
                            (attr.getValue() == null ? "" : attr.getValue())); //$NON-NLS-1$
165
                }
171
                }
(-)src/org/eclipse/jst/pagedesigner/itemcreation/command/UserCustomizedContainerCreationCommand.java (-5 / +15 lines)
Lines 6-12 Link Here
6
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
6
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
7
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
7
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
8
import org.eclipse.jst.pagedesigner.dom.ValidatorSupport;
8
import org.eclipse.jst.pagedesigner.dom.ValidatorSupport;
9
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
10
import org.eclipse.jst.pagedesigner.editors.palette.TagToolCreationAdapter;
9
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData;
11
import org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData;
12
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
13
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
10
14
11
/**
15
/**
12
 * Tag container creation command for tags dropped on to the WPE by the user
16
 * Tag container creation command for tags dropped on to the WPE by the user
Lines 57-76 Link Here
57
        return _data;
61
        return _data;
58
    }
62
    }
59
63
60
    
61
    @Override
64
    @Override
62
    protected IDOMPosition doExecute() 
65
    protected IDOMPosition doExecute()
63
    {
66
    {
64
        final IDOMPosition domPosition = getDomPosition();
67
        final IDOMPosition domPosition = getDomPosition();
65
        final QName  containerQName = getContainerTag().asQName();
68
        final QName containerQName = getContainerTag().asQName();
66
69
67
        IDOMPosition newPosition = domPosition;
70
        IDOMPosition newPosition = domPosition;
68
        newPosition = ValidatorSupport.insertContainer(domPosition, containerQName, getContainerCustomizationData());
71
        final IDOMModel model = ((IDOMNode) domPosition.getContainerNode())
72
                .getModel();
73
74
        final ITagDropSourceData creationProvider = TagToolCreationAdapter
75
                .findProviderForContainer(containerQName);
76
77
        newPosition = ValidatorSupport.insertContainer(domPosition,
78
                model, creationProvider, getContainerCustomizationData());
69
        if (newPosition == null)
79
        if (newPosition == null)
70
        {
80
        {
71
            newPosition = domPosition;
81
            newPosition = domPosition;
72
        }
82
        }
73
        
83
74
        return newPosition;
84
        return newPosition;
75
    }
85
    }
76
}
86
}
(-)src/org/eclipse/jst/pagedesigner/itemcreation/command/TagContainerCreationCommand.java (-2 / +12 lines)
Lines 16-21 Link Here
16
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
16
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
17
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
17
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
18
import org.eclipse.jst.pagedesigner.dom.ValidatorSupport;
18
import org.eclipse.jst.pagedesigner.dom.ValidatorSupport;
19
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
20
import org.eclipse.jst.pagedesigner.editors.palette.TagToolCreationAdapter;
21
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
22
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
19
23
20
/**
24
/**
21
 * @author cbateman
25
 * @author cbateman
Lines 45-53 Link Here
45
        final QName  containerQName = getContainerTag().asQName();
49
        final QName  containerQName = getContainerTag().asQName();
46
        boolean hasform = ValidatorSupport.checkContainer(domPosition, containerQName);
50
        boolean hasform = ValidatorSupport.checkContainer(domPosition, containerQName);
47
        IDOMPosition newPosition = domPosition;
51
        IDOMPosition newPosition = domPosition;
48
        if (!hasform) {
52
        if (!hasform)
53
        {
54
            final IDOMModel model = ((IDOMNode) domPosition.getContainerNode())
55
                .getModel();
56
57
            final ITagDropSourceData creationProvider =
58
                TagToolCreationAdapter.findProviderForContainer(containerQName);
49
            newPosition = ValidatorSupport
59
            newPosition = ValidatorSupport
50
                    .insertContainer(domPosition, containerQName, getContainerCustomizationData());
60
                    .insertContainer(domPosition, model, creationProvider, getContainerCustomizationData());
51
            if (newPosition == null) {
61
            if (newPosition == null) {
52
                newPosition = domPosition;
62
                newPosition = domPosition;
53
            }
63
            }
(-)src/org/eclipse/jst/pagedesigner/itemcreation/command/UserCustomizedElementCustomizationCommand.java (-39 / +28 lines)
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
                }
(-)src/org/eclipse/jst/pagedesigner/editors/palette/TagToolPaletteEntry.java (-53 / +90 lines)
Lines 11-73 Link Here
11
package org.eclipse.jst.pagedesigner.editors.palette;
11
package org.eclipse.jst.pagedesigner.editors.palette;
12
12
13
import org.eclipse.gef.Tool;
13
import org.eclipse.gef.Tool;
14
import org.eclipse.gef.palette.ToolEntry;
14
import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
15
import org.eclipse.gef.requests.CreationFactory;
15
import org.eclipse.jface.resource.ImageDescriptor;
16
import org.eclipse.jface.resource.ImageDescriptor;
16
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer;
17
import org.eclipse.jst.pagedesigner.itemcreation.ItemCreationTool;
17
import org.eclipse.jst.pagedesigner.itemcreation.ItemCreationTool;
18
18
19
/**
19
/**
20
 * Represents a tag palette item entry in the web page designer palette
20
 * Represents a tag palette item entry in the web page designer palette
21
 *
21
 * 
22
 */
22
 */
23
public class TagToolPaletteEntry extends ToolEntry {
23
public class TagToolPaletteEntry extends CombinedTemplateCreationEntry
24
24
        implements IDropSourceDataProvider
25
	private String tagName;
25
{
26
	
26
27
	/**
27
    /**
28
	 * Constructor
28
     * Constructor
29
	 * @param tagName
29
     * 
30
	 * @param label
30
     * @param template
31
	 * @param shortDescription
31
     *            the template item for the drop
32
	 * @param iconSmall
32
     * @param label
33
	 * @param iconLarge
33
     * @param shortDescription
34
	 */
34
     * @param iconSmall
35
	public TagToolPaletteEntry(String tagName, String label, String shortDescription,
35
     * @param iconLarge
36
			ImageDescriptor iconSmall, ImageDescriptor iconLarge) {
36
     */
37
		super(label, shortDescription, iconSmall, iconLarge);
37
    public TagToolPaletteEntry(final ITagDropSourceData template,
38
		this.tagName = tagName;
38
            final String label, final String shortDescription,
39
	}
39
            final ImageDescriptor iconSmall, final ImageDescriptor iconLarge)
40
40
    {
41
	/**
41
        super(label, shortDescription, template, NOOP_FACTORY, iconSmall,
42
	 * @return tagName
42
                iconLarge);
43
	 */
43
    }
44
	public String getTagName(){
44
45
		return tagName;
45
    /**
46
	}
46
     * @return tagName
47
	
47
     */
48
	/**
48
    public String getTagName()
49
	 * Convenience method returning the tag libraries default prefix, if applicable
49
    {
50
	 * @return default prefix 
50
        return getTemplate().getTagName();
51
	 */
51
    }
52
	public String getDefaultPrefix(){
52
53
		if (getParent() instanceof TaglibPaletteDrawer)
53
    /**
54
			return ((TaglibPaletteDrawer)getParent()).getDefaultPrefix();
54
     * Convenience method returning the tag libraries default prefix, if
55
		return ""; //$NON-NLS-1$
55
     * applicable
56
	}
56
     * 
57
57
     * @return default prefix
58
	/**
58
     */
59
	 * @return uri of the tag's library
59
    public String getDefaultPrefix()
60
	 */
60
    {
61
	public String getURI(){
61
        return getTemplate().getDefaultPrefix();
62
		return ((TaglibPaletteDrawer)getParent()).getURI();
62
    }
63
	}
63
64
64
    /**
65
	/* (non-Javadoc)
65
     * @return uri of the tag's library
66
	 * @see org.eclipse.gef.palette.ToolEntry#createTool()
66
     */
67
	 */
67
    public String getURI()
68
	public Tool createTool() {
68
    {
69
		return new ItemCreationTool(this);
69
        return getTemplate().getURI();
70
	}
70
    }
71
	
71
72
72
    /*
73
     * (non-Javadoc)
74
     * 
75
     * @see org.eclipse.gef.palette.ToolEntry#createTool()
76
     */
77
    @Override
78
    public Tool createTool()
79
    {
80
        return new ItemCreationTool(getTemplate());
81
    }
82
83
    private final static CreationFactory NOOP_FACTORY = new CreationFactory()
84
    {
85
        public Object getNewObject()
86
        {
87
            // should never get called
88
            throw new UnsupportedOperationException(
89
                    "createTool should be overriden, so this should never be called"); //$NON-NLS-1$
90
        }
91
92
        public Object getObjectType()
93
        {
94
            // should never get called
95
            throw new UnsupportedOperationException(
96
                    "createTool should be overriden, so this should never be called"); //$NON-NLS-1$
97
        }
98
    };
99
100
    @Override
101
    public ITagDropSourceData getTemplate()
102
    {
103
        return (ITagDropSourceData) super.getTemplate();
104
    }
105
106
    public IDropSourceData getDropSourceData()
107
    {
108
        return getTemplate();
109
    }
73
}
110
}
(-)src/org/eclipse/jst/pagedesigner/editors/palette/DesignerPaletteViewerProvider.java (-2 / +2 lines)
Lines 12-17 Link Here
12
package org.eclipse.jst.pagedesigner.editors.palette;
12
package org.eclipse.jst.pagedesigner.editors.palette;
13
13
14
import org.eclipse.gef.EditDomain;
14
import org.eclipse.gef.EditDomain;
15
import org.eclipse.gef.dnd.TemplateTransferDragSourceListener;
15
import org.eclipse.gef.internal.ui.palette.editparts.DrawerEditPart;
16
import org.eclipse.gef.internal.ui.palette.editparts.DrawerEditPart;
16
import org.eclipse.gef.ui.palette.PaletteContextMenuProvider;
17
import org.eclipse.gef.ui.palette.PaletteContextMenuProvider;
17
import org.eclipse.gef.ui.palette.PaletteViewer;
18
import org.eclipse.gef.ui.palette.PaletteViewer;
Lines 20-26 Link Here
20
import org.eclipse.jface.action.IMenuManager;
21
import org.eclipse.jface.action.IMenuManager;
21
import org.eclipse.jface.viewers.StructuredSelection;
22
import org.eclipse.jface.viewers.StructuredSelection;
22
import org.eclipse.jst.pagedesigner.PDPlugin;
23
import org.eclipse.jst.pagedesigner.PDPlugin;
23
import org.eclipse.jst.pagedesigner.dnd.internal.DesignerTemplateTransferDragSourceListener;
24
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer;
24
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer;
25
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.ui.PlatformUI;
26
import org.eclipse.ui.PlatformUI;
Lines 56-62 Link Here
56
56
57
		// XXX: should only use the following when we use Template
57
		// XXX: should only use the following when we use Template
58
		viewer
58
		viewer
59
				.addDragSourceListener(new DesignerTemplateTransferDragSourceListener(
59
				.addDragSourceListener(new TemplateTransferDragSourceListener(
60
						viewer));
60
						viewer));
61
	}
61
	}
62
62
(-)src/org/eclipse/jst/pagedesigner/itemcreation/internal/TagCreationFactory.java (-3 / +1 lines)
Lines 19-27 Link Here
19
19
20
/**
20
/**
21
 * Creates instances of
21
 * Creates instances of
22
 * {@link org.eclipse.jst.pagedesigner.itemcreation.ITagCreator}s for a the
22
 * {@link org.eclipse.jst.pagedesigner.itemcreation.ITagCreator}s 
23
 * given
24
 * {@link org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry}
25
 * (Eventually) Will use TagCreavtorFactories registered using
23
 * (Eventually) Will use TagCreavtorFactories registered using
26
 * org.eclipse.jst.jsf.pagedesigner.tagcreationfactories ext-pt. Currently only
24
 * org.eclipse.jst.jsf.pagedesigner.tagcreationfactories ext-pt. Currently only
27
 * using DefaultTagCreator.
25
 * using DefaultTagCreator.
(-)src/org/eclipse/jst/pagedesigner/itemcreation/customizer/DropCustomizationController.java (-9 / +7 lines)
Lines 9-14 Link Here
9
import org.eclipse.jst.pagedesigner.PDPlugin;
9
import org.eclipse.jst.pagedesigner.PDPlugin;
10
import org.eclipse.jst.pagedesigner.commands.ICustomizableCommand;
10
import org.eclipse.jst.pagedesigner.commands.ICustomizableCommand;
11
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
11
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
12
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceData;
12
import org.eclipse.jst.pagedesigner.elementedit.ElementEditFactoryRegistry;
13
import org.eclipse.jst.pagedesigner.elementedit.ElementEditFactoryRegistry;
13
import org.eclipse.jst.pagedesigner.elementedit.IElementEdit;
14
import org.eclipse.jst.pagedesigner.elementedit.IElementEdit;
14
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
15
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
Lines 23-46 Link Here
23
public final class DropCustomizationController
24
public final class DropCustomizationController
24
{
25
{
25
    private final ICustomizableCommand _command;
26
    private final ICustomizableCommand _command;
26
    private final String _uri;
27
    private final IDropSourceData  _dropSourceData;
27
    private final String _name;
28
    private final IDOMDocument  _domDocument;
28
    private final IDOMDocument  _domDocument;
29
    private final IDOMPosition _domPosition;
29
    private final IDOMPosition _domPosition;
30
30
31
    /**
31
    /**
32
     * @param command
32
     * @param command
33
     * @param uri
33
     * @param dropSourceData 
34
     * @param name
35
     * @param domDocument 
34
     * @param domDocument 
36
     * @param domPosition 
35
     * @param domPosition 
37
     */
36
     */
38
    public DropCustomizationController(final ICustomizableCommand command,
37
    public DropCustomizationController(final ICustomizableCommand command,
39
            final String uri, final String name, final IDOMDocument domDocument, final IDOMPosition domPosition)
38
            final IDropSourceData dropSourceData, final IDOMDocument domDocument, final IDOMPosition domPosition)
40
    {
39
    {
41
        _command = command;
40
        _command = command;
42
        _uri = uri;
41
        _dropSourceData = dropSourceData;
43
        _name = name;
44
        _domDocument = domDocument;
42
        _domDocument = domDocument;
45
        _domPosition = domPosition;
43
        _domPosition = domPosition;
46
    }
44
    }
Lines 51-64 Link Here
51
    public IStatus performCustomization()
49
    public IStatus performCustomization()
52
    {
50
    {
53
        final TagIdentifier tagId = TagIdentifierFactory.createJSPTagWrapper(
51
        final TagIdentifier tagId = TagIdentifierFactory.createJSPTagWrapper(
54
                _uri, _name);
52
                _dropSourceData.getURI(), _dropSourceData.getTagName());
55
        final IElementEdit elementEdit = ElementEditFactoryRegistry.getInstance()
53
        final IElementEdit elementEdit = ElementEditFactoryRegistry.getInstance()
56
                .createElementEdit(tagId);
54
                .createElementEdit(tagId);
57
55
58
        IStatus status = Status.OK_STATUS;
56
        IStatus status = Status.OK_STATUS;
59
        if (elementEdit != null)
57
        if (elementEdit != null)
60
        {
58
        {
61
            final IDropCustomizer customizer = elementEdit.getDropCustomizer(tagId);
59
            final IDropCustomizer customizer = elementEdit.getDropCustomizer(_dropSourceData);
62
60
63
            if (customizer != null)
61
            if (customizer != null)
64
            {
62
            {
(-)src/org/eclipse/jst/pagedesigner/dom/ValidatorSupport.java (-29 / +21 lines)
Lines 17-28 Link Here
17
import org.eclipse.jst.jsf.core.internal.tld.CMUtil;
17
import org.eclipse.jst.jsf.core.internal.tld.CMUtil;
18
import org.eclipse.jst.pagedesigner.adapters.IBodyInfo;
18
import org.eclipse.jst.pagedesigner.adapters.IBodyInfo;
19
import org.eclipse.jst.pagedesigner.adapters.internal.BodyInfo;
19
import org.eclipse.jst.pagedesigner.adapters.internal.BodyInfo;
20
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
20
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
21
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteItemManager;
22
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer;
23
import org.eclipse.jst.pagedesigner.utils.CommandUtil;
21
import org.eclipse.jst.pagedesigner.utils.CommandUtil;
24
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
22
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
25
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
26
import org.w3c.dom.Element;
23
import org.w3c.dom.Element;
27
import org.w3c.dom.Node;
24
import org.w3c.dom.Node;
28
import org.w3c.dom.Text;
25
import org.w3c.dom.Text;
Lines 89-120 Link Here
89
		return false;
86
		return false;
90
	}
87
	}
91
88
92
	/**
89
    /**
93
	 * @param position
90
     * @param position
94
	 * @param container
91
     * @param model 
95
	 * @param customizationData 
92
     * @param creationProvider 
96
	 * @return the new dom position for the inserted container or null if could
93
     * @param customizationData
97
	 * not insert
94
     * @return the new dom position for the inserted container or null if could
98
	 */
95
     *         not insert
99
	public static IDOMPosition insertContainer(IDOMPosition position,
96
     */
100
			QName container, IAdaptable customizationData) {
97
    public static IDOMPosition insertContainer(final IDOMPosition position,
101
		final TaglibPaletteDrawer category = 
98
            final IDOMModel model,
102
		    PaletteItemManager.getCurrentInstance().findCategoryByURI
99
            final ITagDropSourceData creationProvider, final IAdaptable customizationData)
103
		        (container.getNamespaceURI());
100
    {
104
		if (category != null){
101
        final Element newContainer = CommandUtil.executeInsertion(
105
			final TagToolPaletteEntry tagItem = 
102
                creationProvider, model, position, customizationData);
106
			    category.getTagPaletteEntryByTagName(container.getLocalPart());
103
        if (newContainer != null)
107
			final IDOMModel model = 
104
        {
108
			    ((IDOMNode) position.getContainerNode()).getModel();
105
            DOMPosition pos = new DOMPosition(newContainer, 0);
109
			final Element form = CommandUtil.excuteInsertion
106
            return pos;
110
			    (tagItem, model, position, customizationData);
107
        }
111
			if (form != null) {
112
				DOMPosition pos = new DOMPosition(form, 0);
113
				return pos;
114
			}
115
		}
116
        return null;
108
        return null;
117
	}
109
    }
118
110
119
	/**
111
	/**
120
	 * @return the body info
112
	 * @return the body info
(-)src/org/eclipse/jst/pagedesigner/elementedit/IElementEdit.java (+8 lines)
Lines 15-20 Link Here
15
import org.eclipse.jface.action.IMenuManager;
15
import org.eclipse.jface.action.IMenuManager;
16
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
17
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
18
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceData;
18
import org.eclipse.jst.pagedesigner.itemcreation.ITagCreator;
19
import org.eclipse.jst.pagedesigner.itemcreation.ITagCreator;
19
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IDropCustomizer;
20
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IDropCustomizer;
20
import org.eclipse.jst.pagedesigner.parts.ElementEditPart;
21
import org.eclipse.jst.pagedesigner.parts.ElementEditPart;
Lines 112-121 Link Here
112
     * Returning null and returning a IDropCustomizer whose runCustomizer always returns
113
     * Returning null and returning a IDropCustomizer whose runCustomizer always returns
113
     * OK and getDropCustomizationData always returns null will be considered
114
     * OK and getDropCustomizationData always returns null will be considered
114
     * equivalent by the framework.
115
     * equivalent by the framework.
116
     * @deprecated use getDropCustomizer(IDropSourceData) instead
115
     */
117
     */
116
    public IDropCustomizer getDropCustomizer(TagIdentifier tagId);
118
    public IDropCustomizer getDropCustomizer(TagIdentifier tagId);
117
119
118
    /**
120
    /**
121
     * @param dropSourceData
122
     * @return the drop customizer for the drop source data or null if none.
123
     */
124
    public IDropCustomizer getDropCustomizer(final IDropSourceData dropSourceData);
125
126
    /**
119
     * @param tagId
127
     * @param tagId
120
     * @return a tag creator for the indicated tag or null to indicate that the
128
     * @return a tag creator for the indicated tag or null to indicate that the
121
     * system should use it's default tag creator
129
     * system should use it's default tag creator
(-)src/org/eclipse/jst/pagedesigner/elementedit/AbstractElementEdit.java (+19 lines)
Lines 16-21 Link Here
16
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
17
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
18
import org.eclipse.jst.jsf.core.internal.tld.CMUtil;
18
import org.eclipse.jst.jsf.core.internal.tld.CMUtil;
19
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
20
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceData;
21
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
19
import org.eclipse.jst.pagedesigner.itemcreation.ITagCreator;
22
import org.eclipse.jst.pagedesigner.itemcreation.ITagCreator;
20
import org.eclipse.jst.pagedesigner.itemcreation.customizer.AbstractDropCustomizer;
23
import org.eclipse.jst.pagedesigner.itemcreation.customizer.AbstractDropCustomizer;
21
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IDropCustomizer;
24
import org.eclipse.jst.pagedesigner.itemcreation.customizer.IDropCustomizer;
Lines 105-115 Link Here
105
    private final static IDropCustomizer   DEFAULT_DROP_CUSTOMIZER = 
108
    private final static IDropCustomizer   DEFAULT_DROP_CUSTOMIZER = 
106
        new AbstractDropCustomizer(){/* do nothing; use defaults */};
109
        new AbstractDropCustomizer(){/* do nothing; use defaults */};
107
    
110
    
111
    /** (non-Javadoc)
112
     * @see org.eclipse.jst.pagedesigner.elementedit.IElementEdit#getDropCustomizer(org.eclipse.jst.jsf.common.dom.TagIdentifier)
113
     * @deprecated use getDropCustomizer(IDropSourceData) instead.
114
     */
108
    public IDropCustomizer getDropCustomizer(TagIdentifier tagId) 
115
    public IDropCustomizer getDropCustomizer(TagIdentifier tagId) 
109
    {
116
    {
110
        return DEFAULT_DROP_CUSTOMIZER;
117
        return DEFAULT_DROP_CUSTOMIZER;
111
    }
118
    }
112
119
120
    public IDropCustomizer getDropCustomizer(IDropSourceData dropSourceData)
121
    {
122
        if (dropSourceData instanceof ITagDropSourceData)
123
        {
124
            final String uri = ((ITagDropSourceData)dropSourceData).getURI();
125
            final String tagName = ((ITagDropSourceData)dropSourceData).getTagName();
126
            final TagIdentifier tagId = TagIdentifierFactory.createJSPTagWrapper(uri, tagName);
127
            return getDropCustomizer(tagId);
128
        }
129
        return DEFAULT_DROP_CUSTOMIZER;
130
    }
131
113
    /* (non-Javadoc)
132
    /* (non-Javadoc)
114
     * @see org.eclipse.jst.pagedesigner.elementedit.IElementEdit#getTagCreator(org.eclipse.jst.jsf.common.dom.TagIdentifier)
133
     * @see org.eclipse.jst.pagedesigner.elementedit.IElementEdit#getTagCreator(org.eclipse.jst.jsf.common.dom.TagIdentifier)
115
     */
134
     */
(-)src/org/eclipse/jst/pagedesigner/commands/PaletteDropInsertCommand.java (-22 / +24 lines)
Lines 19-25 Link Here
19
import org.eclipse.jst.pagedesigner.dom.DOMPosition;
19
import org.eclipse.jst.pagedesigner.dom.DOMPosition;
20
import org.eclipse.jst.pagedesigner.dom.EditModelQuery;
20
import org.eclipse.jst.pagedesigner.dom.EditModelQuery;
21
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
21
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
22
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
22
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceData;
23
import org.eclipse.jst.pagedesigner.itemcreation.customizer.DropCustomizationController;
23
import org.eclipse.jst.pagedesigner.itemcreation.customizer.DropCustomizationController;
24
import org.eclipse.jst.pagedesigner.utils.CommandUtil;
24
import org.eclipse.jst.pagedesigner.utils.CommandUtil;
25
import org.eclipse.wst.sse.ui.StructuredTextEditor;
25
import org.eclipse.wst.sse.ui.StructuredTextEditor;
Lines 38-44 Link Here
38
	private final Logger _log = PDPlugin
38
	private final Logger _log = PDPlugin
39
			.getLogger(PaletteDropInsertCommand.class);
39
			.getLogger(PaletteDropInsertCommand.class);
40
40
41
	private TagToolPaletteEntry _tagItem;
41
	private IDropSourceData _creationProvider;
42
42
43
	private int _location;
43
	private int _location;
44
44
Lines 49-61 Link Here
49
	/**
49
	/**
50
	 * @param label
50
	 * @param label
51
	 * @param editor
51
	 * @param editor
52
	 * @param tagItem
52
	 * @param creationProvider
53
	 * @param location
53
	 * @param location
54
	 */
54
	 */
55
	public PaletteDropInsertCommand(String label, StructuredTextEditor editor,
55
	public PaletteDropInsertCommand(String label, StructuredTextEditor editor,
56
			TagToolPaletteEntry tagItem, int location) {
56
			IDropSourceData creationProvider, int location) {
57
		super(label, editor);
57
		super(label, editor);
58
		_tagItem = tagItem;
58
		_creationProvider = creationProvider;
59
		_location = location;
59
		_location = location;
60
	}
60
	}
61
61
Lines 84-103 Link Here
84
			}
84
			}
85
		}
85
		}
86
86
87
		//essentially copied from ItemCreationTool so that DesignView drop and SourceViewDrop are same.
87
        // essentially copied from ItemCreationTool so that DesignView drop and
88
		// Note that SourceView does NO drop validation checking.   This is handled by ItemCreationPolicy in DesignView
88
        // SourceViewDrop are same.
89
		final IStatus status = 
89
        // Note that SourceView does NO drop validation checking. This is
90
		    performCustomization(getModel().getDocument(), position);
90
        // handled by ItemCreationPolicy in DesignView
91
91
        final IStatus status = performCustomization(getModel().getDocument(),
92
		if (status.getSeverity() == IStatus.OK) {
92
                position);
93
			Element element = CommandUtil.excuteInsertion(this._tagItem,
93
94
					getModel(), position, getCustomizationData());
94
        if (status.isOK()) 
95
			if (element != null) {				
95
        {
96
				formatNode(element);
96
            final Element element = CommandUtil.executeInsertion(
97
			}
97
                    _creationProvider, getModel()
98
			this._element = element;
98
                    , position, getCustomizationData());
99
		}
99
            if (element != null) {
100
	}
100
                formatNode(element);
101
            }
102
            this._element = element;
103
        }
104
    }
101
105
102
	/**
106
	/**
103
     * @param domDoc 
107
     * @param domDoc 
Lines 105-113 Link Here
105
     * @return status
109
     * @return status
106
	 */
110
	 */
107
	protected IStatus performCustomization(final IDOMDocument domDoc, final IDOMPosition position) {
111
	protected IStatus performCustomization(final IDOMDocument domDoc, final IDOMPosition position) {
108
		final String  uri = _tagItem.getURI();
112
		return new DropCustomizationController(this, _creationProvider, domDoc, position).performCustomization();
109
		final String name = _tagItem.getTagName();
110
		return new DropCustomizationController(this, uri, name, domDoc, position).performCustomization();
111
	}
113
	}
112
114
113
    /**
115
    /**
(-)src/org/eclipse/jst/pagedesigner/commands/CreateItemCommand.java (-46 / +48 lines)
Lines 14-20 Link Here
14
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.IAdaptable;
15
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
16
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
17
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
17
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceData;
18
import org.eclipse.jst.pagedesigner.utils.CommandUtil;
18
import org.eclipse.jst.pagedesigner.utils.CommandUtil;
19
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
19
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
20
import org.w3c.dom.Element;
20
import org.w3c.dom.Element;
Lines 24-79 Link Here
24
 */
24
 */
25
public class CreateItemCommand extends DesignerCommand implements ICustomizableCommand 
25
public class CreateItemCommand extends DesignerCommand implements ICustomizableCommand 
26
{
26
{
27
	private final IDOMPosition _position;
27
    private final IDOMPosition _position;
28
    private final IDropSourceData _creationProvider;
29
    private Element _ele;
30
    private IAdaptable _customizationData;
28
31
29
	private final TagToolPaletteEntry _tagItem;
32
    /**
30
	private Element _ele;
33
     * @param label
31
	private IAdaptable _customizationData;
34
     * @param model
32
35
     * @param position
33
	/**
36
     * @param creationProvider
34
	 * @param label
37
     */
35
	 * @param model 
38
    public CreateItemCommand(String label, IDOMModel model,
36
	 * @param position 
39
            IDOMPosition position, IDropSourceData creationProvider) {
37
	 * @param tagItem 
40
        super(label, model.getDocument());
38
	 */
41
        this._position = position;
39
	public CreateItemCommand(String label, IDOMModel model,
42
        this._creationProvider = creationProvider;
40
			IDOMPosition position, TagToolPaletteEntry tagItem) {
43
    }
41
		super(label, model.getDocument());
44
42
		this._position = position;
45
    /**
43
		this._tagItem = tagItem;
46
     * @return the dom position for the drop
44
	}
47
     */
45
48
    public IDOMPosition getPosition()
46
	
47
	/**
48
	 * @return the dom position for the drop
49
	 */
50
	public IDOMPosition getPosition()
51
    {
49
    {
52
        return _position;
50
        return _position;
53
    }
51
    }
54
52
55
53
56
    /*
54
    /*
57
	 * (non-Javadoc)
55
     * (non-Javadoc)
58
	 * 
56
     * 
59
	 * @see org.eclipse.jst.pagedesigner.commands.DesignerCommand#doExecute()
57
     * @see org.eclipse.jst.pagedesigner.commands.DesignerCommand#doExecute()
60
	 */
58
     */
61
	protected void doExecute() {
59
    protected void doExecute() 
62
		Element element = CommandUtil.excuteInsertion(this._tagItem,
60
    {
63
				getModel(), this._position, this._customizationData);
61
        Element element = CommandUtil.executeInsertion(
64
		if (element != null) {
62
                _creationProvider,
65
			formatNode(element);
63
                getModel(), this._position, this._customizationData);
66
		}
64
        if (element != null) 
67
		this._ele = element;
65
        {
68
	}
66
            formatNode(element);
67
        }
68
        this._ele = element;
69
    }
69
70
70
	@Override
71
    @Override
71
    protected void postPostExecute() 
72
    protected void postPostExecute() 
72
	{
73
    {
73
        // during JUnit testing, we may not have viewer.
74
        // during JUnit testing, we may not have viewer.
74
        // this will cause us not to have undo support,
75
        // this will cause us not to have undo support,
75
        // but should not effect testing for this command
76
        // but should not effect testing for this command
76
	    if (getViewer() != null)
77
        if (getViewer() != null)
77
        {
78
        {
78
            super.postPostExecute();
79
            super.postPostExecute();
79
        }
80
        }
Lines 94-106 Link Here
94
    }
95
    }
95
96
96
    /*
97
    /*
97
	 * (non-Javadoc)
98
     * (non-Javadoc)
98
	 * 
99
     * 
99
	 * @see org.eclipse.jst.pagedesigner.commands.DesignerCommand#getAfterCommandDesignerSelection()
100
     * @seeorg.eclipse.jst.pagedesigner.commands.DesignerCommand#
100
	 */
101
     * getAfterCommandDesignerSelection()
101
	protected ISelection getAfterCommandDesignerSelection() {
102
     */
102
		return toDesignSelection(_ele);
103
    protected ISelection getAfterCommandDesignerSelection() {
103
	}
104
        return toDesignSelection(_ele);
105
    }
104
106
105
    /**
107
    /**
106
     * @param customizationData
108
     * @param customizationData
(-)src/org/eclipse/jst/pagedesigner/editors/palette/impl/PaletteElementTemplateHelper.java (-12 / +9 lines)
Lines 21-29 Link Here
21
import javax.xml.parsers.ParserConfigurationException;
21
import javax.xml.parsers.ParserConfigurationException;
22
22
23
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
23
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
24
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationInfo;
25
import org.eclipse.jst.pagedesigner.PDPlugin;
24
import org.eclipse.jst.pagedesigner.PDPlugin;
26
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
25
import org.eclipse.jst.pagedesigner.editors.palette.MetadataTagDropSourceData;
27
import org.eclipse.jst.pagedesigner.utils.JSPUtil;
26
import org.eclipse.jst.pagedesigner.utils.JSPUtil;
28
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
27
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
29
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
28
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
Lines 54-69 Link Here
54
	 * 
53
	 * 
55
	 * @param model
54
	 * @param model
56
	 * @param element
55
	 * @param element
57
	 * @param tagItem
56
	 * @param creationProvider 
58
	 * @param tagCreationInfo 
59
	 */
57
	 */
60
	public static void applyTemplate(IDOMModel model, Element element,
58
	public static void applyTemplate(IDOMModel model, Element element,
61
			TagToolPaletteEntry tagItem, TagCreationInfo tagCreationInfo) {
59
	        MetadataTagDropSourceData creationProvider) {
62
		if (element == null || element.getLocalName() == null) {
60
		if (element == null || element.getLocalName() == null) {
63
			return;
61
			return;
64
		}
62
		}
65
		
63
		
66
		Node[] templateNodes = getTemplateNodes(model,  tagCreationInfo);
64
		Node[] templateNodes = getTemplateNodes(model,  creationProvider);
67
		if (templateNodes != null) {
65
		if (templateNodes != null) {
68
			for (int i=0;i<templateNodes.length;i++){
66
			for (int i=0;i<templateNodes.length;i++){
69
				Node anode = templateNodes[i];
67
				Node anode = templateNodes[i];
Lines 73-84 Link Here
73
	}
71
	}
74
72
75
	private static Node[] getTemplateNodes(IDOMModel model,
73
	private static Node[] getTemplateNodes(IDOMModel model,
76
			TagCreationInfo tagCreationInfo) {
74
	        MetadataTagDropSourceData creationProvider) {
77
75
78
		if (tagCreationInfo == null)
76
		if (creationProvider == null)
79
			return null;
77
			return null;
80
		
78
		
81
		String template = (String)tagCreationInfo.getTemplate();
79
		String template = creationProvider.getTemplate();
82
		if (template != null){
80
		if (template != null){
83
			
81
			
84
			final String nodeStr = prepareNode(template);//(String)template.getTemplate();
82
			final String nodeStr = prepareNode(template);//(String)template.getTemplate();
Lines 91-97 Link Here
91
				Document doc = builder.parse(new ByteArrayInputStream( nodeStr.getBytes()));
89
				Document doc = builder.parse(new ByteArrayInputStream( nodeStr.getBytes()));
92
				Node beginNode = doc.getFirstChild();
90
				Node beginNode = doc.getFirstChild();
93
				Node templateNode = beginNode.cloneNode(true);//model.getDocument().importNode(beginNode, true);
91
				Node templateNode = beginNode.cloneNode(true);//model.getDocument().importNode(beginNode, true);
94
				Node[] templateNodes = applyPrefixes(model, tagCreationInfo, templateNode.getChildNodes(), model.getDocument());
92
				Node[] templateNodes = applyPrefixes(model, templateNode.getChildNodes(), model.getDocument());
95
				return templateNodes;
93
				return templateNodes;
96
			} catch (ParserConfigurationException e) {
94
			} catch (ParserConfigurationException e) {
97
			    logger.error(e);
95
			    logger.error(e);
Lines 121-133 Link Here
121
	 * Use the actrual prefixs of jsf html and jsf core to set the prefix of
119
	 * Use the actrual prefixs of jsf html and jsf core to set the prefix of
122
	 * each node declared in template.
120
	 * each node declared in template.
123
	 * @param model 
121
	 * @param model 
124
	 * @param info 
125
	 * @param templateNodes 
122
	 * @param templateNodes 
126
	 * @param document 
123
	 * @param document 
127
	 * @return Node[]
124
	 * @return Node[]
128
	 * 
125
	 * 
129
	 */
126
	 */
130
	public static Node[] applyPrefixes(IDOMModel model, TagCreationInfo info,
127
	public static Node[] applyPrefixes(IDOMModel model, 
131
			NodeList templateNodes, Document document) {
128
			NodeList templateNodes, Document document) {
132
		List result = new ArrayList();
129
		List result = new ArrayList();
133
		for (int i = 0, n = templateNodes.getLength(); i < n; i++) {
130
		for (int i = 0, n = templateNodes.getLength(); i < n; i++) {
(-)src/org/eclipse/jst/pagedesigner/editors/palette/impl/PaletteHelper.java (-1 / +4 lines)
Lines 38-43 Link Here
38
import org.eclipse.jst.pagedesigner.IHTMLConstants;
38
import org.eclipse.jst.pagedesigner.IHTMLConstants;
39
import org.eclipse.jst.pagedesigner.PDPlugin;
39
import org.eclipse.jst.pagedesigner.PDPlugin;
40
import org.eclipse.jst.pagedesigner.editors.palette.IPaletteItemManager;
40
import org.eclipse.jst.pagedesigner.editors.palette.IPaletteItemManager;
41
import org.eclipse.jst.pagedesigner.editors.palette.ITagDropSourceData;
42
import org.eclipse.jst.pagedesigner.editors.palette.TagToolCreationAdapter;
41
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
43
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
42
import org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument;
44
import org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument;
43
import org.eclipse.wst.html.core.internal.contentmodel.JSPCMDocument;
45
import org.eclipse.wst.html.core.internal.contentmodel.JSPCMDocument;
Lines 304-310 Link Here
304
	}
306
	}
305
307
306
	private static TagToolPaletteEntry internalCreateTagEntry(TaglibPaletteDrawer category, String id, String tagName, String label, String desc, ImageDescriptor smallIcon, ImageDescriptor largeIcon, boolean expert){
308
	private static TagToolPaletteEntry internalCreateTagEntry(TaglibPaletteDrawer category, String id, String tagName, String label, String desc, ImageDescriptor smallIcon, ImageDescriptor largeIcon, boolean expert){
307
		TagToolPaletteEntry item = new TagToolPaletteEntry(tagName, label, desc, smallIcon, largeIcon);
309
	    final ITagDropSourceData  data = new TagToolCreationAdapter(category.getURI(), tagName, category.getDefaultPrefix(), id);
310
		final TagToolPaletteEntry item = new TagToolPaletteEntry(data, label, desc, smallIcon, largeIcon);
308
		item.setId(id);
311
		item.setId(id);
309
		
312
		
310
		item.setVisible(!expert);
313
		item.setVisible(!expert);
(-)src/org/eclipse/jst/pagedesigner/editpolicies/DropEditPolicy.java (-3 / +5 lines)
Lines 22-28 Link Here
22
import org.eclipse.gef.requests.GroupRequest;
22
import org.eclipse.gef.requests.GroupRequest;
23
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
23
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
24
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
24
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
25
import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
25
import org.eclipse.jst.pagedesigner.editors.palette.IDropSourceData;
26
import org.eclipse.jst.pagedesigner.elementedit.ElementEditFactoryRegistry;
26
import org.eclipse.jst.pagedesigner.elementedit.ElementEditFactoryRegistry;
27
import org.eclipse.jst.pagedesigner.elementedit.IElementEdit;
27
import org.eclipse.jst.pagedesigner.elementedit.IElementEdit;
28
import org.eclipse.jst.pagedesigner.itemcreation.ItemCreationRequest;
28
import org.eclipse.jst.pagedesigner.itemcreation.ItemCreationRequest;
Lines 116-125 Link Here
116
        }
116
        }
117
        else if (request instanceof ItemCreationRequest)
117
        else if (request instanceof ItemCreationRequest)
118
        {
118
        {
119
        	TagToolPaletteEntry desc = ((ItemCreationRequest)request).getTagToolPaletteEntry();
119
            IDropSourceData creationProvider = 
120
                ((ItemCreationRequest)request).getTagCreationProvider();
120
            TagIdentifier tagId = 
121
            TagIdentifier tagId = 
121
                TagIdentifierFactory.
122
                TagIdentifierFactory.
122
                    createJSPTagWrapper(desc.getURI(), desc.getTagName());
123
                    createJSPTagWrapper(creationProvider.getURI(),
124
                            creationProvider.getTagName());
123
            List tagIds = new ArrayList();
125
            List tagIds = new ArrayList();
124
            tagIds.add(tagId);
126
            tagIds.add(tagId);
125
            return new DropData(tagIds);
127
            return new DropData(tagIds);
(-)src/org/eclipse/jst/pagedesigner/editors/SimpleGraphicalEditor.java (-3 / +15 lines)
Lines 24-29 Link Here
24
import org.eclipse.gef.DefaultEditDomain;
24
import org.eclipse.gef.DefaultEditDomain;
25
import org.eclipse.gef.EditPart;
25
import org.eclipse.gef.EditPart;
26
import org.eclipse.gef.GraphicalViewer;
26
import org.eclipse.gef.GraphicalViewer;
27
import org.eclipse.gef.dnd.TemplateTransferDragSourceListener;
27
import org.eclipse.gef.editparts.ScalableRootEditPart;
28
import org.eclipse.gef.editparts.ScalableRootEditPart;
28
import org.eclipse.gef.palette.PaletteRoot;
29
import org.eclipse.gef.palette.PaletteRoot;
29
import org.eclipse.gef.ui.actions.ActionRegistry;
30
import org.eclipse.gef.ui.actions.ActionRegistry;
Lines 51-57 Link Here
51
import org.eclipse.jst.pagedesigner.commands.CutAction;
52
import org.eclipse.jst.pagedesigner.commands.CutAction;
52
import org.eclipse.jst.pagedesigner.commands.DeleteAction;
53
import org.eclipse.jst.pagedesigner.commands.DeleteAction;
53
import org.eclipse.jst.pagedesigner.commands.PasteAction;
54
import org.eclipse.jst.pagedesigner.commands.PasteAction;
54
import org.eclipse.jst.pagedesigner.dnd.internal.DesignerTemplateTransferDragSourceListener;
55
import org.eclipse.jst.pagedesigner.dnd.internal.LocalSelectionDropTargetListener;
55
import org.eclipse.jst.pagedesigner.dnd.internal.LocalSelectionDropTargetListener;
56
import org.eclipse.jst.pagedesigner.dnd.internal.PDTemplateTransferDropTargetListener;
56
import org.eclipse.jst.pagedesigner.dnd.internal.PDTemplateTransferDropTargetListener;
57
import org.eclipse.jst.pagedesigner.dnd.internal.ResouceDropTargetListener;
57
import org.eclipse.jst.pagedesigner.dnd.internal.ResouceDropTargetListener;
Lines 149-154 Link Here
149
149
150
	private PaletteViewerProvider _paletteViewerProvider;
150
	private PaletteViewerProvider _paletteViewerProvider;
151
151
152
	/**
153
	 * TODO: why isn't this private?
154
	 */
152
	protected IPaletteFactory _paletteViewerPageFactory;
155
	protected IPaletteFactory _paletteViewerPageFactory;
153
156
154
	/**
157
	/**
Lines 509-515 Link Here
509
    					// from the palette into the editor
512
    					// from the palette into the editor
510
    					// @see ShapesEditor#createTransferDropTargetListener()
513
    					// @see ShapesEditor#createTransferDropTargetListener()
511
    					viewer
514
    					viewer
512
    							.addDragSourceListener(new DesignerTemplateTransferDragSourceListener(
515
    							.addDragSourceListener(new TemplateTransferDragSourceListener(
513
    									viewer));
516
    									viewer));
514
    				}
517
    				}
515
    			};
518
    			};
Lines 518-523 Link Here
518
    	return _paletteViewerProvider;
521
    	return _paletteViewerProvider;
519
    }
522
    }
520
523
524
    /**
525
     * @return the palette viewer page
526
     */
521
    protected PaletteViewerPage createPaletteViewerPage() {
527
    protected PaletteViewerPage createPaletteViewerPage() {
522
        if (_paletteViewerPageFactory != null) {
528
        if (_paletteViewerPageFactory != null) {
523
        	_paletteViewerPage = _paletteViewerPageFactory.createPaletteViewerPage(createPaletteViewerProvider());
529
        	_paletteViewerPage = _paletteViewerPageFactory.createPaletteViewerPage(createPaletteViewerProvider());
Lines 738-744 Link Here
738
				if (project != null) {
744
				if (project != null) {
739
					SkinsMenuItemBuilder builder = new SkinsMenuItemBuilder(project);
745
					SkinsMenuItemBuilder builder = new SkinsMenuItemBuilder(project);
740
					builder.buildMenuManagers(menuMgr1);
746
					builder.buildMenuManagers(menuMgr1);
741
				}
747
        }
742
			}
748
			}
743
        }
749
        }
744
        
750
        
Lines 805-810 Link Here
805
    }
811
    }
806
812
807
    
813
    
814
    /**
815
     * @return the palette viewer page
816
     */
808
    public PaletteViewerPage getPaletteViewerPage() {
817
    public PaletteViewerPage getPaletteViewerPage() {
809
        if (_paletteViewerPage == null) {
818
        if (_paletteViewerPage == null) {
810
        	_paletteViewerPage = createPaletteViewerPage();
819
        	_paletteViewerPage = createPaletteViewerPage();
Lines 812-817 Link Here
812
		return _paletteViewerPage;
821
		return _paletteViewerPage;
813
	}
822
	}
814
823
824
    /**
825
     * @return the palette factory
826
     */
815
    protected IPaletteFactory initPaletteFactory()
827
    protected IPaletteFactory initPaletteFactory()
816
    {   	
828
    {   	
817
    	if (_paletteViewerPageFactory == null) {
829
    	if (_paletteViewerPageFactory == null) {
(-)src/org/eclipse/jst/pagedesigner/editors/palette/MetadataTagDropSourceData.java (+155 lines)
Added Link Here
1
/**
2
 * 
3
 */
4
package org.eclipse.jst.pagedesigner.editors.palette;
5
6
import java.util.List;
7
8
import org.eclipse.jst.jsf.common.metadata.Entity;
9
import org.eclipse.jst.jsf.common.metadata.Model;
10
import org.eclipse.jst.jsf.common.metadata.Trait;
11
import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext;
12
import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper;
13
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.PaletteInfo;
14
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.PaletteInfos;
15
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationAttribute;
16
import org.eclipse.jst.jsf.tagdisplay.internal.paletteinfos.TagCreationInfo;
17
import org.eclipse.jst.pagedesigner.utils.CommandUtil;
18
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
19
20
/**
21
 * A source data that is enhanced by metadata.
22
 * 
23
 * @author cbateman
24
 *
25
 */
26
public final class MetadataTagDropSourceData implements ITagDropSourceData
27
{
28
    private final IDOMModel _model;
29
    private final TagCreationInfo _tagCreationInfo;
30
    private final ITagDropSourceData _delegate;
31
32
    /**
33
     * @param creationProvider
34
     * @param model
35
     */
36
    public MetadataTagDropSourceData(
37
            final ITagDropSourceData creationProvider,
38
            final IDOMModel model)
39
    {
40
        _delegate = creationProvider;
41
        _model = model;
42
        _tagCreationInfo = getTagCreationInfo();
43
    }
44
45
    /**
46
     * @return the pre-defined attributes for the tag from meta-data or
47
     *  null if none.
48
     */
49
    public List<TagCreationAttribute> getAttributes()
50
    {
51
        if (_tagCreationInfo != null)
52
        {
53
            return _tagCreationInfo.getAttributes();
54
        }
55
        return null;
56
    }
57
58
    /**
59
     * @return the template derived from metadata for tag drop or null if none.
60
     */
61
    public String getTemplate()
62
    {
63
        if (_tagCreationInfo != null)
64
        {
65
            return (String) _tagCreationInfo.getTemplate();
66
        }
67
        return null;
68
    }
69
70
    public String getDefaultPrefix()
71
    {
72
        return _delegate.getDefaultPrefix();
73
    }
74
75
    public String getTagName()
76
    {
77
        return _delegate.getTagName();
78
    }
79
80
    public String getURI()
81
    {
82
        return _delegate.getURI();
83
    }
84
85
    private TagCreationInfo getTagCreationInfo()
86
    {
87
        final ITaglibDomainMetaDataModelContext metadataContext = CommandUtil
88
                .getMetadataContext(getURI(), _model);
89
        TagCreationInfo tagCreationInfo = null;
90
        String id = getId();
91
        if (metadataContext != null && id != null)
92
        {
93
            tagCreationInfo = createCreationInfo(metadataContext, id,
94
                    getTagName());
95
        }
96
        return tagCreationInfo;
97
    }
98
99
    public String getId()
100
    {
101
        return _delegate.getId();
102
    }
103
    
104
    /**
105
     * @param metaDataContext
106
     * @param id
107
     * @param tagName
108
     * @return a tag creation info for the tag and id in the metadata context
109
     */
110
    static TagCreationInfo createCreationInfo(
111
            final ITaglibDomainMetaDataModelContext metaDataContext,
112
            final String id, final String tagName)
113
    {
114
        final Model model = TaglibDomainMetaDataQueryHelper
115
                .getModel(metaDataContext);
116
        if (model != null)
117
        {
118
            Trait trait = TaglibDomainMetaDataQueryHelper.getTrait(model,
119
                    PaletteInfos.TRAIT_ID);
120
            if (trait != null)
121
            {
122
                final PaletteInfos pis = (PaletteInfos) trait.getValue();
123
                final PaletteInfo pi = pis.findPaletteInfoById(id);
124
                if (pi != null)
125
                {
126
                    return pi.getTagCreation();
127
                }
128
            }
129
            // tag-creation trait on entity directly?
130
            final Entity tag = getTagEntity(metaDataContext, tagName);
131
            if (tag != null)
132
            {// metadata exists
133
                trait = TaglibDomainMetaDataQueryHelper.getTrait(tag,
134
                        "tag-create"); //$NON-NLS-1$
135
                if (trait != null && trait.getValue() != null)
136
                {
137
                    return (TagCreationInfo) trait.getValue();
138
                }
139
            }
140
        }
141
        return null;
142
    }
143
    /**
144
     * @param metaDataContext
145
     * @param tagName
146
     * @return the {@link Entity} for this tag element being created
147
     */
148
    private static Entity getTagEntity(
149
            final ITaglibDomainMetaDataModelContext metaDataContext,
150
            final String tagName)
151
    {
152
        return TaglibDomainMetaDataQueryHelper.getEntity(metaDataContext,
153
                tagName);
154
    }
155
}
(-)src/org/eclipse/jst/pagedesigner/editors/palette/TagToolCreationAdapter.java (+104 lines)
Added Link Here
1
package org.eclipse.jst.pagedesigner.editors.palette;
2
3
4
import javax.xml.namespace.QName;
5
6
import org.eclipse.jst.pagedesigner.editors.palette.impl.PaletteItemManager;
7
import org.eclipse.jst.pagedesigner.editors.palette.impl.TaglibPaletteDrawer;
8
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
9
10
/**
11
 * Adapt a TagToolPaletteEntry to the ITagDropSourceData
12
 * 
13
 * @author cbateman
14
 * 
15
 */
16
public final class TagToolCreationAdapter implements ITagDropSourceData
17
{
18
    private String _uri;
19
    private String _tagName;
20
    private String _defaultPrefix;
21
    private String _id;
22
23
    /**
24
     * @param uri 
25
     * @param tagName 
26
     * @param defaultPrefix 
27
     * @param id 
28
     */
29
    public TagToolCreationAdapter(final String uri,  final String tagName, final String defaultPrefix,
30
            final String id)
31
    {
32
        _uri = uri;
33
        _tagName = tagName;
34
        _defaultPrefix = defaultPrefix;
35
        _id = id;
36
    }
37
38
    public String getDefaultPrefix()
39
    {
40
        return _defaultPrefix;
41
    }
42
43
    public String getTagName()
44
    {
45
        return _tagName;
46
    }
47
48
    public String getURI()
49
    {
50
        return _uri;
51
    }
52
53
    public String getId()
54
    {
55
        return _id;
56
    }
57
58
    /**
59
     * @param provider
60
     * @param model
61
     * @return a metadata tag creation adapter for an existing tag
62
     * creation provider (which need not itself be a TagToolCreationAdapter)
63
     * and a dom model.
64
     */
65
    public static MetadataTagDropSourceData createMdTagCreationProvider(final ITagDropSourceData provider, final IDOMModel model)
66
    {
67
        return new MetadataTagDropSourceData(provider, model);
68
    }
69
70
    /**
71
     * @param container
72
     * @return the tag creation provider
73
     */
74
    public static ITagDropSourceData findProviderForContainer(
75
            final QName container)
76
    {
77
        return findProviderForContainer(container.getNamespaceURI(), container
78
                .getLocalPart(), PaletteItemManager.getCurrentInstance());
79
    }
80
81
    /**
82
     * @param uri
83
     * @param tagName
84
     * @param itemManager
85
     * @return the tag creation provider
86
     */
87
    public static ITagDropSourceData findProviderForContainer(
88
            final String uri, final String tagName,
89
            final PaletteItemManager itemManager)
90
    {
91
        final TaglibPaletteDrawer category = itemManager.findCategoryByURI(uri);
92
        if (category != null)
93
        {
94
            final TagToolPaletteEntry tagItem = category
95
                    .getTagPaletteEntryByTagName(tagName);
96
            if (tagItem != null)
97
            {
98
                return tagItem.getTemplate();
99
            }
100
        }
101
        return null;
102
    }
103
104
}
(-)src/org/eclipse/jst/pagedesigner/editors/palette/ITagDropSourceData.java (+19 lines)
Added Link Here
1
package org.eclipse.jst.pagedesigner.editors.palette;
2
3
4
/**
5
 * Provides generic information for tag creation from a palette drop.
6
 * 
7
 * @author cbateman
8
 * 
9
 */
10
public interface ITagDropSourceData extends IDropSourceData
11
{
12
    /**
13
     * Convenience method returning the tag libraries default prefix, if
14
     * applicable
15
     * 
16
     * @return default prefix
17
     */
18
    public String getDefaultPrefix();
19
}
(-)src/org/eclipse/jst/pagedesigner/editors/palette/IDropSourceData.java (+26 lines)
Added Link Here
1
package org.eclipse.jst.pagedesigner.editors.palette;
2
3
/**
4
 * Data describing a palette drop.
5
 * 
6
 * @author cbateman
7
 *
8
 */
9
public interface IDropSourceData
10
{
11
    /**
12
     * @return uri of the tag's library
13
     */
14
    public String getURI();
15
    /**
16
     * @return tagName
17
     */
18
    public String getTagName();
19
    /**
20
     * Optional value.
21
     * 
22
     * @return a unique id for a tag creation provider that may be different
23
     * from the uri. MAY BE NULL.
24
     */
25
    public String getId();
26
}
(-)src/org/eclipse/jst/pagedesigner/editors/palette/IDropSourceDataProvider.java (+16 lines)
Added Link Here
1
package org.eclipse.jst.pagedesigner.editors.palette;
2
3
/**
4
 * Used by objects (usually palette entries) that wish provide drop source data
5
 * to a client.
6
 * 
7
 * @author cbateman
8
 *
9
 */
10
public interface IDropSourceDataProvider
11
{
12
    /**
13
     * @return a drop source data in context
14
     */
15
    IDropSourceData  getDropSourceData();
16
}

Return to bug 267962