function init()
 {
     $SWT = new JavaClass("org.eclipse.swt.SWT");
     $shell = $this->shell = new java("org.eclipse.swt.widgets.Shell");
     $shell->setSize(320, 200);
     $shell->setLayout(new java("org.eclipse.swt.layout.FillLayout"));
     $button = new Java("org.eclipse.swt.widgets.Button", $this->shell, $SWT->PUSH);
     $button->setText("Click here.");
     $button->addSelectionListener(java_closure($this, null, java("org.eclipse.swt.events.SelectionListener")));
     $this->shell->open();
 }
Exemple #2
0
 public function runOdtFromSql($inputFileName, $outputFileName, $parameters, $query, $conn)
 {
     if (!isset($conn)) {
         $conn = $this->jdbcConnection;
     }
     try {
         $JasperDesign = new Java('net.sf.jasperreports.engine.design.JasperDesign');
         $JRDesignQuery = new Java('net.sf.jasperreports.engine.design.JRDesignQuery');
         $JRXmlLoader = new Java('net.sf.jasperreports.engine.xml.JRXmlLoader');
         $JasperDesign = $JRXmlLoader->load($inputFileName);
         $JRDesignQuery->setText($query);
         $JasperDesign->setQuery($JRDesignQuery);
         if (!$outputFileName) {
             $outputFileName = dirname($inputFileName) . '/' . pathinfo($inputFileName, PATHINFO_FILENAME) . '.odt';
         }
         $jasper_file_name = dirname($outputFileName) . '/' . pathinfo($outputFileName, PATHINFO_FILENAME) . '.jasper';
         $JasperCompileManager = new Java('net.sf.jasperreports.engine.JasperCompileManager');
         $JasperCompileManager->compileReportToFile($JasperDesign, $jasper_file_name);
         if ($this->runReportToOdtFile($jasper_file_name, $outputFileName, $parameters, $conn)) {
             unlink($jasper_file_name);
             return true;
         } else {
             return false;
         }
     } catch (JavaException $ex) {
         $trace = new Java('java.io.ByteArrayOutputStream');
         $ex->printStackTrace(new Java('java.io.PrintStream', $trace));
         print nl2br("java stack trace: {$trace}\n");
         return false;
     }
 }