コード例 #1
0
 /** Creates a new instance of ReportElementSheetPanel */
 public ReportObjectSheetPanel() {
   super();
   this.setBackground(Color.BLUE);
   initSheetProperties();
   // We have to register for element changes...
   MainFrame mf = MainFrame.getMainInstance();
   mf.addReportListener(this);
   mf.addReportFrameActivatedListener(this);
   I18n.addOnLanguageChangedListener(this);
 }
コード例 #2
0
  /*
   * 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;
  }
コード例 #3
0
  /*
   * 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;
  }
コード例 #4
0
  protected void initSheetProperties() {
    spParameterName =
        new SheetProperty(
            "parameterName",
            I18n.getString("crosstabParameterDialog.label1", "Parameter name"),
            SheetProperty.TEXT);
    spParameterName.setShowResetButton(false);

    spParameterDescription =
        new SheetProperty(
            "parameterDescription",
            I18n.getString("jRParameterDialog.label4", "Parameter Description"),
            SheetProperty.TEXT);
    spParameterDescription.setShowResetButton(false);

    spParameterDefaultValueExpression =
        new ExpressionSheetProperty(
            "parameterDefaultValueExpression",
            it.businesslogic.ireport.util.I18n.getString(
                "jRParameterDialog.label3", "Default Value Expression"));
    spParameterDefaultValueExpression.setShowResetButton(false);

    spParameterProperties =
        new PropertiesSheetProperty(
            "parameterProperties",
            it.businesslogic.ireport.util.I18n.getString(
                "parameterProperties", "Parameter Properties"));
    spParameterProperties.setShowResetButton(false);

    spParameterClassType =
        new ComboBoxSheetProperty(
            "parameterClassType",
            it.businesslogic.ireport.util.I18n.getString(
                "jRParameterDialog.label2", "Parameter Class Type"));
    spParameterClassType.setShowResetButton(false);
    JComboBox classTypeCombo = (JComboBox) spParameterClassType.getEditor();

    classTypeCombo.setEditable(true);

    classTypeCombo.addItem("java.lang.Boolean");
    classTypeCombo.addItem("java.lang.Byte");
    classTypeCombo.addItem("java.util.Date");
    classTypeCombo.addItem("java.sql.Timestamp");
    classTypeCombo.addItem("java.sql.Time");
    classTypeCombo.addItem("java.lang.Double");
    classTypeCombo.addItem("java.lang.Float");
    classTypeCombo.addItem("java.lang.Integer");
    classTypeCombo.addItem("java.lang.Long");
    classTypeCombo.addItem("java.lang.Short");
    classTypeCombo.addItem("java.math.BigDecimal");
    classTypeCombo.addItem("java.lang.Number");
    classTypeCombo.addItem("java.lang.String");
    classTypeCombo.addItem("java.util.Collection");
    classTypeCombo.addItem("java.util.List");
    classTypeCombo.addItem("java.lang.Object");
    classTypeCombo.addItem("java.io.InputStream");
    classTypeCombo.addItem("net.sf.jasperreports.engine.JREmptyDataSource");

    spParameterIsForPrompting =
        new SheetProperty(
            "parameterIsForPrompting",
            it.businesslogic.ireport.util.I18n.getString(
                "jRParameterDialog.checkBoxIsForPrompting", "Use as a Prompt"),
            SheetProperty.BOOLEAN);
    spParameterIsForPrompting.setShowResetButton(false);

    spFieldName =
        new SheetProperty(
            "fieldName", I18n.getString("jRFieldDialog.label1", "Field name"), SheetProperty.TEXT);
    spFieldName.setShowResetButton(false);

    spFieldDescription =
        new SheetProperty(
            "fieldDescription",
            I18n.getString("jRFieldDialog.label4", "Field Description"),
            SheetProperty.TEXT);
    spFieldDescription.setShowResetButton(false);

    spFieldClassType =
        new ComboBoxSheetProperty(
            "fieldClassType",
            it.businesslogic.ireport.util.I18n.getString(
                "jRFieldDialog.label2", "Field Class Type"));
    spFieldClassType.setShowResetButton(false);
    classTypeCombo = (JComboBox) spFieldClassType.getEditor();

    classTypeCombo.setEditable(true);
    classTypeCombo.addItem("java.lang.Boolean");
    classTypeCombo.addItem("java.lang.Byte");
    classTypeCombo.addItem("java.util.Date");
    classTypeCombo.addItem("java.sql.Timestamp");
    classTypeCombo.addItem("java.sql.Time");
    classTypeCombo.addItem("java.lang.Double");
    classTypeCombo.addItem("java.lang.Float");
    classTypeCombo.addItem("java.lang.Integer");
    classTypeCombo.addItem("java.lang.Long");
    classTypeCombo.addItem("java.lang.Short");
    classTypeCombo.addItem("java.math.BigDecimal");
    classTypeCombo.addItem("java.lang.Number");
    classTypeCombo.addItem("java.lang.String");
    classTypeCombo.addItem("java.util.Collection");
    classTypeCombo.addItem("java.util.List");

    spFieldProperties =
        new PropertiesSheetProperty(
            "fieldProperties",
            it.businesslogic.ireport.util.I18n.getString("fieldProperties", "Field Properties"));
    spFieldProperties.setShowResetButton(false);

    spVariableName =
        new SheetProperty(
            "variableName",
            I18n.getString("jRVariableDialog.label1", "Variable name"),
            SheetProperty.TEXT);
    spVariableName.setShowResetButton(false);

    spVariableClassType =
        new ComboBoxSheetProperty(
            "variableClassType",
            it.businesslogic.ireport.util.I18n.getString(
                "jRVariableDialog.label5", "Variable Class Type"));
    spVariableClassType.setShowResetButton(false);
    classTypeCombo = (JComboBox) spVariableClassType.getEditor();
    classTypeCombo.setEditable(true);
    classTypeCombo.addItem("java.lang.Boolean");
    classTypeCombo.addItem("java.lang.Byte");
    classTypeCombo.addItem("java.util.Date");
    classTypeCombo.addItem("java.sql.Timestamp");
    classTypeCombo.addItem("java.sql.Time");
    classTypeCombo.addItem("java.lang.Double");
    classTypeCombo.addItem("java.lang.Float");
    classTypeCombo.addItem("java.lang.Integer");
    classTypeCombo.addItem("java.lang.Long");
    classTypeCombo.addItem("java.lang.Short");
    classTypeCombo.addItem("java.math.BigDecimal");
    classTypeCombo.addItem("java.lang.Number");
    classTypeCombo.addItem("java.lang.String");
    classTypeCombo.addItem("java.util.Collection");
    classTypeCombo.addItem("java.util.List");
    classTypeCombo.addItem("java.lang.Object");
    classTypeCombo.addItem("java.io.InputStream");
    classTypeCombo.addItem("net.sf.jasperreports.engine.JREmptyDataSource");

    spVariableCalculationType =
        new SheetProperty(
            "variableCalculationType",
            it.businesslogic.ireport.util.I18n.getString(
                "jRVariableDialog.label2", "Calculation Type"),
            SheetProperty.COMBOBOX);
    Vector tags = new Vector();
    tags.add(new Tag("Nothing", I18n.getString("variable.calculationType.Nothing", "Nothing")));
    tags.add(new Tag("Count", I18n.getString("variable.calculationType.Count", "Count")));
    tags.add(
        new Tag(
            "DistinctCount",
            I18n.getString("variable.calculationType.DistinctCount", "Distinct count")));
    tags.add(new Tag("Sum", I18n.getString("variable.calculationType.Sum", "Sum")));
    tags.add(new Tag("Average", I18n.getString("variable.calculationType.Average", "Average")));
    tags.add(new Tag("Lowest", I18n.getString("variable.calculationType.Lowest", "Lowest")));
    tags.add(new Tag("Highest", I18n.getString("variable.calculationType.Highest", "Highest")));
    tags.add(
        new Tag(
            "StandardDeviation",
            I18n.getString("variable.calculationType.StandardDeviation", "Standard deviation")));
    tags.add(new Tag("Variance", I18n.getString("variable.calculationType.Variance", "Variance")));
    tags.add(new Tag("System", I18n.getString("variable.calculationType.System", "System")));
    tags.add(new Tag("First", I18n.getString("variable.calculationType.First", "First")));
    spVariableCalculationType.setTags(tags);
    spVariableCalculationType.setDefaultValue("Now");
    spVariableCalculationType.setShowResetButton(false);
    spVariableResetType =
        new it.businesslogic.ireport.gui.sheet.SheetProperty(
            "variableResetType",
            it.businesslogic.ireport.util.I18n.getString("jRVariableDialog.label7", "Reset Type"),
            it.businesslogic.ireport.gui.sheet.SheetProperty.COMBOBOX);
    spVariableResetType.setShowResetButton(false);
    tags = new Vector();
    tags.add(
        new Tag("None", it.businesslogic.ireport.util.I18n.getString("resetType.None", "None")));
    tags.add(
        new Tag(
            "Report", it.businesslogic.ireport.util.I18n.getString("resetType.Report", "Report")));
    tags.add(
        new Tag("Page", it.businesslogic.ireport.util.I18n.getString("resetType.Page", "Page")));
    tags.add(
        new Tag(
            "Column", it.businesslogic.ireport.util.I18n.getString("resetType.Column", "Column")));
    tags.add(
        new Tag("Group", it.businesslogic.ireport.util.I18n.getString("resetType.Group", "Group")));
    spVariableResetType.setTags(tags);
    spVariableResetType.setDefaultValue("Report");

    spVariableResetGroup =
        new ComboBoxSheetProperty(
            "variableResetGroup",
            it.businesslogic.ireport.util.I18n.getString("jRVariableDialog.label6", "Reset Group"));
    spVariableResetGroup.setShowResetButton(false);

    spVariableIncrementType =
        new SheetProperty(
            "variableIncrementType",
            it.businesslogic.ireport.util.I18n.getString(
                "gui.elementpropertiessheet.textfieldEvaluationTime", "Eval. time"),
            SheetProperty.COMBOBOX);
    tags = new Vector();
    tags.add(
        new Tag(
            "None", it.businesslogic.ireport.util.I18n.getString("incrementType.None", "None")));
    tags.add(
        new Tag(
            "Report",
            it.businesslogic.ireport.util.I18n.getString("incrementType.Report", "Report")));
    tags.add(
        new Tag(
            "Page", it.businesslogic.ireport.util.I18n.getString("incrementType.Page", "Page")));
    tags.add(
        new Tag(
            "Column",
            it.businesslogic.ireport.util.I18n.getString("incrementType.Column", "Column")));
    tags.add(
        new Tag(
            "Group", it.businesslogic.ireport.util.I18n.getString("incrementType.Group", "Group")));
    spVariableIncrementType.setShowResetButton(false);
    spVariableIncrementType.setTags(tags);
    spVariableIncrementType.setDefaultValue("None");

    spVariableIncrementGroup =
        new ComboBoxSheetProperty(
            "variableIncrementGroup",
            it.businesslogic.ireport.util.I18n.getString(
                "jRVariableDialog.label10", "Increment Group"));
    spVariableIncrementGroup.setShowResetButton(false);

    spVariableIncrementerClass =
        new SheetProperty(
            "variableIncrementerClass",
            I18n.getString("jRVariableDialog.label8", "Custom Incrementer Factory Class"),
            SheetProperty.TEXT);
    spVariableIncrementerClass.setShowResetButton(false);

    spVariableExpression =
        new ExpressionSheetProperty(
            "variableExpression",
            it.businesslogic.ireport.util.I18n.getString(
                "jRVariableDialog.label3", "Variable Expression"));
    spVariableExpression.setShowResetButton(false);

    spVariableInitialValueExpression =
        new ExpressionSheetProperty(
            "variableInitialValueExpression",
            it.businesslogic.ireport.util.I18n.getString(
                "jRVariableDialog.label4", "Initial Value Expression"));
    spVariableInitialValueExpression.setShowResetButton(false);
  }
コード例 #5
0
  /*
   * 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;
  }