Exemplo n.º 1
0
  public void setClazz(Clazz clazz) {
    this.clazz = clazz;
    setTitle(clazz.getThisClassInfo().getFullyQualifiedName());

    HashMap params = new HashMap();
    params.put(ClazzSourceView.WITH_LINE_NUMBERS, "yes");
    params.put(ClazzSourceView.SUPPRESS_EXCESSED_THIS, "yes");
    decompile(params);
  }
Exemplo n.º 2
0
  private void saveToFile() {
    JFileChooser chooser = new JFileChooser();
    String saveName = clazz.getFileName();
    saveName = saveName.substring(0, saveName.lastIndexOf('.')) + ".java";
    chooser.setSelectedFile(new File(saveName));

    int returnVal = chooser.showSaveDialog(this);
    if (returnVal != JFileChooser.APPROVE_OPTION) {
      JOptionPane.showMessageDialog(
          this, "No file specified", "Try again...", JOptionPane.WARNING_MESSAGE);
      return;
    }
    try {
      PrintWriter pw = new PrintWriter(new FileOutputStream(chooser.getSelectedFile()));
      pw.println(source);
      pw.close();
    } catch (IOException ioe) {
      JOptionPane.showMessageDialog(
          this, ioe.toString(), "Input/Output Exception", JOptionPane.ERROR_MESSAGE);
      System.exit(1);
    }
  }