private void jButtonRemoveActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonRemoveActionPerformed

    while (jList1.getSelectedIndex() >= 0) {
      categoryDataset.getCategorySeries().remove(jList1.getSelectedValue());
      ((javax.swing.DefaultListModel) jList1.getModel()).removeElementAt(jList1.getSelectedIndex());
    }
  } // GEN-LAST:event_jButtonRemoveActionPerformed
  public void setCategoryDataset(CategoryDataset categoryDataset) {
    this.categoryDataset = categoryDataset;

    jButtonModify.setEnabled(false);
    jButtonModify.setEnabled(false);
    javax.swing.DefaultListModel lm = (javax.swing.DefaultListModel) jList1.getModel();

    lm.removeAllElements();

    Vector v = categoryDataset.getCategorySeries();

    for (int i = 0; i < v.size(); ++i) {
      lm.addElement(v.elementAt(i));
    }
  }
  private void jMenuItemPasteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemPasteActionPerformed

    Vector v = it.businesslogic.ireport.gui.MainFrame.getMainInstance().getChartSeriesClipBoard();

    if (v != null && v.size() > 0) {
      for (int i = 0; i < v.size(); ++i) {
        if (v.elementAt(i) instanceof CategorySeries) {
          CategorySeries cs = (CategorySeries) v.elementAt(i);
          cs = cs.cloneMe();
          categoryDataset.getCategorySeries().addElement(cs);
          ((javax.swing.DefaultListModel) jList1.getModel()).addElement(cs);
        }
      }
    }
  } // GEN-LAST:event_jMenuItemPasteActionPerformed
  private void jButtonAddActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonAddActionPerformed

    CategorySeriesDialog csd =
        new CategorySeriesDialog(it.businesslogic.ireport.gui.MainFrame.getMainInstance(), true);
    csd.setSubDataset(this.getSubDataset());
    csd.setVisible(true);
    if (csd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
      CategorySeries cs = new CategorySeries();
      cs.setSeriesExpression(csd.getSeriesExpression());
      cs.setCategoryExpression(csd.getCategoryExpression());
      cs.setValueExpression(csd.getValueExpression());
      cs.setLabelExpression(csd.getLabelExpression());
      cs.setSectionItemHyperlink(csd.getSectionItemHyperlink());

      categoryDataset.getCategorySeries().addElement(cs);
      ((javax.swing.DefaultListModel) jList1.getModel()).addElement(cs);
    }
  } // GEN-LAST:event_jButtonAddActionPerformed