Hi All,
I am still on war with getting jasper and swt working. :)
My latest issue is as follows. I want my report to reload every 50 seconds.
[code]
import net.sf.jasperreports.engine.JasperPrint;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
..
public class CSReportAction implements IWorkbenchWindowActionDelegate {
CustomerInfo cusInfo = null;
ReportView rv = null;
/**
* The constructor.
*/
public CSReportAction() {
try {
rv = (ReportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ReportView.ID_REPORT_VIEW);
} catch (PartInitException e) {
e.printStackTrace();
}
}
/**
* The action has been activated. The argument of the
* method represents the 'real' action sitting
* in the workbench UI.
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action) {
cusInfo = new CustomerInfo(new Shell(), SWT.NONE);
cusInfo.open();
// while(true) {
System.out.println("Calling reports...");
JasperPrint jprint = ReportGen.generateReport(cusInfo.getCustomerInfo());
System.out.println("Passed Customer No -" + cusInfo.getCustomerInfo() + "- to the Jprint.");
try {
rv.getReportViewer().setDocument(jprint);
System.out.println("JPrint object displayed in browser.");
System.out.println("Reports done.");
System.out.println("--------------------------------------------");
} catch (Exception e) {
e.printStackTrace();
}
// if(rv.getReportViewer().hasDocument()){
//
// try {
// synchronized(this){
// wait(50000);
// }
// } catch (InterruptedException e) {
// System.out.println("Error while waiting"+e);
// }catch (Exception e1) {
// System.out.println("Error while waiting2"+e1);
//
// }
// }
}
public void selectionChanged(IAction action, ISelection selection) {
}
public void dispose() {
}
public void init(IWorkbenchWindow window) {
}
}
[/code]
What I trying to do here, when I click on a button, I take the customer id from the user and call the generatereport method, which returns me the jasperprint object. Now, I load the report using the getReportViewer.setDocument().
Now, I want this report to reload at specific intervals. So, I first used the timer methods. I got the message - 'not thread owner'. I presumed it was because, my timer method was starting another thread inside the main run() thread, which is not permitted. So, I tried using the simple wait(). This also isnt working.
Any idea? Anybody?
-Uday
--
View in EZ forum: http://www.eclipsezone.com/eclipse/forums/m91949405.html