Example #1
0
  private void decompile(Map params) {
    try {
      ClazzSourceView csv = ClazzSourceViewFactory.getClazzSourceView(clazz);
      csv.setDecompileParameters(params);
      source = csv.getSource();

      String sourceText = source;

      sourceText = sourceText.replaceAll(" ", " ");
      sourceText = sourceText.replaceAll("<", "&lt;");
      sourceText = sourceText.replaceAll(">", "&gt;");
      sourceText = sourceText.replaceAll("\n", "<BR>");
      sourcePane.setText(sourceText);
      sourcePane.setCaretPosition(0);
    } catch (Throwable ex) {
      if (Utils.hasDebug()) {
        ex.printStackTrace();
      }
      sourcePane.setText("Exception occured while decompiling");

      String link = "http://sourceforge.net/tracker/?group_id=226227&atid=1066690";
      String exception = unpackException(ex);

      JTextPane text = new JTextPane();
      text.setContentType("text/html");
      text.setText(
          "<html>Error occured while decompiling!<BR>Please submit bug at <b>"
              + link
              + "</b><BR>"
              + exception
              + "</html>");
      text.setEditable(false);
      text.setBackground(this.getBackground());

      JOptionPane.showMessageDialog(this, text, "Error", JOptionPane.ERROR_MESSAGE);

      throw new IllegalArgumentException("Error decompiling");
    }
  }
Example #2
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    decompilePanel = new JPanel();
    jScrollPane2 = new JScrollPane();
    sourcePane = new JTextPane();
    jMenuBar1 = new JMenuBar();
    jMenu2 = new JMenu();
    savaAsMenuItem = new JMenuItem();
    CtrlCMenuItem = new JMenuItem();

    setName("decompileFrame"); // NOI18N
    getContentPane().setLayout(new java.awt.GridBagLayout());

    decompilePanel.setLayout(new java.awt.GridBagLayout());

    sourcePane.setContentType("text/html");
    sourcePane.setEditable(false);
    sourcePane.setDisabledTextColor(new java.awt.Color(0, 0, 0));
    sourcePane.setEnabled(false);
    jScrollPane2.setViewportView(sourcePane);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    decompilePanel.add(jScrollPane2, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    getContentPane().add(decompilePanel, gridBagConstraints);

    jMenu2.setText("Edit");

    savaAsMenuItem.setText("Save as...");
    savaAsMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveAsMenuItemActionPerformed(evt);
          }
        });
    jMenu2.add(savaAsMenuItem);

    CtrlCMenuItem.setText("Copy All to Clipboard");
    CtrlCMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            CtrlCMenuItemActionPerformed(evt);
          }
        });
    jMenu2.add(CtrlCMenuItem);

    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    pack();
  }