コード例 #1
0
ファイル: JavaCodeViewer.java プロジェクト: ApipA/jWic
  /* (non-Javadoc)
   * @see de.jwic.sourceviewer.viewer.IObjectViewer#setNavigationElement(de.jwic.sourceviewer.model.NavigationElement)
   */
  public void setNavigationElement(NavigationElement element) {

    if (element == null) {
      htmlCode = "";
      return; // direct exit
    }

    if (false) {
      htmlCode = "test";
      return;
    }
    FileElement fe = (FileElement) element;
    try {
      FileReader reader = new FileReader(fe.getFile());
      JavaSource source = new JavaSourceParser().parse(reader);
      JavaSource2HTMLConverter converter = new JavaSource2HTMLConverter();
      StringWriter writer = new StringWriter();

      JavaSourceConversionOptions options = JavaSourceConversionOptions.getDefault();
      // options.setShowLineNumbers(true);

      converter.convert(source, options, writer);
      htmlCode = writer.toString();
      reader.close();

    } catch (Exception e) {
      log.error("Error creating HTML code", e);
      htmlCode = "Error creating html code: " + e;
    }
  }
コード例 #2
0
ファイル: JavaCodeViewer.java プロジェクト: ApipA/jWic
  /* (non-Javadoc)
   * @see de.jwic.sourceviewer.viewer.IObjectViewer#isSupported(de.jwic.sourceviewer.model.NavigationElement)
   */
  public boolean isSupported(NavigationElement element) {

    if (element instanceof FileElement) {
      FileElement file = (FileElement) element;
      return file.getType().equals(FileType.JAVA) || file.getType().equals(FileType.JS);
    }

    return false;
  }