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/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/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/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();

Return to bug 267962