Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » DND Problem: What is being dragged?
DND Problem: What is being dragged? [message #200265] Fri, 21 October 2005 09:30 Go to next message
Eclipse UserFriend
Originally posted by: prashanto.chatterjee.softwareag.com

Hi,
I need to add certain indicators that suggest as to in which part a
dragged item can be dropped. The type of indication I am looking at is
changing container color to green for receptive nature and to red for
non-receptive nature. I tried doing this by adding the following piece of
code in my DropListener class:

------------------------------------------------------------ -------------------
protected Request createTargetRequest() {
//Look at the data on templatetransfer.
//Create factory
//PC: 12-09-2005 : Creating my own request so that I can set CI page name
for that
//CreateRequest request = new CreateRequest();
DropTargetEvent event = getCurrentEvent();
Object data = event.data;

Point dropLocation = getDropLocation();
Object dragged = GadgetTransfer.getInstance().getTemplate();
EditPart targetEditPart = getViewer().findObjectAt(dropLocation);
if(dragged == CIPage.class && targetEditPart instanceof
CISectionEditPart){
//change color of the section to green indicating receptiveness
CISectionEditPart ciSectionPart = (CISectionEditPart)targetEditPart;
SectionBorder ciSectionBorder =
(SectionBorder)ciSectionPart.getFigure().getBorder();
ciSectionBorder.getTitleBarBorder().setBackgroundColor(Color Constants.darkGreen);
ciSectionPart.refreshVisuals();
((StandardGUIAppEditPart)ciSectionPart.getParent()).refreshV isuals();
}else{
//change color of the section to red indicating non-receptiveness
System.out.println();
}

Shape shape = null;
try{
shape = (Shape)data;
}catch(ClassCastException cce){
//Strangely this comes but I am not able to figure this out :( So
preventing it from getting thrown
//cce.printStackTrace();
}
//CIPage page = (CIPage)event.data;
CustomizedCreateRequest request = null;
if(shape != null){
//implies the page has been dropped
request = new CustomizedCreateRequest(shape.getName());
}else{
request = new CustomizedCreateRequest();
}
request.setFactory(getFactory(GadgetTransfer.getInstance().g etTemplate()));
return request;
}
------------------------------------------------------------ -------------------

Now the problem is, what I drag is not clear and not set in the event
until I do a drop. I observed the same behavior when I drop an item from
the palette. Is it possible to know what is the dragged object during a
drag?

Thanks in advance.

Appreciate your time and help,
Prashanto Chatterjee
Re: DND Problem: What is being dragged? [message #200289 is a reply to message #200265] Fri, 21 October 2005 10:55 Go to previous message
Eclipse UserFriend
Originally posted by: prashanto.chatterjee.softwareag.com

Hi,
To add to my request earlier; I am actually dragging an item from a
TreeView onto a Container in my editor.

Thanks,
Prashanto Chatterjee
Previous Topic:Tooltip in gef.ui.parts.TreeViewer
Next Topic:GEF or Draw2D
Goto Forum:
  


Current Time: Thu Nov 07 06:53:35 GMT 2024

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

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

Back to the top