Home » Language IDEs » ServerTools (WTP) » WPE : Drop location is not properly identified
| | | | |
Re: WPE : Drop location is not properly identified [message #666079 is a reply to message #665905] |
Tue, 19 April 2011 00:50 |
Ani Messages: 37 Registered: November 2010 |
Member |
|
|
Initially my requirement was to use some of the eclipse's HTML palette components and add some of my own custom comps,
but i did not find it feasible,
so i replaced the whole palette with my custom one.this is how i'm adding my compos to the palette
PaletteDrawer componentsDrawer = new PaletteDrawer("Standard Components");
TagToolPaletteEntry paletteEntry = new TagToolPaletteEntry(
new MyPaletteComponent("myNameSpaceUri", compName, "myPrefix", "compIdForApp", MyComp.class),
compName, "Create a MyComp",
ImageDescriptor.createFromFile(MyComponentFigure.class,"icons/MyFig.gif "),
ImageDescriptor.createFromFile(MyComponentFigure.class, "icons/MyFig.gif"));
componentsDrawer.add(paletteEntry);
here
public class MyPaletteComponent implements ITagDropSourceData {//has the tag specific information}
when dropped on the design editor, it generates a tag like <myPrefix:compName/>
in runCustomizer(), i've code to add more attributes to this tag.
this method mainly handles the code generation and property view stuffs.
so if i understand correcly, to get the same tags as the eclipse html,
u need to use their ITagDropSourceData implementation.
i'm sure u would have added the proper dragsource/droptarget adapters to the palette and editor viewer,
but non-draggable icons are mostly shown if those are not appropriately added.
also make sure to have the ITagDropSourceData implementation as in MyPaletteComponent.java and use this in the palette entry.
and yes, u need to implement each component behavior separately so as what figure created on drop, what code generated and so on.
FYI, i've also wrapped myComp instance in a class which implements IAdapatable so that the dropped myComp is adaptable.
hope it helps someway,
thanks.
|
|
|
Re: WPE : Drop location is not properly identified [message #666136 is a reply to message #666079] |
Tue, 19 April 2011 09:15 |
bunta Choudhary Messages: 38 Registered: December 2010 |
Member |
|
|
Hi ANI,
thanks for the prompt reply.
As you suggested, I as well followed the same approach.
Now On dropping my component I want to generate this kind of code -
input type=\"button\" value=\"Button\" /
precisely , the above is the snippet for HTML button.
To achieve the above, I am passing the above string value to PaletteRoot class like this -
String strbuttonTAG = input type=\"button\" value=\"Button\" /;
TagToolPaletteEntry paletteEntry = new TagToolPaletteEntry(
new CustomButtonPaletteComponent(CUSTITLDConstant.URI_HTML,strbuttonTAG,"custButton",CUSTPaletteRoot.class),
compName, "Create a MyComp",
ImageDescriptor.createFromFile(MyComponentFigure.class,"icons/MyFig.gif "),
ImageDescriptor.createFromFile(MyComponentFigure.class, "icons/MyFig.gif"));
But in the above piece of code, as soon as I try any space or any other characted except alphabets in "compName", it immediatly throws ,else it works fine-
Quote: |
missing resource: Problem creating tag custButton at:DOMPosition: (form/form@[260, 266] (<form>)@[266, 273] (</form>) : 0)
org.w3c.dom.DOMException: null input type=\"button\" value=\"Button\" /
at org.eclipse.wst.xml.core.internal.document.DocumentImpl.chec kTagNameValidity(DocumentImpl.java:259)
at org.eclipse.wst.html.core.internal.document.DocumentStyleImp l.createElement(DocumentStyleImpl.java:70)
at org.eclipse.jst.pagedesigner.itemcreation.AbstractTagCreator .createElement(AbstractTagCreator.java:93)
at org.eclipse.jst.pagedesigner.itemcreation.AbstractTagCreator .createTag(AbstractTagCreator.java:49)
at org.eclipse.jst.pagedesigner.utils.CommandUtil.executeInsert ion(CommandUtil.java:91)
at org.eclipse.jst.pagedesigner.commands.CreateItemCommand.doEx ecute(CreateItemCommand.java:61)
at org.eclipse.jst.pagedesigner.commands.DesignerCommand.execut e(DesignerCommand.java:124)
|
:
:
:
As per your explaination I as well created the class extending AbstractDropCustomizer
public class CustDropCustomizer extends AbstractDropCustomizer {
private CustAdaptable dropCustomizationData;
IDropSourceData dropSourceData;
TagIdentifier target;
public CustDropCustomizer(IDropSourceData dropSourceData, TagIdentifier tagId) {
this.target = tagId;
this.dropCustomizationData = getDropCustomizationData();
this.dropSourceData = dropSourceData;
}
public CustAdaptable getDropCustomizationData()
{
return new CustAdaptable(target);
}
@Override
public IStatus runCustomizer() {
return super.runCustomizer();
}
@Override
public IStatus runCustomizer(final IFile file, final IDOMPosition position)
{
final String tagName = ((ITagDropSourceData)dropSourceData).getTagName();
dropCustomizationData.getAttributeData().addAttribute(dropCustomizationData.getTagIdentifier().getTagName(),"testValue");
return Status.OK_STATUS;
}
}
But I am not able to add the custom attributes as the above method shows.
You as well mentioned about Figure to get generated.
If the code I posted for html button is working fine, is the figure with Button will automatically be displayed on the editor or I need to
take care that part.
|
|
| |
Re: WPE : Drop location is not properly identified [message #666571 is a reply to message #666559] |
Thu, 21 April 2011 04:46 |
bunta Choudhary Messages: 38 Registered: December 2010 |
Member |
|
|
Hi Ani, As per your suggestion I modified my code and now the flow is looking like this -
Regarding the question about CUSTPaletteRoot, yes it is the PaleteRoot class only.(CUSTPaletteRoot extends PaletteRoot)
now myPalletteComponent will be -
Quote: | new MyPaletteComponent("myNameSpaceUri", "input", "myPrefix", "compIdForApp", CUSTPaletteRoot.class),
compName, "Create a MyComp",
ImageDescriptor.createFromFile(MyComponentFigure.class,"icons/MyFig.gif "),
ImageDescriptor.createFromFile(MyComponentFigure.class, "icons/MyFig.gif"));
|
My Desired tag output is -
<input type="submit">
and I am getting
<input>
considering not able to add the attributes and the value ie type="submit"
my ElementEdit file is like this -
public class CustElementEdit implements IElementEdit {
CUSTDropCustomizer drpCustomizer;
@Override
public IDropCustomizer getDropCustomizer(TagIdentifier tag) {
return (IDropCustomizer) drpCustomizer.getDropCustomizationData();
}
@Override
public IDropCustomizer getDropCustomizer(IDropSourceData dropSourceData) {
// TODO Auto-generated method stub
TagIdentifier tagId = null;
if (dropSourceData instanceof ITagDropSourceData)
{
final String uri = ((ITagDropSourceData)dropSourceData).getNamespace();
final String tagName = ((ITagDropSourceData)dropSourceData).getTagName();
tagId = TagIdentifierFactory.createJSPTagWrapper(uri, tagName);
}
//Here I am passing the instance for DropCustmizer
drpCustomizer = new CUSTDropCustomizer(tagId);
return drpCustomizer;
}
}
DropCustomiser is looking like this -
public class CUSTDropCustomizer extends AbstractDropCustomizer {
private CUSTAdaptable dropCustomizationData;
TagIdentifier target;
CUSTAdaptable CUSTAdaptable;
public CUSTDropCustomizer(TagIdentifier tagId) {
this.target = tagId;
}
public CUSTAdaptable getDropCustomizationData()
{
//Changed the return type
return dropCustomizationData;
}
@Override
public IStatus runCustomizer() {
return super.runCustomizer();
}
@Override
public IStatus runCustomizer(final IFile file, final IDOMPosition position)
{
Map<String,String> map = new HashMap<String,String>();
map.put("type","submit");
//creating the adaptable instance here
this.dropCustomizationData = new CUSTAdaptable(target);
//Tried both the methods named add and set, but none of them worked
this.dropCustomizationData.addAttribute("type","submit");
//dropCustomizationData.getAttributeData().setAttributes(map);
//Returning OK_STATUS as not sure about the changes
return Status.OK_STATUS;
}
}
Now the Adaptable class will be looking like this-
public class CUSTAdaptable extends CustomizationDataImpl {
private TagIdentifier tagIdentifier;
private AttributeData _attrs;
private ChildrenData childrenData;
private ParentData parentData;
public CUSTAdaptable(TagIdentifier target) {
super(target);
tagIdentifier = target;
_attrs = new AttributeData();
parentData = new ParentData();
childrenData = new ChildrenData();
// TODO Auto-generated constructor stub
}
/* (non-Javadoc)
* @see org.eclipse.jst.pagedesigner.itemcreation.customizer.ICustomizationData#getTagIdentifier()
*/
public TagIdentifier getTagIdentifier()
{
return tagIdentifier;
}
/* (non-Javadoc)
* @see org.eclipse.jst.pagedesigner.itemcreation.customizer.IWritableCustomizationData#setTagIdentifier(org.eclipse.jst.jsf.common.dom.TagIdentifier)
*/
public void setTagIdentifier(TagIdentifier tagId)
{
this.tagIdentifier = tagId;
}
}
This is the scenarios I am applying to achieve the <input type="submit"> but I am not getting the same. What is actual flaw I am doing with the code.It is preety obvious that I am doing something wrong while adding attribute mostly with some return type but not able to figure out the actual point of issue.
[Updated on: Thu, 21 April 2011 04:47] Report message to a moderator
|
|
|
Re: WPE : Drop location is not properly identified [message #666725 is a reply to message #666571] |
Fri, 22 April 2011 00:49 |
Ani Messages: 37 Registered: November 2010 |
Member |
|
|
new MyPaletteComponent("myNameSpaceUri", "input", "myPrefix", "compIdForApp", CUSTPaletteRoot.class),
compName, "Create a MyComp",
ImageDescriptor.createFromFile(MyComponentFigure.class,"icons/MyFig.gif "),
ImageDescriptor.createFromFile(MyComponentFigure.class, "icons/MyFig.gif"));
i don't understand why r u passing a PaletteRoot instance to MyPaletteComponent() in the above code!
instead u shud pass ur custom comp implementation class. e.g.
public class FormPaletteComponent implements ITagDropSourceData {
private String _uri;
private String _tagName;
private String _defaultPrefix;
private String _id;
private Class _compClass;
//can have other attributes also
public Class getCompClass() {
return _compClass;
}
@SuppressWarnings("rawtypes")
public void setCompClass(Class _compClass) {
this._compClass = _compClass;
}
public FormPaletteComponent(final String uri, final String tagName, final String defaultPrefix, final String id,
@SuppressWarnings("rawtypes") final Class compClass)
{
_uri = uri;
_tagName = tagName;
_defaultPrefix = defaultPrefix;
_id = id;
_compClass = compClass;
}
}
MyComponent implements Serializable {
private String id;
getId(){}
setId{}
//other stuffs
}
new MyPaletteComponent("myNameSpaceUri", "input", "myPrefix", "compIdForApp", MyComponent.class),
compName, "Create a MyComp",
ImageDescriptor.createFromFile(MyComponentFigure.class,"icons/MyFig.gif "),
ImageDescriptor.createFromFile(MyComponentFigure.class, "icons/MyFig.gif"));
from getDropCustomizer(), you shud return dropcustomizer instance instead of customizationdata
customizationdata is IAdaptable instance (u not getting any error!!!)
looks like u might get a classcastexception
public class CustElementEdit extends AbstractElementEdit {
public IDropCustomizer getDropCustomizer(IDropSourceData dropSourceData) {
if (dropSourceData instanceof MyPaletteComponent)
{
//MyPaletteComponent is ITagSourceData impl, as i told before
//this will return u MyComponent.class which u r passing in the above code
MyPaletteComponent paletteComp = (MyPaletteComponent)dropSourceData;
//from paletteComp, u can get ur required attributes for customizer
final Class compClass = (paletteComp.getCompClass());
return new CUSTDropCustomizer(//attributes taken from paletteComp);
}
return null;
//return super.getDropCustomizer(dropSourceData);
}
}
public class CUSTAdaptable extends CustomizationDataImpl {
public CUSTAdaptable (TagIdentifier target) {
super(target);
}
private MyComponent component;
//u can have other stuffs
public Object getAdapter(Class cls)
{
if(cls == ICustomizationData.class) {
return this;
}
return null;
}
public VirtualComponent getMyComponent()
{
return component;
}
public void setMyComponent(MyComponent component)
{
this.component = component;
}
@Override
public TagIdentifier getTagIdentifier() {
// TODO Auto-generated method stub
return null;
}
}
public class CUSTDropCustomizer extends AbstractDropCustomizer {
private CustAdaptable dropCustomizationData;
private Class compClass;
public CUSTDropCustomizer(Class compClass, SasbTagIdentifier tagId)
{
this.compClass = compClass;
this.tagId = tagId;
}
@Override
public IAdaptable getDropCustomizationData()
{
return dropCustomizationData;
}
@Override
public IStatus runCustomizer()
{
return Status.OK_STATUS;
}
@Override
public IStatus runCustomizer(IFile ifile, IDOMPosition position)
{
dropCustomizationData = new CustAdaptable(tagId);
MyComponent comp = (MyComponent)new SimpleFactory(compClass).getNewObject();
//use the ifile to get ur file
//load the file
//modify the file - get the tag and alter/add attributes
//then save the file
//these will be simple java kind impl
dropCustomizationData.setMyComponent(comp);
return Status.OK_STATUS;
}
}
|
|
| | | |
Re: WPE : Drop location is not properly identified [message #669404 is a reply to message #664563] |
Tue, 10 May 2011 08:41 |
bunta Choudhary Messages: 38 Registered: December 2010 |
Member |
|
|
Hi Ani,
I added a video tag like -
<object width ="150" height="100">
<param name="movie" value="abhishek3D[1].swf">
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<embed src="video\abhishek3D[1].swf" width="550" height="400"</embed>
</object>
On dropping the same, I got a very blurred image on the editor window.
I guess I need to do something with the figure .
Can you suggest me the way to do the same.
In the figure class, I did this much only, for other components it is working fine but as soon as I add object tag things are not well on the editor window,the figure I am getting is not worth. In this place, I would like to show an image of any player.
public class MyPaletteFigure implements Serializable ,IAdaptable{
@Override
public Object getAdapter(Class compClass) {
// TODO Auto-generated method stub
return compClass;
}
}
[Updated on: Tue, 10 May 2011 08:42] Report message to a moderator
|
|
| | |
Goto Forum:
Current Time: Sat Oct 19 15:32:59 GMT 2024
Powered by FUDForum. Page generated in 0.04641 seconds
|