/** Invoked when an action occurs. */
  public void actionPerformed(final ActionEvent e) {

    final ReportDesignerContext reportDesignerContext = getReportDesignerContext();
    final ReportRenderContext activeContext = getActiveContext();
    if (activeContext == null) {
      return;
    }

    if (activeContext.isChanged()) {
      // ask the user and maybe save the report..
      final int option =
          JOptionPane.showConfirmDialog(
              reportDesignerContext.getParent(),
              Messages.getInstance()
                  .getString("PublishToServerAction.ReportModifiedWarning.Message"),
              Messages.getInstance().getString("PublishToServerAction.ReportModifiedWarning.Title"),
              JOptionPane.YES_NO_CANCEL_OPTION,
              JOptionPane.WARNING_MESSAGE);
      if (option == JOptionPane.YES_OPTION) {
        if (SaveReportAction.saveReport(
                reportDesignerContext, activeContext, reportDesignerContext.getParent())
            == false) {
          return;
        }
      }
      if (option == JOptionPane.CANCEL_OPTION) {
        return;
      }
    }

    final PublishToServerTask publishToServerTask =
        new PublishToServerTask(reportDesignerContext, reportDesignerContext.getParent());
    final LoginTask loginTask =
        new LoginTask(
            reportDesignerContext, reportDesignerContext.getParent(), publishToServerTask);

    SwingUtilities.invokeLater(loginTask);
  }
  public void actionPerformed(final ActionEvent e) {
    final ReportRenderContext activeContext = getActiveContext();
    if (activeContext == null) {
      return;
    }

    final ReportDesignerContext context = getReportDesignerContext();
    final Component parent = context.getParent();
    final Window window = LibSwingUtil.getWindowAncestor(parent);
    final RowBandingDialog dialog;
    if (window instanceof JDialog) {
      dialog = new RowBandingDialog((JDialog) window);
    } else if (window instanceof JFrame) {
      dialog = new RowBandingDialog((JFrame) window);
    } else {
      dialog = new RowBandingDialog();
    }

    final RowBandingFunction function = findRowbandingFunction(activeContext);
    final AbstractReportDefinition report = activeContext.getReportDefinition();
    if (function == null) {
      final RowBandingFunction newFunction = new RowBandingFunction();
      if (dialog.performEdit(newFunction)) {
        report.getExpressions().add(newFunction);
        activeContext
            .getUndo()
            .addChange(
                ActionMessages.getString("EditRowBandingAction.Text"),
                new ExpressionAddedUndoEntry(report.getExpressions().size() - 1, newFunction));
        report.notifyNodeChildAdded(function);
      }
    } else {
      final RowBandingFunction instance = (RowBandingFunction) function.getInstance();
      if (dialog.performEdit(instance)) {
        final ExpressionCollection expressionCollection = report.getExpressions();
        final int idx = expressionCollection.indexOf(function);
        expressionCollection.set(idx, instance);
        activeContext
            .getUndo()
            .addChange(
                ActionMessages.getString("EditRowBandingAction.Text"),
                new ExpressionEditUndoEntry(idx, function, instance));
        report.fireModelLayoutChanged(report, ReportModelEvent.NODE_PROPERTIES_CHANGED, instance);
      }
    }
  }