⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ireportcompiler.java

📁 iReport-0.4.1-src是iReport的源代码,iReport是一个开源的报表项目,可以生成PDF等格式报表
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
   
   public void removeThread()
   {
       if (threadList != null)
      {
         javax.swing.DefaultListModel dlm = (javax.swing.DefaultListModel)threadList.getModel();
         dlm.removeElement(this);
         threadList.updateUI();
      }
       
   }
   /** Getter for property command.
    * @return Value of property command.
    *
    */
   public int getCommand()
   {
      return command;
   }
   
   /** Setter for property command.
    * @param command New value of property command.
    *
    */
   public void setCommand(int command)
   {
      this.command = command;
   }
   
   /** Getter for property iReportConnection.
    * @return Value of property iReportConnection.
    *
    */
   public it.businesslogic.ireport.IReportConnection getIReportConnection()
   {
      return iReportConnection;
   }
   
   /** Setter for property iReportConnection.
    * @param iReportConnection New value of property iReportConnection.
    *
    */
   public void setIReportConnection(it.businesslogic.ireport.IReportConnection iReportConnection)
   {
      this.iReportConnection = iReportConnection;
   }
   
   /** Getter for property jrf.
    * @return Value of property jrf.
    *
    */
   public JReportFrame getJrf()
   {
      return jrf;
   }
   
   /** Setter for property jrf.
    * @param jrf New value of property jrf.
    *
    */
   public void setJrf(JReportFrame jrf)
   {
      this.jrf = jrf;
   }
   
   /** Getter for property mainFrame.
    * @return Value of property mainFrame.
    *
    */
   public MainFrame getMainFrame()
   {
      return mainFrame;
   }
   
   /** Setter for property mainFrame.
    * @param mainFrame New value of property mainFrame.
    *
    */
   public void setMainFrame(MainFrame mainFrame)
   {
      this.mainFrame = mainFrame;
   }
   
   /** Getter for property properties.
    * @return Value of property properties.
    *
    */
   public HashMap getProperties()
   {
      return properties;
   }
   
   /** Setter for property properties.
    * @param properties New value of property properties.
    *
    */
   public void setProperties(HashMap properties)
   {
      this.properties = properties;
   }
   
   public String toString()
   {
      return status;
   }
   
   class FilteredStream extends FilterOutputStream
   {
      public FilteredStream(OutputStream aStream)
      {
         super(aStream);
      }
      
      public void write(byte b[]) throws IOException
      {
         String aString = new String(b);
         outputBuffer += aString;
      }
      
      public void write(byte b[], int off, int len) throws IOException
      {
         String aString = new String(b , off , len);
         outputBuffer += aString;
         
         //mainFrame.logOnConsole(aString);
      }
   }
   
   public void start()
   {
      this.thread = new Thread(this);
      
	//using the report directory to load classes and resources
	try{
		  String reportDirectory = new File(jrf.getReport().getFilename()).getParent();
      
		  //set classpath
		  String classpath = System.getProperty("jasper.reports.compile.class.path");
		  if(classpath != null){
			
			  classpath += File.pathSeparator + reportDirectory; 
			  System.setProperty("jasper.reports.compile.class.path", classpath);
			
		  }else if(System.getProperty("java.class.path") != null){
			
			  classpath = System.getProperty("java.class.path");
			  classpath += File.pathSeparator + reportDirectory; 
			  System.setProperty("java.class.path", classpath);
		  }

		  //include report directory for resource search path
		  reportDirectory = reportDirectory.replace('\\', '/');
		  if(!reportDirectory.endsWith("/")){
			  reportDirectory += "/";//the file path separator must be present
		  }
		  if(!reportDirectory.startsWith("/")){
			  reportDirectory = "/" + reportDirectory;//it's important to JVM 1.4.2 especially if contains windows drive letter
		  }
		  thread.setContextClassLoader(new URLClassLoader(new URL[]{
			  new URL("file://"+reportDirectory)
		  }));
  
	}catch(MalformedURLException mue){
	  mue.printStackTrace();
	}
      
      this.thread.start();
   }
   
   public void parseException(String exception, Vector sourceLines)
   {
      
      // Create a single outString...
      String outString = "";
      
      // For each row, looking for a file name followed by a row number...
      //javax.swing.JOptionPane.showMessageDialog(null,exception);
      StringTokenizer st = new StringTokenizer(exception, "\n");
      while (st.hasMoreElements())
      {
         
         String line = st.nextToken();
         if (line.startsWith(this.javaFile))
         {
            // The next line is an expression error....
            //mainFrame.logOnConsole(line+"\n");
            outString += Misc.toHTML(line+"\n");
            String lineNumber = line.substring( this.javaFile.length()+1);
            lineNumber = lineNumber.substring(0, lineNumber.indexOf(':'));
            int ln = Integer.parseInt(lineNumber);
            if (ln >= 3) ln -=3;
            
            // Take the element name....
            
            String reference = "";
            if (sourceLines.size() >= ln)
            {
               
               String lineCode = (String)sourceLines.elementAt(ln);
               //mainFrame.logOnConsole( "Line: " + ln + "> " + lineCode+"\n");
               if (lineCode.indexOf("            case") == 0 &&
               lineCode.indexOf(" : // ") >0)
               {
                  // We have found the comment where jasperReport puts the expression ref.
                  reference = lineCode.substring(lineCode.indexOf(" : // ")+6).trim();
               }
            }
            
            if (st.hasMoreElements())
            {
               try
               {
                  String error_line = st.nextToken();
                  if (error_line.startsWith("found"))
                  {
                     //mainFrame.logOnConsole( error_line+"\n");
                     outString += Misc.toHTML(error_line+"\n");
                     error_line = st.nextToken();
                  }
                  if (error_line.startsWith("required"))
                  {
                     //mainFrame.logOnConsole( error_line+"\n");
                     outString += Misc.toHTML(error_line+"\n");
                     error_line = st.nextToken();
                  }
                  if (error_line.startsWith("symbol"))
                  {
                     //mainFrame.logOnConsole( error_line+"\n");
                     outString += Misc.toHTML(error_line+"\n");
                     error_line = st.nextToken();
                  }
                  if (error_line.startsWith("location"))
                  {
                     //mainFrame.logOnConsole( error_line+"\n");
                     outString += Misc.toHTML(error_line+"\n");
                     error_line = st.nextToken();
                  }
                  
                  // Find the link....
                  // Count space at begin of line...
                  String html = "";
                  for (int i=0; i<error_line.length(); ++i)
                  {
                     if (error_line.charAt(i) == ' ')
                     {
                        html += "&nbsp;";
                     }
                     else break;
                  }
                  error_line = error_line.trim();
                  html += "<a href=\"http://error:"+ jrf.getWindowID()+ "/"+reference+"\">"+Misc.toHTML(error_line)+"</a><br>";
                  //mainFrame.logOnConsole( html,true);
                  outString += html;
               } catch (Exception ex)
               {
                  //mainFrame.logOnConsole( "Error parsing\n!");
                  outString += Misc.toHTML("Error parsing\n!");
               }
            }
         }
         else if (line.startsWith("Warning :") && line.indexOf("y=")>0 && line.indexOf("height=")>0 && line.indexOf("band-height=")>0)
         {
            //mainFrame.logOnConsole("<a href=\"http://warning\">"+Misc.toHTML(line)+"</a><br>",true);
            outString += "<a href=\"http://warning:"+ jrf.getWindowID() +"\">"+Misc.toHTML(line)+"</a><br>";
         }
         else
         {
            //mainFrame.logOnConsole(line+"\n");
            outString += Misc.toHTML(line+"\n");
         }
      }
      mainFrame.logOnConsole(outString,true);
      //mainFrame.logOnConsole( "<a href=\"http://problem\">*****<hr><font face=\"Courier New\" size=\"3\">"+ exception +"</a>", true);
      outputBuffer = "";
   }
   
   public javax.swing.JComponent searchButton(javax.swing.JComponent root, String text)
   {
      if (root instanceof javax.swing.JButton && ((javax.swing.JButton)root).getText()!=null && ((javax.swing.JButton)root).getText().equals(text) ) return root;
      for (int i=0; i<root.getComponentCount(); ++i)
      {
         
         if (root.getComponent(i) instanceof javax.swing.JComponent)
         {
            mainFrame.logOnConsole(""+ ((javax.swing.JComponent)root.getComponent(i)) +"\n");
            javax.swing.JComponent res = searchButton((javax.swing.JComponent)root.getComponent(i),  text);
            if (res != null) return res;
         }
      }
      return null;
   }
   
   public void afterPageExport() {
       
       filledpage++;
       if (command == 0)
       {
            
       }
       
       /*
       if (filledpage != 1 && (filledpage % 10 != 0)) return;
       javax.swing.text.Document doc = mainFrame.getLogDocument();
       try {
       String doc_str = doc.getText(0, doc.getLength() );
       int index = doc_str.lastIndexOf("Exported page ");
       if (index <=0 )
       {
        mainFrame.logOnConsole("</font><font face=\"SansSerif\" size=\"3\" color=\"#000000\">Exported page " + filledpage +"</font><br><font face=\"Courier New\" size=\"3\">",true);
       }
       else
       {
          String str_old = "Exported page " + (filledpage-10);
          doc.remove(index, str_old.length());
          doc.insertString(0, "Exported page " + filledpage, null);
       }
       } catch (Exception ex) {}
       */
   }

    public javax.swing.JList getThreadList() {
        return threadList;
    }

    public void setThreadList(javax.swing.JList threadList) {
        this.threadList = threadList;
    }
    
    public void updateThreadList()
    {
        try {
         if (threadList != null) javax.swing.SwingUtilities.invokeAndWait( 
            new java.lang.Runnable() { 
                    public void run() { 
                            threadList.updateUI(); 
                    }
            } );
         } catch (Exception ex) {}
    }
        
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -