Jump to content
JasperReports Library 7.0 is now available ×

Mac OS X, Cannot Drop Fields, ver 0.3.1,0.3.2


2004 IR Help

Recommended Posts

By: Kelvin Smith - kelvins

Mac OS X, Cannot Drop Fields, ver 0.3.1,0.3.2

2004-06-25 22:00

Hello,

 

Have been trialling out iReports 0.3.1. Works OK on Linux, but not on Mac OS X. It works fine in every aspect that is does on Linux except that if I drag and drop a field from the "Report Fields" window, It doesn't go to the report.

 

What happens visually on OS X, is when you start dragging the field to the form, the rectangle is as large as the field name list.

 

Running OS X.3.4. Rename dj.jar as tools.jar as per another post.

 

Any idea?

 

 

 

 

By: Gary Nunes - gary_nunes

RE: Mac OS X, Cannot Drop Fields, ver 0.3.1,0.3.2

2004-06-26 19:03

Kelvin,

 

You have encountered two distinct behaviors of Mac OS X Java. One is a bug, the other is "by design".

 

The "by design" behavior is the default appearance of the drag image. The Apple Java group has indicated that they intend to provide better default drag images in the future but, in the mean time, what you see is what's there. It is possible to explicitly provide a different image (more about that later).

 

The Mac OS X DnD bug is an odd one but easily fixed. One must include the String flavor as one of the supported transferable (drag and droppable) flavors. The support is minimal and easily added to iReport. Once added the field dragging "magically" starts working. The support is added in the TransferableObject.java file in package it.businesslogic.ireport.gui.dnd. It requires modifying the following methods:

getTransferData(...)

getTransferDataFlavors(...)

isDataFlavorSupported(...)

to support DataFlavor.stringFlavor. The modified file source appears at the end of this message. Copy it into a file named TransferableObject.java and place the new file in the appropriate place in the source package hierarchy (the differences from the old file are marked with my initials: GDN). Recompile.

 

Regarding replacing the default drag image. I didn't try doing that since, once the drag works, the default image isn't so bad. If you want to do it I think it will require modifying file JDragTable.java in package it.businesslogic.ireport.gui. In method gragGestureRecognized(...) of that file there's a call

e.startDrag(...)

That call needs to be replaced with the version that allows specification of a drag image.

 

I hope this helps,

Gary Nunes

 

 

----- new TransferableObject.java code follows -----

/*

* TransferableObject.java

*

* Created on 14 novembre 2003, 0.54

*/

 

package it.businesslogic.ireport.gui.dnd;

 

/**

*

* @author Administrator

*/

public class TransferableObject implements java.awt.datatransfer.Transferable {

 

Object obj;

java.awt.datatransfer.DataFlavor thisFlavor;

/** Creates a new instance of TransferableObject */

public TransferableObject(Object obj) {

this.obj = obj;

thisFlavor = new java.awt.datatransfer.DataFlavor(obj.getClass(), obj.getClass().getName());

}

 

public Object getTransferData(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException {

if (flavor.equals( thisFlavor ))

{

return obj;

}

// GDN new code start

else

if (flavor.equals( java.awt.datatransfer.DataFlavor.stringFlavor )) {

return new String(); // anything non-null

}

else

// GDN new code end

return null;

}

 

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors() {

// GDN new code start

java.awt.datatransfer.DataFlavor stringFlavor = java.awt.datatransfer.DataFlavor.stringFlavor;

return new java.awt.datatransfer.DataFlavor[] { thisFlavor,

stringFlavor };

// GDN new code end

 

// GDN comment out-->return new java.awt.datatransfer.DataFlavor[]{thisFlavor};

}

 

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor) {

// GDN comment out

// if (flavor != null && flavor.equals( thisFlavor ))

// {

// return true;

// }

//

// return false;

// GDN comment out

// GDN new code begin

if (flavor == null)

return false;

else

if (flavor.equals( thisFlavor ))

return true;

else

if (flavor.equals( java.awt.datatransfer.DataFlavor.stringFlavor ))

return true;

else

return false;

// GDN new code end

}

 

}

----- end of new TransferableObject.java code ----

 

 

 

 

 

 

By: Gary Nunes - gary_nunes

RE: Mac OS X, Cannot Drop Fields, ver 0.3.1,0.3.2

2004-06-26 19:04

P.S.

 

As far as I know there's no need to change the name of the dt.jar file to tools.jar. It just needs to be in the right place.

 

-gary

 

 

 

 

By: Gary Nunes - gary_nunes

RE: Mac OS X, Cannot Drop Fields, ver 0.3.1,0.3.2

2004-06-26 19:22

P.P.S

 

Kelvin,

 

The code doesn't look so good in the previous message (the formatting seems to have gone away).

 

I've placed the modified TransferableObject.java file in the "Patches" section of this site so maybe you can get it there if you want. It's titled "Fix to drag/drop problem in Mac OS X" (https://sourceforge.net/tracker/index.php?func=detail&aid=980499&group_id=64348&atid=507165)

 

-gary

 

 

 

 

By: Gary Nunes - gary_nunes

RE: Mac OS X, Cannot Drop Fields, ver 0.3.1,0.3.2

2004-06-30 07:54

Kelvin,

 

I received a message that the TransferableObject.java patch is now in the latest CVS source so all you need to do now is get the latest CVS source (as described in a previous message). You don't need to apply the patch yourself.

 

Regards,

gary

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...