How to handle the drag & drop of a hyperlink in GWT

2011-12-30 Thread Shuai Yuan
Hi all,

I want to handle the drag & drop of hyperlinks in my app. The
hyperlink could be from any where, therefore I cannot make it
setDragable(true) and setData("link", "the URL") to mark it.

A very similar scenario would be Google Image search by image, where
you can drag & drop a link of image to the search box.

The sample code,

Label lblDropLink = new Label("Drop a link here");
lblDropLink.addDragOverHandler(new DragOverHandler() {

@Override
public void onDragOver(DragOverEvent event) {
lblDropLink.setText("Drop here to add the link.");
lblDropLink.setStyleName("dragOverFade");
}
});
lblDropLink.addDropHandler(new DropHandler() {

@Override
public void onDrop(DropEvent event) {
event.preventDefault();

// QUESTION: how to get the link, and even its text?
}
});

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: GWT 2.1 hellomvp using GIN

2010-10-21 Thread Yuan
can't use gin at ActivityMapper? somehower, on the HelloMVP
AppActivityMapper,
it says

public Activity getActivity(Place place) {
// This is begging for GIN
if (place instanceof HelloPlace)
return new HelloActivity((HelloPlace) place, 
clientFactory);
else if (place instanceof GoodbyePlace)
return new GoodbyeActivity((GoodbyePlace) place, 
clientFactory);

return null;
}

On Oct 20, 3:22 pm, Thomas Broyer  wrote:
> On 20 oct, 11:42, Sebastian Beigel  wrote:
>
> > Hi,
>
> > I'm looking at 2.1 (RC1) for the first time right now and I try to
> > refactor the hellomvp sample to use GIN.
>
> > Unfortunately, I have some problems with the places -> activities
> > mapping. The doc says "A better way to implement the chain of nested
> > ifs would be with a GIN module." and the code is commented "Map each
> > Place to its corresponding Activity. This would be a great use for
> > GIN.".
>
> > I agree, but I don't really know how to do this mapping :) Has anyone
> > refactored this code to use GIN?
>
> You just can't actually. What could work is using a Ginjector as the
> factory of a PlaceHistoryMapperWithFactory, but for ActivityMapper
> this is not possible (it could be by adding a code generator using a
> factory of activity factories, similar to the factory of place
> tokenizers (which are kind of factories for places) for
> PlaceHistoryMapperWithFactory).
> I wrote an code generator for ActivityMapper some time ago  code-reviews.appspot.com/845802/show> it won't do what you're asking
> for but could probably be used as a basis for it. But you'd first have
> to decide how to model a "factory of activities" that would be
> returned by your "Ginjector as a factory for
> ActivityMapperWithFactory".

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.