DND Problem: What is being dragged? [message #200265] |
Fri, 21 October 2005 09:30 |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02605 seconds