private void jTree1MouseClicked1(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jTree1MouseClicked1

    if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1) {
      DefaultMutableTreeNode tn =
          (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();

      if (tn.getChildCount() > 0) return;

      /*if (!jTree1.isCollapsed( jTree1.getSelectionPath() ))
      {
          jTree1.collapsePath( jTree1.getSelectionPath() );
          return;
      }
           *
           */
      if (tn.getUserObject() instanceof TreeJRField) {
        TreeJRField jrf = (TreeJRField) tn.getUserObject();
        if (!jrf.getObj().isPrimitive() && !jrf.getObj().getName().startsWith("java.lang.")) {
          exploreBean(
              tn,
              jrf.getObj().getName(),
              isPathOnDescription()
                  ? Misc.nvl(jrf.getField().getDescription(), "")
                  : Misc.nvl(jrf.getField().getName(), ""));
        }
      }
    }
  } // GEN-LAST:event_jTree1MouseClicked1
  public void exploreBean(DefaultMutableTreeNode root, String classname, String parentPath) {
    try {

      root.removeAllChildren();
      if (parentPath.length() > 0) parentPath += ".";

      MainFrame.reportClassLoader.rescanLibDirectory();
      Class clazz = Class.forName(classname, true, MainFrame.reportClassLoader);

      java.beans.PropertyDescriptor[] pd =
          org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptors(clazz);
      for (int nd = 0; nd < pd.length; ++nd) {
        String fieldName = pd[nd].getName();
        if (pd[nd].getPropertyType() != null && pd[nd].getReadMethod() != null) {
          String returnType = pd[nd].getPropertyType().getName();
          it.businesslogic.ireport.JRField field =
              new it.businesslogic.ireport.JRField(Misc.getJRFieldType(fieldName), returnType);
          if (isPathOnDescription()) {
            field.setDescription(parentPath + fieldName);
          } else {
            field.setName(parentPath + fieldName);
          }

          TreeJRField jtf = new TreeJRField();

          jtf.setField(field);
          jtf.setObj(pd[nd].getPropertyType());

          boolean bChildrens = true;
          if (pd[nd].getPropertyType().isPrimitive()
              || pd[nd].getPropertyType().getName().startsWith("java.lang.")) {
            bChildrens = false;
          }
          root.add(new DefaultMutableTreeNode(jtf, bChildrens));
        }
      }

      jTree1.expandPath(new TreePath(root.getPath()));
      jTree1.updateUI();

    } catch (ClassNotFoundException cnf) {
      javax.swing.JOptionPane.showMessageDialog(
          this,
          I18n.getFormattedString(
              "messages.BeanInspectorPanel.classNotFoundError",
              "Class not found error!!\nCheck your classpath and retry!\n{0}",
              new Object[] {cnf.getMessage()}),
          I18n.getString("message.title.error", "Error"),
          javax.swing.JOptionPane.ERROR_MESSAGE);
      return;
    } catch (Exception ex) {
      javax.swing.JOptionPane.showMessageDialog(
          this,
          ex.getMessage(),
          I18n.getString("message.title.error", "Error"),
          javax.swing.JOptionPane.ERROR_MESSAGE);
      return;
    }
  }
  private void jButton2ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton2ActionPerformed

    // Get all selected paths...
    if (MainFrame.getMainInstance().getActiveReportFrame() == null || getJTableFields() == null) {
      return;
    }

    DefaultTableModel dtm = (DefaultTableModel) getJTableFields().getModel();

    TreePath[] paths = jTree1.getSelectionPaths();
    if (paths == null) return;
    for (int i = 0; i < paths.length; ++i) {
      boolean valid = true;
      TreePath tp = paths[i];

      TreeJRField tjrf =
          (TreeJRField) ((DefaultMutableTreeNode) tp.getLastPathComponent()).getUserObject();
      String returnType = Misc.getJRFieldType(tjrf.getObj().getName());
      it.businesslogic.ireport.JRField field =
          new it.businesslogic.ireport.JRField(tjrf.getField().getName(), returnType);
      field.setDescription(tjrf.getField().getDescription());
      Vector row = new Vector();
      row.addElement(field);
      row.addElement(field.getClassType());
      row.addElement(field.getDescription());

      if (isComboVisible() && jComboBox1.getSelectedItem() instanceof FieldClassWrapper) {
        FieldClassWrapper cw = (FieldClassWrapper) jComboBox1.getSelectedItem();
        field.setName(cw.getFieldName() + "." + field.getDescription());
        field.setDescription(field.getName());
      }

      // Check for duplicates fields...
      boolean found = fieldAlreadyExists(field);
      String baseName = field.getName();
      for (int j = 1; isPathOnDescription() && found; ++j) {
        field.setName(baseName + "_" + j);
        found = fieldAlreadyExists(field);
      }

      if (!found) {
        dtm.addRow(row);
        getJTableFields()
            .getSelectionModel()
            .addSelectionInterval(
                getJTableFields().getRowCount() - 1, getJTableFields().getRowCount() - 1);
      }
    }
  } // GEN-LAST:event_jButton2ActionPerformed