Skip to content

Commit

Permalink
Added check to drag listener
Browse files Browse the repository at this point in the history
Sovles bug 2022
  • Loading branch information
Arvid Berg committed Jun 28, 2010
1 parent 028fc8d commit aabe7ac
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import net.bioclipse.jobs.BioclipseJobUpdateHook;
import net.bioclipse.jobs.BioclipseUIJob;
import net.sourceforge.nattable.NatTable;
import net.sourceforge.nattable.grid.GridRegion;
import net.sourceforge.nattable.layer.LabelStack;

import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
Expand Down Expand Up @@ -71,6 +73,7 @@
import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
Expand Down Expand Up @@ -218,11 +221,23 @@ private void initDrag() {

@Override
public void dragStart( DragSourceEvent event ) {
start = new Point(event.x,event.y);
Control widget = ((DragSource)event.widget).getControl();
if(widget instanceof NatTable) {
NatTable table = ((NatTable)widget);
LabelStack regionLabels = table.getRegionLabelsByXY(event.x, event.y);
if(regionLabels.hasLabel(GridRegion.BODY)) {
start = new Point(event.x,event.y);
return;
}
}
event.doit = false;
}
@Override
public void dragSetData( DragSourceEvent event ) {
if(start==null) return;
if(start==null){
event.doit = false;
return;
}
MoleculeTableViewer viewer = getMolTableViewer();
NatTable table = (NatTable) viewer.getControl();
int col = table.getColumnPositionByX( start.x );
Expand All @@ -243,10 +258,14 @@ public void dragSetData( DragSourceEvent event ) {
else if (PluginTransfer.getInstance().isSupportedType(event.dataType)) {
byte[] bData = AtomContainerTransfer.getInstance().toByteArray(mol.getAtomContainer());
event.data = new PluginTransferData("net.bioclipse.cdk.jchempaint.atomContainerDrop", bData);
}
}else event.doit = false;
} else if ( TextTransfer.getInstance().isSupportedType( event.dataType )) {
event.data = data.toString();
}
else if( plugTransfer.isSupportedType(event.dataType)) {
event.data = new PluginTransferData( "net.bioclipse.cdk.jchempaint.atomContainerDrop",
data.toString().getBytes());
} else event.doit = false;
}
});
}
Expand Down

0 comments on commit aabe7ac

Please sign in to comment.