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
  /**
   * This method set the focus on a specific component.
   *
   * <p>expressionInfo[0] can be something like: COMPONENT_CATEGORY_EXPRESSION,
   * COMPONENT_SERIES_EXPRESSION, COMPONENT_VALUE_EXPRESSION...
   *
   * <p>If it is COMPONENT_HYPERLINK, other parameters are expected... otherInfo is used here only
   * for COMPONENT_HYPERLINK otherInfo[0] = expression ID otherInfo[1] = parameter # otherInfo[2] =
   * parameter expression ID
   */
  public void setFocusedExpression(Object[] expressionInfo) {
    if (expressionInfo == null) return;
    int expID = ((Integer) expressionInfo[0]).intValue();

    switch (expID) {
      case COMPONENT_CATEGORY_EXPRESSION:
        Misc.selectTextAndFocusArea(jRTextExpressionCategory);
        break;
      case COMPONENT_SERIES_EXPRESSION:
        Misc.selectTextAndFocusArea(jRTextExpressionSeries);
        break;
      case COMPONENT_VALUE_EXPRESSION:
        Misc.selectTextAndFocusArea(jRTextExpressionValue);
        break;
      case COMPONENT_LABEL_EXPRESSION:
        Misc.selectTextAndFocusArea(jRTextExpressionLabel);
        break;
      case COMPONENT_HYPERLINK:
        jTabbedPane1.setSelectedComponent(sectionItemHyperlinkPanel1);
        Object newInfo[] = new Object[expressionInfo.length - 1];
        for (int i = 1; i < expressionInfo.length; ++i) newInfo[i - 1] = expressionInfo[i];
        sectionItemHyperlinkPanel1.setFocusedExpression(newInfo);
        break;
    }
  }
  public void afterInit() {
    // this.setSize(620, 320);

    this.pack();
    // Open in center...
    it.businesslogic.ireport.util.Misc.centerFrame(this);

    this.jComboBoxWhenResourceMissingType.addItem(
        new Tag(
            "Null",
            it.businesslogic.ireport.util.I18n.getString("whenResourceMissingType.Null", "Null")));
    this.jComboBoxWhenResourceMissingType.addItem(
        new Tag(
            "Empty",
            it.businesslogic.ireport.util.I18n.getString(
                "whenResourceMissingType.Empty", "Empty")));
    this.jComboBoxWhenResourceMissingType.addItem(
        new Tag(
            "Key",
            it.businesslogic.ireport.util.I18n.getString("whenResourceMissingType.Key", "Key")));
    this.jComboBoxWhenResourceMissingType.addItem(
        new Tag(
            "Error",
            it.businesslogic.ireport.util.I18n.getString(
                "whenResourceMissingType.Error", "Error")));

    applyI18n();

    it.businesslogic.ireport.util.Misc.setComboboxSelectedTagValue(
        jComboBoxWhenResourceMissingType, "Null");

    boolean found = true;
    for (int i = 1; found; ++i) {
      found = false;
      Enumeration e =
          it.businesslogic.ireport.gui.MainFrame.getMainInstance()
              .getActiveReportFrame()
              .getReport()
              .getSubDatasets()
              .elements();
      while (e.hasMoreElements() && !found) {
        SubDataset dataset = (SubDataset) e.nextElement();
        if (dataset.getName().equals("SubDataset" + i)) {
          found = true;
        }
      }
      if (!found) {
        jTextFieldName.setText("SubDataset" + i);
      }
    }

    jTextFieldResourceBoundle.setText(
        it.businesslogic.ireport.gui.MainFrame.getMainInstance()
            .getActiveReportFrame()
            .getReport()
            .getResourceBundleBaseName());
  }
  public void initAll() {
    initComponents();

    applyI18n();
    // jList1.setCellRenderer(new ColorsListCellRenderer());

    jButtonPasteInterval.setEnabled(clipboard.size() > 0);
    jButtonUseLast.setEnabled(lastIntervals.size() > 0);

    ((DefaultTableColumnModel) jTable1.getColumnModel())
        .getColumn(0)
        .setCellRenderer(new MeterIntervalTableCellRenderer());
    ((DefaultTableColumnModel) jTable1.getColumnModel()).getColumn(1).setPreferredWidth(50);
    DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
    dtcr.setHorizontalAlignment(SwingConstants.CENTER);
    ((DefaultTableColumnModel) jTable1.getColumnModel()).getColumn(1).setCellRenderer(dtcr);

    this.pack();
    Misc.centerFrame(this);

    jTable1
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                jTable1ValueChanged(e);
              }
            });
  }
Beispiel #5
0
  /** Creates new form ValuesDialog */
  public StylesDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    applyI18n();
    this.setSize(490, 250);
    // DefaultTableColumnModel dtcm = (DefaultTableColumnModel)jTableParameters.getColumnModel();
    // DefaultTableCellRenderer tcr =
    // (DefaultTableCellRenderer)dtcm.getColumn(0).getHeaderRenderer();

    // new DefaultTableCellRenderer();
    // tcr.setFont(jTableParameters.getFont());
    // tcr.setBackground(this.getBackground());
    // tcr.setBorder( new javax.swing.border.BevelBorder( javax.swing.border.BevelBorder.RAISED));
    // dtcm.getColumn(0).setHeaderRenderer(tcr);

    DefaultListSelectionModel dlsm =
        (DefaultListSelectionModel) this.jTableParameters.getSelectionModel();
    dlsm.addListSelectionListener(
        new javax.swing.event.ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            jTableParametersListSelectionValueChanged(e);
          }
        });

    // Open in center...
    it.businesslogic.ireport.util.Misc.centerFrame(this);

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

    it.businesslogic.ireport.gui.MainFrame.getMainInstance()
        .getActiveReportFrame()
        .getReport()
        .addStyleChangedListener(this);
    Enumeration e =
        it.businesslogic.ireport.gui.MainFrame.getMainInstance()
            .getActiveReportFrame()
            .getReport()
            .getStyles()
            .elements();
    while (e.hasMoreElements()) {
      Style style = (Style) e.nextElement();
      addStyle(style);
    }

    DefaultTableColumnModel dtcm = (DefaultTableColumnModel) jTableParameters.getColumnModel();
    dtcm.getColumn(0).setPreferredWidth(350);
    dtcm.getColumn(1).setPreferredWidth(100);

    javax.swing.KeyStroke escape =
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
    javax.swing.Action escapeAction =
        new javax.swing.AbstractAction() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            setVisible(false);
          }
        };

    getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
  }
  /** Show the dialog. if c is null, the dialog will not have a parent. */
  public int showDialog(Component c) {
    Window topLevel = null;
    if (c != null) {
      topLevel = SwingUtilities.getWindowAncestor(c);
    }

    if (topLevel == null) {
      dialog = new JDialog();
      dialog.setModal(true);
    } else if (topLevel instanceof Frame) {
      dialog = new JDialog((Frame) topLevel, true);
    } else if (topLevel instanceof Dialog) {
      dialog = new JDialog((Dialog) topLevel, true);
    }

    dialog.getContentPane().add(this);
    dialog.setDefaultCloseOperation(dialog.DISPOSE_ON_CLOSE);

    dialog.setTitle("Arithmetic operation");
    dialog.pack();
    Misc.centerFrame(dialog);

    dialog.setVisible(true);

    return getDialogResult();
  }
 /**
  * This method set the focus on a specific component. Valid constants are something like:
  * FIELD_XXX
  */
 public void setFocusedExpression(int expID) {
   switch (expID) {
     case COMPONENT_FILTER_EXPRESSION:
       Misc.selectTextAndFocusArea(jRTextExpressionAreaFilterExpression);
       break;
     case COMPONENT_SCRIPTLET_EXPRESSION:
       Misc.selectTextAndFocusArea(jTextFieldScriptletClass);
       break;
     case COMPONENT_DATASET_NAME:
       Misc.selectTextAndFocusArea(jTextFieldName);
       break;
     case COMPONENT_RESOURCE_BUNDLE:
       Misc.selectTextAndFocusArea(jTextFieldResourceBoundle);
       break;
   }
 }
Beispiel #8
0
  private void jButtonModifyActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonModifyActionPerformed
    java.awt.Frame parent = Misc.frameFromComponent(this);
    StyleDialog cd = new StyleDialog(this, true);

    // Take the selected connection from the table...
    if (jTableParameters.getSelectedRow() < 0) return;
    Style irc = null;
    try {
      irc = (Style) jTableParameters.getModel().getValueAt(jTableParameters.getSelectedRow(), 0);
    } catch (Exception ex) {
      return;
    }

    if (irc == null) return;

    cd.setStyle(irc);
    cd.setVisible(true);

    if (cd.getDialogResult() == JOptionPane.OK_OPTION) {
      Style sub = cd.getStyle();
      // Now we have an old and a new object.
      // 1. Adjust table...
      try {
        jTableParameters.getModel().setValueAt(sub, jTableParameters.getSelectedRow(), 0);
      } catch (Exception ex) {
        return;
      }
    }
  } // GEN-LAST:event_jButtonModifyActionPerformed
  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;
    }
  }
  public SubReportElement(int x, int y, int width, int height) {
    super(x, y, width, height);
    setKey("subreport");

    subreportParameters = new Vector();
    returnValues = new Vector();
    subreportExpressionClass = "java.lang.String";
    useConnection = false;
    this.transparentDefault = "Transparent";
    if (img == null)
      img =
          Misc.loadBufferedImageFromResources(
              new java.awt.Panel(), "it/businesslogic/ireport/icons/subreportTool1.jpg");
  }
  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
  /*
   * This method apply the new value for the specified property
   * The oldValue can be wrong or null if a multiselection was performed
   * return true if the object is modified...
   */
  private boolean applyNewParameterProperty(
      JRParameter param, String propertyName, Object oldValue, Object newValue) {
    if (propertyName == null) return false;

    boolean objectModified = true;

    if (propertyName.equals("parameterName")) {
      SubDataset paramSubdataset = Misc.getObjectSubDataset(getJrf().getReport(), param);
      if (paramSubdataset != null && newValue != null) {
        for (int i = 0; i < paramSubdataset.getParameters().size(); ++i) {
          JRParameter f = (JRParameter) paramSubdataset.getParameters().get(i);
          if (f.getName().equals(newValue)) {
            ((SheetProperty) this.getSheetProperty(propertyName))
                .setLabelError(
                    I18n.getString(
                        "messages.jRParameterDialog.DuplicatedParameterName",
                        "A parameter with this name already exists!"));
            ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
            return false;
          }
        }

        param.setName("" + newValue);
        ((SheetProperty) this.getSheetProperty(propertyName)).setLabelError(null);
        ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
      }
    } else if (propertyName.equals("parameterIsForPrompting")) {
      param.setIsForPrompting(((Boolean) newValue).booleanValue());
    } else if (propertyName.equals("parameterDescription")) {
      if (newValue != null) {
        param.setDescription("" + newValue);
      }
    } else if (propertyName.equals("parameterProperties")) {
      if (newValue != null && newValue instanceof List) {
        param.setProperties((List) newValue);
      }
    } else if (propertyName.equals("parameterClassType")) {
      if (newValue != null) {
        param.setClassType("" + newValue);
      }
    } else if (propertyName.equals("parameterDefaultValueExpression")) {
      if (newValue != null) {
        param.setDefaultValueExpression("" + newValue);
      }
      ((SheetProperty) this.getSheetProperty(propertyName)).setLabelError(null);
      ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
    }

    return objectModified;
  }
  /*
   * This method apply the new value for the specified property
   * The oldValue can be wrong or null if a multiselection was performed
   * return true if the object is modified...
   */
  private boolean applyNewFieldProperty(
      JRField field, String propertyName, Object oldValue, Object newValue) {
    if (propertyName == null) return false;

    boolean objectModified = true;

    if (propertyName.equals("fieldName")) {
      SubDataset paramSubdataset = Misc.getObjectSubDataset(getJrf().getReport(), field);
      if (paramSubdataset != null && newValue != null) {
        for (int i = 0; i < paramSubdataset.getFields().size(); ++i) {
          JRField f = (JRField) paramSubdataset.getFields().get(i);
          if (f.getName().equals(newValue)) {
            ((SheetProperty) this.getSheetProperty(propertyName))
                .setLabelError(
                    I18n.getString(
                        "messages.JRFieldDialog.DuplicatedFieldName",
                        "A field with this name already exists!"));
            ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
            return false;
          }
        }

        field.setName("" + newValue);
        ((SheetProperty) this.getSheetProperty(propertyName)).setLabelError(null);
        ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
      }
    } else if (propertyName.equals("fieldDescription")) {
      if (newValue != null) {
        field.setDescription("" + newValue);
      }
    } else if (propertyName.equals("fieldProperties")) {
      if (newValue != null && newValue instanceof List) {
        field.setProperties((List) newValue);
      }
    } else if (propertyName.equals("fieldClassType")) {
      if (newValue != null) {
        field.setClassType("" + newValue);
      }
    }

    return objectModified;
  }
  public void setSubDataset(SubDataset subDataset) {
    this.subDataset = subDataset;
    this.jTextFieldName.setText(subDataset.getName());
    this.jTextFieldScriptletClass.setText(subDataset.getScriptletClass());
    this.jTextFieldResourceBoundle.setText(subDataset.getResourceBundleBaseName());
    this.jRTextExpressionAreaFilterExpression.setText(subDataset.getFilterExpression());
    if (subDataset != null) {
      jRTextExpressionAreaFilterExpression.setSubDataset(subDataset);
    }

    Misc.setComboboxSelectedTagValue(
        jComboBoxWhenResourceMissingType, subDataset.getWhenResourceMissingType());
    jButtonFields.setEnabled(true);
    jButtonVariables.setEnabled(true);
    jButtonParameters.setEnabled(true);
    jButtonQuery.setEnabled(true);
    jButtonGroups.setEnabled(true);
    jButtonProperties.setEnabled(true);
    this.jButtonOk.setText(I18n.getString("subDatasetDialog.buttonOk", "Ok"));
  }
  /** Creates new form CategorySeriesDialog */
  public CategorySeriesDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    applyI18n();

    this.setSize(500, 500);
    it.businesslogic.ireport.util.Misc.centerFrame(this);

    javax.swing.KeyStroke escape =
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
    javax.swing.Action escapeAction =
        new javax.swing.AbstractAction() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            jButtonCancelActionPerformed(e);
          }
        };

    getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);

    // to make the default button ...
    this.getRootPane().setDefaultButton(this.jButtonOK);
  }
  /** Creates new form TotalObjectDialog */
  public TotalObjectDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();

    this.setSize(400, 450);

    this.setModal(true);

    org.syntax.jedit.SyntaxDocument sd = new org.syntax.jedit.SyntaxDocument();
    sd.setTokenMarker(new org.syntax.jedit.tokenmarker.JavaTokenMarker());

    this.jRTextExpressionAreaDefaultExpression.setDocument(sd);

    jTree1.setCellRenderer(new DocumentExpressionEditorTreeCellRenderer());
    updateAllTree();

    this.dialogResult = javax.swing.JOptionPane.CANCEL_OPTION;

    it.businesslogic.ireport.util.Misc.centerFrame(this);

    javax.swing.KeyStroke escape =
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
    javax.swing.Action escapeAction =
        new javax.swing.AbstractAction() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            jButtonCancelActionPerformed(e);
          }
        };

    getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);

    applyI18n();
    // to make the default button ...
    this.getRootPane().setDefaultButton(this.jButtonOK);
  }
  public JRField[] getFields(IReportConnection irConn, JRDataset reportDataset, Map parameters)
      throws JRException, UnsupportedOperationException {

    if (irConn == null || !irConn.isJDBCConnection()) {
      throw new JRException(
          "The active connection is not of type JDBC. Activate a JDBC connection first.");
    }

    String query = reportDataset.getQuery().getText();
    String error_msg = "";
    Connection con = null;
    PreparedStatement ps = null;

    try {
      // look for parameters in the query and replace them with default values.
      // parameters look something like
      // $P{QuoteGroupID}
      // or
      // $P!{OrderByClause}
      java.util.List queryParams = new ArrayList();
      JRParameter[] jrParams = reportDataset.getParameters();
      for (int k = 0; k < jrParams.length; ++k) {
        JRParameter parameter = jrParams[k];

        String p1 = "$P{" + parameter.getName() + "}";
        String p2 = "$P!{" + parameter.getName() + "}";

        Object defValue = parameters.get(parameter.getName());

        int ip1 = query.indexOf(p1);
        while (ip1 != -1) {
          // add a query parameter
          if (defValue == null) {
            throw new IllegalArgumentException(
                "Please set a " + "default value for the parameter '" + parameter.getName() + "'");
          }

          String before = query.substring(0, ip1);
          String after = query.substring(ip1 + p1.length());
          query = before + " ? " + after;
          queryParams.add(defValue);
          ip1 = query.indexOf(p1);
        }

        int ip2 = query.indexOf(p2);
        while (ip2 != -1) {
          // String replacement, Altering the SQL statement.
          if (defValue == null) {
            throw new IllegalArgumentException(
                "Please set a " + "default value for the parameter '" + parameter.getName() + "'");
          }

          String before = query.substring(0, ip2);
          String after = query.substring(ip2 + p2.length());
          query = before + "" + defValue.toString() + "" + after;
          ip2 = query.indexOf(p2);
        }
      }

      con = irConn.getConnection();

      ps = con.prepareStatement(query);
      //                for(int pc=0; pc<queryParams.size(); pc++ ) {
      //                    ps.setObject(pc+1, queryParams.get(pc) );
      //                }

      for (int pc = 0; pc < queryParams.size(); pc++) {
        Class parameterType = queryParams.get(pc).getClass();

        if (java.lang.Boolean.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.BIT);
          } else {
            ps.setBoolean(pc + 1, ((Boolean) queryParams.get(pc)).booleanValue());
          }
        } else if (java.lang.Byte.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.TINYINT);
          } else {
            ps.setByte(pc + 1, ((Byte) queryParams.get(pc)).byteValue());
          }
        } else if (java.lang.Double.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.DOUBLE);
          } else {
            ps.setDouble(pc + 1, ((Double) queryParams.get(pc)).doubleValue());
          }
        } else if (java.lang.Float.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.FLOAT);
          } else {
            ps.setFloat(pc + 1, ((Float) queryParams.get(pc)).floatValue());
          }
        } else if (java.lang.Integer.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.INTEGER);
          } else {
            ps.setInt(pc + 1, ((Integer) queryParams.get(pc)).intValue());
          }
        } else if (java.lang.Long.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.BIGINT);
          } else {
            ps.setLong(pc + 1, ((Long) queryParams.get(pc)).longValue());
          }
        } else if (java.lang.Short.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.SMALLINT);
          } else {
            ps.setShort(pc + 1, ((Short) queryParams.get(pc)).shortValue());
          }
        } else if (java.math.BigDecimal.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.DECIMAL);
          } else {
            ps.setBigDecimal(pc + 1, (BigDecimal) queryParams.get(pc));
          }
        } else if (java.lang.String.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.VARCHAR);
          } else {
            ps.setString(pc + 1, queryParams.get(pc).toString());
          }
        } else if (java.sql.Timestamp.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.TIMESTAMP);
          } else {
            ps.setTimestamp(pc + 1, (java.sql.Timestamp) queryParams.get(pc));
          }
        } else if (java.sql.Time.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.TIME);
          } else {
            ps.setTime(pc + 1, (java.sql.Time) queryParams.get(pc));
          }
        } else if (java.util.Date.class.isAssignableFrom(parameterType)) {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.DATE);
          } else {
            ps.setDate(pc + 1, new java.sql.Date(((java.util.Date) queryParams.get(pc)).getTime()));
          }
        } else {
          if (queryParams.get(pc) == null) {
            ps.setNull(pc + 1, Types.JAVA_OBJECT);
          } else {
            ps.setObject(pc + 1, queryParams.get(pc));
          }
        }
      }

      // Some JDBC drivers don't supports this method...
      try {
        ps.setFetchSize(0);
      } catch (Exception e) {
      }

      ResultSet rs = ps.executeQuery();

      // if (in < num) return;

      ResultSetMetaData rsmd = rs.getMetaData();

      // if (in < num) return;

      List columns = new ArrayList();
      for (int i = 1; i <= rsmd.getColumnCount(); ++i) {
        JRDesignField field = new JRDesignField();
        field.setName(rsmd.getColumnLabel(i));
        field.setValueClassName(Misc.getJdbcTypeClass(rsmd, i));
        field.setDescription("");
        columns.add(field);
      }

      JRField[] final_fields = new JRField[columns.size()];
      for (int i = 0; i < final_fields.length; ++i) {
        final_fields[i] = (JRField) columns.get(i);
      }

      return final_fields;

    } catch (IllegalArgumentException ie) {
      throw new JRException(ie.getMessage());
    } catch (NoClassDefFoundError ex) {
      ex.printStackTrace();
      error_msg = "NoClassDefFoundError!!\nCheck your classpath!";
      throw new JRException(error_msg);
    } catch (java.sql.SQLException ex) {
      error_msg = "SQL problems:\n" + ex.getMessage();
      throw new JRException(error_msg);
    } catch (Exception ex) {
      ex.printStackTrace();
      error_msg =
          "General problem:\n"
              + ex.getMessage()
              + "\n\nCheck username and password; is the DBMS active ?!";
      throw new JRException(error_msg);
    } catch (Throwable t) {
      throw new JRException(t.getMessage());
    } finally {
      if (ps != null)
        try {
          ps.close();
        } catch (Exception e) {
        }
      if (con != null)
        try {
          con.close();
        } catch (Exception e) {
        }
    }
  }
Beispiel #18
0
 private void jButtonNewActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonNewActionPerformed
   java.awt.Frame parent = Misc.frameFromComponent(this);
   StyleDialog cd = new StyleDialog(this, true);
   cd.setVisible(true);
 } // GEN-LAST:event_jButtonNewActionPerformed
  /** Update all the element properties... */
  public void updateSelection(JReportFrame newJrf) {

    // Improving speed...
    // Do nothing if there are elements selected...
    if (newJrf != null && newJrf.getSelectedElements().size() > 0) return;

    // Fix for numbers focus losing...
    if (newJrf == null) {
      this.setSelection(new Vector());
    } else {
      this.setSelection(newJrf.getSelectedObjects());
    }

    setInit(true);

    this.removeAllProperties();

    this.jrf = newJrf;

    if (jrf == null || getSelection().size() == 0) {
      this.recreateSheet();
      return;
    }

    try {
      Vector selectedElements = getSelection();

      boolean sameParameterDescription = true;
      boolean sameParameterDefaultValueExpression = true;
      boolean sameParameterClassType = true;
      boolean sameParameterIsForPrompting = true;

      boolean sameFieldDescription = true;
      boolean sameFieldClassType = true;

      boolean sameVariableResetType = true;
      boolean sameVariableResetGroup = true;
      boolean sameVariableCalculationType = true;
      boolean sameVariableClassType = true;
      boolean sameVariableExpression = true;
      boolean sameVariableInitialValueExpression = true;
      boolean sameVariableIncrementGroup = true;
      boolean sameVariableIncrementType = true;
      boolean sameVariableIncrementerClass = true;

      boolean areAllparameters = true;
      boolean areAllfields = true;
      boolean areAllvariables = true;
      boolean isTheFirstElement = true;

      boolean areBuiltInParameters = false; // True if one ore more parameter is builtin...
      boolean areBuiltInVariables = false; // True if one ore more parameter is builtin...

      SubDataset subdataset = null;

      for (int i = 0; i < selectedElements.size(); ++i) {
        Object obj = selectedElements.elementAt(i);

        if (!(obj instanceof JRParameter)) {
          areAllparameters = false;
        }

        if (!(obj instanceof JRField)) {
          areAllfields = false;
        }

        if (!(obj instanceof JRVariable)) {
          areAllvariables = false;
        }

        if (isTheFirstElement) {
          subdataset = Misc.getObjectSubDataset(jrf.getReport(), obj);
          updateAllComboBoxes(subdataset);
        } else if (subdataset != null) {
          SubDataset s2 = Misc.getObjectSubDataset(subdataset, obj);
          if (s2 != subdataset) {
            subdataset = null;
          }
        }

        if (areAllparameters) {
          JRParameter param = (JRParameter) selectedElements.elementAt(i);

          if (!areBuiltInParameters) {
            areBuiltInParameters = param.isBuiltin();
          }

          if (selectedElements.size() == 1) {
            // Single parameter selectes...
            setTextArea(isTheFirstElement, param.getName(), spParameterName);
            spParameterProperties.setValue(param.getProperties());
          }
          if (sameParameterDescription)
            sameParameterDescription =
                setTextArea(isTheFirstElement, param.getDescription(), spParameterDescription);
          if (sameParameterDefaultValueExpression)
            sameParameterDefaultValueExpression =
                setTextArea(
                    isTheFirstElement,
                    param.getDefaultValueExpression(),
                    spParameterDefaultValueExpression);
          if (sameParameterClassType)
            sameParameterClassType =
                setGenericSheetProperty(
                    isTheFirstElement, param.getClassType(), spParameterClassType);
          if (sameParameterIsForPrompting)
            sameParameterIsForPrompting =
                this.setCheckBox(
                    isTheFirstElement, param.isIsForPrompting(), false, spParameterIsForPrompting);
        }

        if (areAllfields) {
          JRField field = (JRField) selectedElements.elementAt(i);

          if (selectedElements.size() == 1) {
            // Single parameter selectes...
            setTextArea(isTheFirstElement, field.getName(), spFieldName);
            spFieldProperties.setValue(field.getProperties());
          }
          if (sameFieldDescription)
            sameFieldDescription =
                setTextArea(isTheFirstElement, field.getDescription(), spFieldDescription);
          if (sameFieldClassType)
            sameFieldClassType =
                setGenericSheetProperty(isTheFirstElement, field.getClassType(), spFieldClassType);
        }

        if (areAllvariables) {
          JRVariable variable = (JRVariable) selectedElements.elementAt(i);

          if (!areBuiltInVariables) {
            areBuiltInVariables = variable.isBuiltin();
          }

          if (selectedElements.size() == 1) {
            // Single parameter selectes...
            setTextArea(isTheFirstElement, variable.getName(), spVariableName);
          }

          if (subdataset != null) {
            if (sameVariableResetType)
              sameVariableResetType =
                  setTagComboBox(isTheFirstElement, variable.getResetType(), spVariableResetType);
            if (sameVariableResetGroup)
              sameVariableResetGroup =
                  setTagComboBox(isTheFirstElement, variable.getResetGroup(), spVariableResetGroup);
            if (sameVariableIncrementType)
              sameVariableIncrementType =
                  setTagComboBox(
                      isTheFirstElement, variable.getIncrementType(), spVariableIncrementType);
            if (sameVariableIncrementGroup)
              sameVariableIncrementGroup =
                  setTagComboBox(
                      isTheFirstElement, variable.getIncrementGroup(), spVariableIncrementGroup);
          }

          if (sameVariableCalculationType)
            sameVariableCalculationType =
                setTagComboBox(
                    isTheFirstElement, variable.getCalculation(), spVariableCalculationType);
          if (sameVariableIncrementerClass)
            sameVariableIncrementerClass =
                setTextArea(
                    isTheFirstElement,
                    variable.getIncrementerFactoryClass(),
                    spVariableIncrementerClass);
          if (sameVariableClassType)
            sameVariableClassType =
                setGenericSheetProperty(
                    isTheFirstElement, variable.getClassType(), spVariableClassType);
          if (sameVariableExpression)
            sameVariableExpression =
                setTextArea(isTheFirstElement, variable.getExpression(), spVariableExpression);
          if (sameVariableInitialValueExpression)
            sameVariableInitialValueExpression =
                setTextArea(
                    isTheFirstElement,
                    variable.getInitialValueExpression(),
                    spVariableInitialValueExpression);
        }

        isTheFirstElement = false;
      }

      // TO DO: change this!

      // get the common subdataset...
      if (subdataset != null) {
        ExpressionContext ec = new ExpressionContext();
        ec.setSubDataset(subdataset);
        spParameterDefaultValueExpression.setExpressionContext(ec);
        spVariableExpression.setExpressionContext(ec);
        spVariableInitialValueExpression.setExpressionContext(ec);
      }

      spParameterDefaultValueExpression.setLabelError(null);
      spParameterDefaultValueExpression.updateLabel();

      spVariableExpression.setLabelError(null);
      spVariableExpression.updateLabel();

      spVariableInitialValueExpression.setLabelError(null);
      spVariableInitialValueExpression.updateLabel();

      if (areAllparameters) {

        String commonStr =
            it.businesslogic.ireport.util.I18n.getString(
                "parameterProperties", "Parameter Properties");
        if (getSelection().size() == 1) this.addSheetProperty(commonStr, spParameterName);
        spParameterIsForPrompting.setDefaultValue(new Boolean(true));
        this.addSheetProperty(commonStr, spParameterClassType);
        spParameterClassType.setLabelColor(
            (sameParameterClassType)
                ? mandatoryPropertiesLabelColor
                : sharedDifferentValueLabelColor);

        if (!areBuiltInParameters) {
          spParameterName.setReadOnly(false);
          spParameterClassType.setReadOnly(false);
          spParameterIsForPrompting.setLabelColor(
              (sameParameterIsForPrompting)
                  ? mandatoryPropertiesLabelColor
                  : sharedDifferentValueLabelColor);
          this.addSheetProperty(commonStr, spParameterIsForPrompting);
          spParameterDefaultValueExpression.setLabelColor(
              (sameParameterDefaultValueExpression)
                  ? mandatoryPropertiesLabelColor
                  : sharedDifferentValueLabelColor);
          this.addSheetProperty(commonStr, spParameterDefaultValueExpression);
          if (getSelection().size() == 1) this.addSheetProperty(commonStr, spParameterProperties);
        } else {
          spParameterName.setReadOnly(true);
          spParameterClassType.setReadOnly(true);
        }

      } else if (areAllfields) {
        String commonStr =
            it.businesslogic.ireport.util.I18n.getString("fieldProperties", "Field Properties");
        if (getSelection().size() == 1) this.addSheetProperty(commonStr, spFieldName);
        spFieldClassType.setLabelColor(
            (sameFieldClassType) ? mandatoryPropertiesLabelColor : sharedDifferentValueLabelColor);
        this.addSheetProperty(commonStr, spFieldClassType);
        spFieldDescription.setLabelColor(
            (sameFieldDescription)
                ? mandatoryPropertiesLabelColor
                : sharedDifferentValueLabelColor);
        this.addSheetProperty(commonStr, spFieldDescription);
        if (getSelection().size() == 1) this.addSheetProperty(commonStr, spFieldProperties);

      } else if (areAllvariables) {
        String commonStr =
            it.businesslogic.ireport.util.I18n.getString(
                "variableProperties", "Variable Properties");
        if (getSelection().size() == 1) this.addSheetProperty(commonStr, spVariableName);

        spVariableClassType.setLabelColor(
            (sameVariableClassType)
                ? mandatoryPropertiesLabelColor
                : sharedDifferentValueLabelColor);
        this.addSheetProperty(commonStr, spVariableClassType);

        if (!areBuiltInVariables) {
          spVariableName.setReadOnly(false);
          spVariableClassType.setReadOnly(false);

          spVariableCalculationType.setLabelColor(
              (sameVariableCalculationType)
                  ? mandatoryPropertiesLabelColor
                  : sharedDifferentValueLabelColor);
          this.addSheetProperty(commonStr, spVariableCalculationType);

          if (subdataset != null) {
            spVariableResetType.setLabelColor(
                (sameVariableResetType)
                    ? mandatoryPropertiesLabelColor
                    : sharedDifferentValueLabelColor);
            this.addSheetProperty(commonStr, spVariableResetType);
            spVariableResetGroup.setLabelColor(
                (sameVariableResetGroup)
                    ? mandatoryPropertiesLabelColor
                    : sharedDifferentValueLabelColor);
            this.addSheetProperty(commonStr, spVariableResetGroup);
            spVariableIncrementType.setLabelColor(
                (sameVariableIncrementType)
                    ? mandatoryPropertiesLabelColor
                    : sharedDifferentValueLabelColor);
            this.addSheetProperty(commonStr, spVariableIncrementType);
            spVariableIncrementGroup.setLabelColor(
                (sameVariableIncrementGroup)
                    ? mandatoryPropertiesLabelColor
                    : sharedDifferentValueLabelColor);
            this.addSheetProperty(commonStr, spVariableIncrementGroup);

            if (!sameVariableResetType || !spVariableResetType.getValue().equals("Group")) {
              spVariableResetGroup.setReadOnly(true);
            } else {
              spVariableResetGroup.setReadOnly(false);
            }

            if (!sameVariableIncrementType || !spVariableIncrementType.getValue().equals("Group")) {
              spVariableIncrementGroup.setReadOnly(true);
            } else {
              spVariableIncrementGroup.setReadOnly(false);
            }
          }
          spVariableIncrementerClass.setLabelColor(
              (sameVariableIncrementerClass)
                  ? mandatoryPropertiesLabelColor
                  : sharedDifferentValueLabelColor);
          this.addSheetProperty(commonStr, spVariableIncrementerClass);
          spVariableExpression.setLabelColor(
              (sameVariableExpression)
                  ? mandatoryPropertiesLabelColor
                  : sharedDifferentValueLabelColor);
          this.addSheetProperty(commonStr, spVariableExpression);
          spVariableInitialValueExpression.setLabelColor(
              (sameVariableInitialValueExpression)
                  ? mandatoryPropertiesLabelColor
                  : sharedDifferentValueLabelColor);
          this.addSheetProperty(commonStr, spVariableInitialValueExpression);

        } else {
          spVariableName.setReadOnly(true);
          spVariableClassType.setReadOnly(true);
        }
      }

      this.recreateSheet();

    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {

    }

    setInit(false);
  }
  /*
   * This method apply the new value for the specified property
   * The oldValue can be wrong or null if a multiselection was performed
   * return true if the object is modified...
   */
  private boolean applyNewVariableProperty(
      JRVariable variable, String propertyName, Object oldValue, Object newValue) {
    if (propertyName == null) return false;

    boolean objectModified = true;

    if (propertyName.equals("variableName")) {
      SubDataset paramSubdataset = Misc.getObjectSubDataset(getJrf().getReport(), variable);
      if (paramSubdataset != null && newValue != null) {
        for (int i = 0; i < paramSubdataset.getVariables().size(); ++i) {
          JRVariable f = (JRVariable) paramSubdataset.getVariables().get(i);
          if (f.getName().equals(newValue)) {
            ((SheetProperty) this.getSheetProperty(propertyName))
                .setLabelError(
                    I18n.getString(
                        "messages.JRVariableDialog.DuplicatedVariableName",
                        "A variable with this name already exists!"));
            ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
            return false;
          }
        }

        variable.setName("" + newValue);
        ((SheetProperty) this.getSheetProperty(propertyName)).setLabelError(null);
        ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
      }
    } else if (propertyName.equals("variableClassType")) {
      if (newValue != null) {
        variable.setClassType("" + newValue);
      }
    } else if (propertyName.equals("variableCalculationType")) {
      if (newValue != null) {
        variable.setCalculation("" + newValue);
      }
    } else if (propertyName.equals("variableResetType")) {
      if (newValue != null) {
        variable.setResetType("" + newValue);
      }
      if (newValue != null && newValue.equals("Group")) {
        spVariableResetGroup.setReadOnly(false);
        variable.setResetGroup(spVariableResetGroup.getValue() + "");
      } else {
        spVariableResetGroup.setReadOnly(true);
        variable.setResetGroup("");
      }
      spVariableResetGroup.updateLabel();
    } else if (propertyName.equals("variableResetGroup")) {
      variable.setResetGroup((newValue == null) ? "" : "" + newValue);
    } else if (propertyName.equals("variableIncrementType")) {
      if (newValue != null) {
        variable.setIncrementType("" + newValue);
      }
      if (newValue != null && newValue.equals("Group")) {
        spVariableIncrementGroup.setReadOnly(false);
        variable.setResetGroup(spVariableIncrementGroup.getValue() + "");
      } else {
        spVariableIncrementGroup.setReadOnly(true);
        variable.setIncrementGroup("");
      }
      spVariableIncrementGroup.updateLabel();
    } else if (propertyName.equals("variableIncrementGroup")) {
      variable.setIncrementGroup((newValue == null) ? "" : "" + newValue);
    } else if (propertyName.equals("variableIncrementerClass")) {
      variable.setIncrementerFactoryClass((newValue == null) ? "" : "" + newValue);
    } else if (propertyName.equals("variableExpression")) {
      if (newValue != null) {
        variable.setExpression("" + newValue);
      }
      ((SheetProperty) this.getSheetProperty(propertyName)).setLabelError(null);
      ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
    } else if (propertyName.equals("variableInitialValueExpression")) {
      if (newValue != null) {
        variable.setInitialValueExpression("" + newValue);
      }
      ((SheetProperty) this.getSheetProperty(propertyName)).setLabelError(null);
      ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
    }

    return objectModified;
  }
  /** This methos is called when a property changes... */
  public void sheetPropertyValueChanged(SheetPropertyValueChangedEvent evt) {
    if (isInit()) return;

    try {
      setInit(true);
      // System.out.println("Changed: " + evt.getPropertyName());
      // if (isNullItem((SheetProperty)evt.getSource())) return;

      // removeNullItem( (SheetProperty)evt.getSource() );

      Vector selectedElements = getSelection();

      Vector modified_parameters = new Vector();
      Vector original_parameters = new Vector();

      Vector modified_fields = new Vector();
      Vector original_fields = new Vector();

      Vector modified_variables = new Vector();
      Vector original_variables = new Vector();

      for (int i = 0; i < selectedElements.size(); ++i) {

        Object object = selectedElements.elementAt(i);

        if (object instanceof JRParameter) {
          JRParameter param = (JRParameter) object;
          if (param.isBuiltin()) continue;
          JRParameter originalParam = param.cloneMe();
          if (applyNewParameterProperty(
              param, evt.getPropertyName(), evt.getOldValue(), evt.getNewValue())) {
            modified_parameters.add(object);
            original_parameters.add(originalParam);
          }
        } else if (object instanceof JRField) {
          JRField field = (JRField) object;
          JRField originalField = field.cloneMe();
          if (applyNewFieldProperty(
              field, evt.getPropertyName(), evt.getOldValue(), evt.getNewValue())) {
            modified_fields.add(object);
            original_fields.add(originalField);
          }
        } else if (object instanceof JRVariable) {
          JRVariable variable = (JRVariable) object;
          JRVariable originalVariable = variable.cloneMe();
          if (applyNewVariableProperty(
              variable, evt.getPropertyName(), evt.getOldValue(), evt.getNewValue())) {
            modified_variables.add(object);
            original_variables.add(originalVariable);
          }
        }

        // don't listen to these events...

        for (int k = 0; k < modified_parameters.size(); ++k) {
          JRParameter param = (JRParameter) modified_parameters.get(k);
          JRParameter oldParam = (JRParameter) original_parameters.get(k);
          SubDataset sd = Misc.getObjectSubDataset(getJrf().getReport(), param);
          sd.fireSubDatasetObjectChangedListenerSubDatasetObjectChanged(
              new it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent(
                  sd,
                  it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.PARAMETER,
                  it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.MODIFIED,
                  oldParam,
                  param));
        }

        for (int k = 0; k < modified_fields.size(); ++k) {
          JRField field = (JRField) modified_fields.get(k);
          JRField oldField = (JRField) original_fields.get(k);
          SubDataset sd = Misc.getObjectSubDataset(getJrf().getReport(), field);
          sd.fireSubDatasetObjectChangedListenerSubDatasetObjectChanged(
              new it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent(
                  sd,
                  it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.FIELD,
                  it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.MODIFIED,
                  oldField,
                  field));
        }

        for (int k = 0; k < modified_variables.size(); ++k) {
          JRVariable variable = (JRVariable) modified_variables.get(k);
          JRVariable oldVariable = (JRVariable) original_variables.get(k);
          SubDataset sd = Misc.getObjectSubDataset(getJrf().getReport(), variable);
          sd.fireSubDatasetObjectChangedListenerSubDatasetObjectChanged(
              new it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent(
                  sd,
                  it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.VARIABLE,
                  it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.MODIFIED,
                  oldVariable,
                  variable));
        }
      }

      getJrf().getReport().incrementReportChanges();

    } finally {
      setInit(false);
    }
  }