Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » WPE : Drop location is not properly identified
WPE : Drop location is not properly identified [message #664563] Mon, 11 April 2011 08:01 Go to next message
Ani  is currently offline Ani Friend
Messages: 37
Registered: November 2010
Member
Hi,

I'm using "org.eclipse.jst.pagedesigner.pageDesignerExtension".

My editor is HTMLEditor only which is provided by eclipse. But i have custom palette whose component drop generates my custom text code. But the graphical editor and text editors are the same.

When i try to drop my palette components on the editor, they get dropped in a row and not at the location where mouse was clicked for the drop.

I'm able to move the components around, but the drop location is not the desired one

and also i can't resize the figures on the editor though dragging the corners updates my text editor, but the figure is not resized.

I'm checking with the installed edit policies, but not getting anywhere till now.
Where am i going wrong! can any one help here !

thanks,
Re: WPE : Drop location is not properly identified [message #665544 is a reply to message #664563] Fri, 15 April 2011 03:30 Go to previous messageGo to next message
bunta Choudhary is currently offline bunta ChoudharyFriend
Messages: 38
Registered: December 2010
Member
@ANi,

I think you raised a question about how to add custom component in the Web page Editor Palette earlier and this question shows that you have already solved that issue.

Can you please provide me a simple working example as I am stuck to add even a single category in the WPE.

"I want to add a new custom component in the Web page Editor Palete named "myHTMLComponent". So, as soon as user opens any html page with WPE, myHTMLComponentM should be present there. How can I do the needful, moreover this component will as well need to generate the code changes accordingly. How to achieve the desired result.

Is there any input I can get for this. I already created standardmetadata tag, but what next"
Re: WPE : Drop location is not properly identified [message #665886 is a reply to message #665544] Mon, 18 April 2011 01:02 Go to previous messageGo to next message
Ani  is currently offline Ani Friend
Messages: 37
Registered: November 2010
Member
For adding new categories in the palette, we need to have pagedesignerextension in plugin.xml as following -


<extension
point="org.eclipse.jst.pagedesigner.pageDesignerExtension">
<paletteFactory
class="com.comp.myeditor.palette.MyEditorPaletteFactory">
</paletteFactory>
</extension>

Where MyEditorPaletteFactory will be extending AbstractPaletteFactory. Here in createPaletteRoot(), we can add our category.
public PaletteRoot createPaletteRoot(IEditorInput editorInput){
PaletteRoot paletteRoot = new PaletteRoot(getCurrentFile(editorInput));
paletteRoot.add(createStandardComponents());
return paletteRoot;
//return null;
}

private IFile getCurrentFile(IEditorInput input) {
IFile inputFile = null;
if (input instanceof IFileEditorInput) {
inputFile = ((IFileEditorInput) input).getFile();
}
return inputFile;
}





private static PaletteContainer createStandardComponents() {
PaletteDrawer componentsDrawer = new PaletteDrawer("myHTMLComponent");

TagToolPaletteEntry paletteEntry = new TagToolPaletteEntry(
new FormPaletteComponent(".....);
componentsDrawer.add(paletteEntry);

return componentsDrawer;
}



This will create the component category in the palette and we can add as many components as needed using the componentsdrawer.



Re: WPE : Drop location is not properly identified [message #665887 is a reply to message #665886] Mon, 18 April 2011 01:12 Go to previous messageGo to next message
Ani  is currently offline Ani Friend
Messages: 37
Registered: November 2010
Member
For the code changes part, we need to add an element edit factory under the same pagedesignerextension point.

<elementEditFactory
class="com.comp.myeditor.palette.MyElementEditFactory">
</elementEditFactory>

where MyElementEditFactory implements IElementEditFactory and in createElementEdit(), we need to return our custom element edit.

public IElementEdit createElementEdit(TagIdentifier tag) {
return new MyElementEdit();
//return null;
}

public class MyElementEdit extends AbstractElementEdit {

public IDropCustomizer getDropCustomizer(IDropSourceData dropSourceData) {
return new MyElementDropCustomizer(....);
}

}

public class MyElementDropCustomizer extends AbstractDropCustomizer {

private MyAdaptable dropCustomizationData;

public IAdaptable getDropCustomizationData()
{
return dropCustomizationData;
}
public IStatus runCustomizer(IFile ifile, IDOMPosition position)
{
//the custom implementation goes here to customize the drop and code generation
}
}


public class MyAdaptable extends CustomizationDataImpl {

//custom impl
}

Re: WPE : Drop location is not properly identified [message #665905 is a reply to message #665887] Mon, 18 April 2011 05:43 Go to previous messageGo to next message
bunta Choudhary is currently offline bunta ChoudharyFriend
Messages: 38
Registered: December 2010
Member
ANI..

Thanks Smile

I have few concerns-
1. I have added the 2 categories and under each category I have 5 different components/elements. So how each component will behave with drag and drop feature. Do i need to write different java files for each of the components and if yes, how to map them. If No , then what is the approach.
2. Precisely, I am mainly adding same HTM 4.0 components. So on drag and drop, same code should be autogenerated.
But when I am trying to drop the same , it is showing the icon of non draggable component.
So what actually I need to follow here to get the same HTML code .
I am not getting any clue of adding anything inside runCustomizer.

[Updated on: Mon, 18 April 2011 11:49]

Report message to a moderator

Re: WPE : Drop location is not properly identified [message #666079 is a reply to message #665905] Tue, 19 April 2011 00:50 Go to previous messageGo to next message
Ani  is currently offline Ani Friend
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 Go to previous messageGo to next message
bunta Choudhary is currently offline bunta ChoudharyFriend
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 #666559 is a reply to message #666136] Thu, 21 April 2011 01:04 Go to previous messageGo to next message
Ani  is currently offline Ani Friend
Messages: 37
Registered: November 2010
Member
what is CUSTPaletteRoot.class? looks like a PaletteRoot extension
for me it's a simple java pojo (specific for each component)
implementing serializable and some custom requirements.

and if i understand correctly,
"custbutton" is ur prefix
startButtonTag is the tag name
compName is the name displayed on palette.
am i right?

so when r u trying to add space and when it throws exception? is it on drop of the component? looks like the drop position is not valid...not very sure abt code around


in customizer.getDropCustomizationData(),
u r always returning a new CustAdaptable(target);
it will not have changes from run customizer.

the dropCustomizationData declaration looks fine,
but in the runCustomizer(), i initialize dropCustomizationData, make changes to it.

then return same instance from customizer.getDropCustomizationData();

i guess, here is the problem, just try to hit around it.

For figures, u need to have custom figures for each of ur components.
look in to org.eclipse.jst.pagedesigner.css2.widget.ButtonWidgetProvide r.java and try to follow up

Re: WPE : Drop location is not properly identified [message #666571 is a reply to message #666559] Thu, 21 April 2011 04:46 Go to previous messageGo to next message
bunta Choudhary is currently offline bunta ChoudharyFriend
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 Go to previous messageGo to next message
Ani  is currently offline Ani Friend
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 #667150 is a reply to message #666725] Wed, 27 April 2011 06:41 Go to previous messageGo to next message
bunta Choudhary is currently offline bunta ChoudharyFriend
Messages: 38
Registered: December 2010
Member
Ok Ani..


Can you update me the way for working with CSS .
I mean I want to give custom look and feel to my components. So I need to invoke proper CSS accordingly. How to achieve the same ?

[Updated on: Wed, 27 April 2011 11:20]

Report message to a moderator

Re: WPE : Drop location is not properly identified [message #667309 is a reply to message #667150] Thu, 28 April 2011 00:33 Go to previous messageGo to next message
Ani  is currently offline Ani Friend
Messages: 37
Registered: November 2010
Member
look into the AbstractWidgetProvider or ButtonWidgetProvider classes of pagedesigner extension.
You can extend it to have ur custom figure in the paintFigure() method.
Re: WPE : Drop location is not properly identified [message #667310 is a reply to message #667309] Thu, 28 April 2011 00:38 Go to previous messageGo to next message
Ani  is currently offline Ani Friend
Messages: 37
Registered: November 2010
Member
you can do IFile.refreshLocal() / IFile.getParent.refreshLocal() to reflect the newly saved changes
Re: WPE : Drop location is not properly identified [message #669404 is a reply to message #664563] Tue, 10 May 2011 08:41 Go to previous messageGo to next message
bunta Choudhary is currently offline bunta ChoudharyFriend
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

Re: WPE : Drop location is not properly identified [message #895285 is a reply to message #669404] Thu, 12 July 2012 11:40 Go to previous messageGo to next message
Sujatha M is currently offline Sujatha MFriend
Messages: 1
Registered: July 2012
Junior Member
Hi Ani,
I followed your steps to create custom pallet and component in eclispe web page editor and was able to do it successfully,but I am not able to add properties or attributes to the custom element can you please explain in more detail on how to achive this.

Thanks in advance
Re: WPE : Drop location is not properly identified [message #1705148 is a reply to message #664563] Wed, 12 August 2015 13:02 Go to previous message
Shri G is currently offline Shri GFriend
Messages: 7
Registered: August 2014
Junior Member
Above example is good but I am not able to add custom attributes.
Also I wanted to add my Panel component to palette. Could you please provide sample example or documentation for custom component using pagedesigner?
Previous Topic:Adding Deployment Assembly components programmatically
Next Topic:Tomcat 8 deploy to root context not working
Goto Forum:
  


Current Time: Fri Apr 19 08:46:20 GMT 2024

Powered by FUDForum. Page generated in 0.03640 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top