コード例 #1
0
  public void redo() {
    // We must remove our element...
    if (jrf == null && crosstabReportElement == null) return;
    Enumeration e = this.getElements().elements();
    Vector changed_elements = new Vector();
    while (e.hasMoreElements()) {
      PositionedElement pe = (PositionedElement) e.nextElement();
      ReportElement element = pe.getElement();

      if (crosstabReportElement != null) {
        jrf.getCrosstabEditor(crosstabReportElement)
            .getPanelEditor()
            .getSelectedElements()
            .remove(element);
        crosstabReportElement.getElements().remove(element);
        jrf.getCrosstabEditor(crosstabReportElement).getPanelEditor().repaint();
      } else {
        jrf.getSelectedElements().remove(element);
        jrf.getReport().getElements().remove(element);
        if (element instanceof CrosstabReportElement) {
          jrf.removeCrosstabEditor((CrosstabReportElement) element);
        }
        jrf.getReportPanel().repaint();
      }
      changed_elements.add(element);
    }
    jrf.fireReportListenerReportElementsChanged(
        new ReportElementChangedEvent(
            jrf, crosstabReportElement, changed_elements, ReportElementChangedEvent.REMOVED));
  }
コード例 #2
0
  public void undo() {
    // We must add our element...
    if (jrf == null && crosstabReportElement == null) return;
    Vector changed_elements = new Vector();
    for (int i = this.getElements().size() - 1; i >= 0; --i) {
      PositionedElement pe = (PositionedElement) getElements().get(i);
      ReportElement element = pe.getElement();
      // Add element....

      if (crosstabReportElement != null) {

        crosstabReportElement.getElements().insertElementAt(element, pe.getOldPosition());
      } else {
        jrf.getReport().getElements().insertElementAt(element, pe.getOldPosition());
        // jrf.addSelectedElement( element, false );
        if (element instanceof CrosstabReportElement) {
          jrf.addCrosstabEditor((CrosstabReportElement) element);
        }
      }
      changed_elements.add(element);
      // jrf.getSelectedElements().remove( element );
      // jrf.fireReportListenerReportElementsChanged(new ReportElementChangedEvent(jrf, element ,
      // ReportElementChangedEvent.REMOVED));
    }
    jrf.fireReportListenerReportElementsChanged(
        new ReportElementChangedEvent(
            jrf, crosstabReportElement, changed_elements, ReportElementChangedEvent.ADDED));

    if (crosstabReportElement != null) {
      jrf.getCrosstabEditor(crosstabReportElement)
          .getPanelEditor()
          .setSelectedElements(changed_elements);
      jrf.getCrosstabEditor(crosstabReportElement).getPanelEditor().repaint();
    } else {
      jrf.setSelectedElements(changed_elements);
      jrf.getReportPanel().repaint();
    }
  }