@Override public Object createObject(Attributes atts) { JRDesignVariable variable = (JRDesignVariable)digester.peek(); JRDesignExpression expression = new JRDesignExpression(); if ( variable.getCalculationValue() == CalculationEnum.COUNT || variable.getCalculationValue() == CalculationEnum.DISTINCT_COUNT ) { expression.setValueClassName(java.lang.Object.class.getName()); } else { expression.setValueClassName(variable.getValueClassName()); } return expression; }
private JRVariable createHelperVariable(JRVariable variable, String nameSuffix, CalculationEnum calculation) { JRDesignVariable helper = new JRDesignVariable(); helper.setName(variable.getName() + nameSuffix); helper.setValueClassName(variable.getValueClassName()); helper.setIncrementerFactoryClassName(variable.getIncrementerFactoryClassName()); helper.setResetType(variable.getResetTypeValue()); helper.setResetGroup(variable.getResetGroup()); helper.setIncrementType(variable.getIncrementTypeValue()); helper.setIncrementGroup(variable.getIncrementGroup()); helper.setCalculation(calculation); helper.setSystemDefined(true); helper.setExpression(variable.getExpression()); return helper; }
private JRVariable createDistinctCountHelperVariable(JRVariable variable) { JRDesignVariable helper = new JRDesignVariable(); helper.setName(variable.getName() + "_DISTINCT_COUNT"); helper.setValueClassName(variable.getValueClassName()); helper.setIncrementerFactoryClassName(JRDistinctCountIncrementerFactory.class.getName()); helper.setResetType(ResetTypeEnum.REPORT); if (variable.getIncrementTypeValue() != IncrementTypeEnum.NONE) { helper.setResetType(ResetTypeEnum.getByValue(variable.getIncrementTypeValue().getValue())); } helper.setResetGroup(variable.getIncrementGroup()); helper.setCalculation(CalculationEnum.NOTHING); helper.setSystemDefined(true); helper.setExpression(variable.getExpression()); return helper; }
/** * When the data is refreshed is checked if the class name is a collection, in this * case the controls to define the nested type are shown, otherwise they are hidden. */ @Override public void refresh() { setRefreshing(true); APropertyNode element = getElement(); if (element != null) { element.getPropertyDescriptors(); for (Object key : widgets.keySet()) { if (key.equals(JRDesignParameter.PROPERTY_NESTED_TYPE_NAME)){ String type = element.getPropertyValue(JRDesignVariable.PROPERTY_VALUE_CLASS_NAME).toString(); if (isClassCollection(type)) setCompVisible(true); else setCompVisible(false); } widgets.get(key).setData(element, element.getPropertyValue(key)); if (key.equals(JRDesignParameter.PROPERTY_DEFAULT_VALUE_EXPRESSION)){ // fix the visibilities mask: allows only PARAMETERS ExpressionContext expContext = ((WTextExpression) ((SPExpression) widgets.get(key)).getControl()).getExpressionContext(); if(expContext!=null){ expContext.setVisibilities(EnumSet.of(Visibility.SHOW_PARAMETERS)); } } } } setRefreshing(false); }
/** * Creates the property descriptors. * * @param desc * the desc */ @Override public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) { validator = new VariableNameValidator(); validator.setTargetNode(this); JSSTextPropertyDescriptor nameD = new JSSValidatedTextPropertyDescriptor(JRDesignVariable.PROPERTY_NAME, Messages.common_name, validator); nameD.setDescription(Messages.MVariableSystem_name_description); desc.add(nameD); NClassTypePropertyDescriptor classD = new NClassTypePropertyDescriptor(JRDesignVariable.PROPERTY_VALUE_CLASS_NAME, Messages.common_value_class_name); classD.setDescription(Messages.MVariableSystem_value_class_name_description); desc.add(classD); classD.setHelpRefBuilder(new HelpReferenceBuilder( "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#variable_class")); defaultsMap.put(JRDesignVariable.PROPERTY_VALUE_CLASS_NAME, "java.lang.String"); //$NON-NLS-1$ }
@Override public void propertyChange(PropertyChangeEvent evt) { if (JRDesignGroup.PROPERTY_NAME.equals(evt.getPropertyName())) { // Temporary fix for the Community Bug #2991 // Should be done on JR-side. Let's keep the cache map of groups in sync. JRDesignGroup jrGroup = (JRDesignGroup) getValue(); JasperDesign design = getJasperDesign(); if (design != null){ design.getGroupsMap().remove(evt.getOldValue()); design.getGroupsMap().put(jrGroup.getName(), jrGroup); //JRDesignDataset dataset = ModelUtils.getDataset(this); JRVariable groupVar = getJasperDesign().getVariablesMap().get(evt.getOldValue() + "_COUNT"); if (groupVar != null){ //This should launch the propertyChange event on the variable so the map is updated also for it ((JRDesignVariable)groupVar).setName(jrGroup.getName() + "_COUNT"); } } } super.propertyChange(evt); }
private JRDesignVariable createVariable(String name, String clazz, ResetTypeEnum rtype, JRGroup group) throws Exception { jrVariable = new JRDesignVariable(); jrVariable.setCalculation(CalculationEnum.SUM); String vname = name + "_SUM"; int i=0; while (jasperDesign.getVariablesMap().containsKey(vname)) { i++; vname = name + "_" + i + "_SUM"; } jrVariable.setName(vname); jrVariable.setResetType(rtype); if (rtype.equals(ResetTypeEnum.GROUP)) jrVariable.setResetGroup(group); jrVariable.setValueClassName(clazz); JRDesignExpression jre = new JRDesignExpression(); jre.setText("$F{" + name + "}"); jrVariable.setExpression(jre); return jrVariable; }
public VariableNode(JasperDesign jd, JRDesignVariable variable, Lookup doLkp) { super (Children.LEAF, new ProxyLookup(doLkp, Lookups.fixed(jd, variable))); this.jd = jd; this.variable = variable; setDisplayName ( variable.getName()); super.setName( variable.getName() ); if (variable.isSystemDefined()) { setIconBaseWithExtension("com/jaspersoft/ireport/designer/resources/variable-16.png"); } else { setIconBaseWithExtension("com/jaspersoft/ireport/designer/resources/variable-16.png"); } variable.getEventSupport().addPropertyChangeListener(this); }
public void propertyChange(PropertyChangeEvent evt) { com.jaspersoft.ireport.designer.IReportManager.getInstance().notifyReportChange(); if (evt.getPropertyName() == null) return; if (evt.getPropertyName().equals( JRDesignVariable.PROPERTY_NAME )) { super.setName(getVariable().getName()); this.setDisplayName(getVariable().getName()); if (this.getParentNode() != null && this.getParentNode() instanceof VariablesNode) { SwingUtilities.invokeLater(new Runnable() { public void run() { ((VariablesNode)(VariableNode.this.getParentNode())).updateSorting(); } }); } } // Update the sheet this.firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue() ); }
/** * Read all available variables from the active report and popute the combobox */ public void updateVariables() { jComboBoxSubreportVariable.removeAllItems(); jComboBoxVariable.removeAllItems(); try { List variables = IReportManager.getInstance().getActiveReport().getVariablesList(); for (int i=0; i<variables.size(); ++i) { JRDesignVariable var = (JRDesignVariable)variables.get(i); if (var.isSystemDefined()) { jComboBoxSubreportVariable.addItem( var.getName()); } else { jComboBoxVariable.addItem( var.getName()); } } } catch (Exception ex) { } }
@Override public Object createObject(Attributes atts) { JRDesignVariable variable = (JRDesignVariable)digester.peek(); JRDesignExpression expression = new JRDesignExpression(); expression.setValueClassName(variable.getValueClassName()); return expression; }
protected JRDesignCrosstabGroup() { super(); variable = designVariable = new JRDesignVariable(); designVariable.setCalculation(CalculationEnum.SYSTEM); designVariable.setSystemDefined(true); header = new JRDesignCellContents(); totalHeader = new JRDesignCellContents(); }
/** * Creates a crosstab measure. */ public JRDesignCrosstabMeasure() { super(); variable = designVariable = new JRDesignVariable(); designVariable.setCalculation(CalculationEnum.SYSTEM); designVariable.setSystemDefined(true); }
private void addBuiltinVariables() { for (int i = 0; i < BUILT_IN_VARIABLES.length; ++i) { JRDesignVariable variable = new JRDesignVariable(); variable.setName((String) BUILT_IN_VARIABLES[i]); variable.setValueClass((Class<?>) BUILT_IN_VARIABLES[++i]); variable.setCalculation(CalculationEnum.SYSTEM); variable.setSystemDefined(true); addVariable(variable); } }
protected void addTotalVar(JRCrosstabMeasure measure, JRCrosstabRowGroup rowGroup, JRCrosstabColumnGroup colGroup) { JRDesignVariable var = new JRDesignVariable(); var.setCalculation(CalculationEnum.SYSTEM); var.setSystemDefined(true); var.setName(getTotalVariableName(measure, rowGroup, colGroup)); var.setValueClassName(measure.getValueClassName()); addVariable(var); }
@Override public void execute() { super.execute(); try { if (var != null) jDataset.addVariable((JRDesignVariable) var); } catch (JRException e) { e.printStackTrace(); } }
public Image getColumnImage(Object element, int columnIndex) { switch (columnIndex) { case 0: if (element instanceof JRDesignField) return JaspersoftStudioPlugin.getInstance().getImage(MField.getIconDescriptor().getIcon16()); if (element instanceof JRDesignParameter) return JaspersoftStudioPlugin.getInstance().getImage(MParameter.getIconDescriptor().getIcon16()); if (element instanceof JRDesignVariable) return JaspersoftStudioPlugin.getInstance().getImage(MVariable.getIconDescriptor().getIcon16()); } return null; }
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { super.createControls(parent, tabbedPropertySheetPage); parent.setLayout(new GridLayout(3, false)); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; createWidget4Property(parent, JRDesignVariable.PROPERTY_CALCULATION).getControl().setLayoutData(gd); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; createWidget4Property(parent, JRDesignVariable.PROPERTY_EXPRESSION).getControl().setLayoutData(gd); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; createWidget4Property(parent, JRDesignVariable.PROPERTY_INITIAL_VALUE_EXPRESSION).getControl().setLayoutData(gd); IPropertyDescriptor pd = getPropertyDesriptor(JRDesignVariable.PROPERTY_INCREMENT_TYPE); IPropertyDescriptor gpd = getPropertyDesriptor(JRDesignVariable.PROPERTY_INCREMENT_GROUP); getWidgetFactory().createCLabel(parent, pd.getDisplayName()); SPIncrementType winctype = new SPIncrementType(parent, this, pd, gpd); gd = new GridData(); gd.horizontalSpan = 2; winctype.getControl().setLayoutData(gd); widgets.put(pd.getId(), winctype); gd = new GridData(GridData.FILL_HORIZONTAL); createWidget4Property(parent, JRDesignVariable.PROPERTY_INCREMENTER_FACTORY_CLASS_NAME).getControl().setLayoutData( gd); pd = getPropertyDesriptor(JRDesignVariable.PROPERTY_RESET_TYPE); gpd = getPropertyDesriptor(JRDesignVariable.PROPERTY_RESET_GROUP); getWidgetFactory().createCLabel(parent, pd.getDisplayName()); SPResetType wrestype = new SPResetType(parent, this, pd, gpd); gd = new GridData(); gd.horizontalSpan = 2; wrestype.getControl().setLayoutData(gd); widgets.put(pd.getId(), wrestype); }
@Override protected void initializeProvidedProperties() { super.initializeProvidedProperties(); addProvidedProperties(JRDesignVariable.PROPERTY_CALCULATION, Messages.MVariable_calculation); addProvidedProperties(JRDesignVariable.PROPERTY_EXPRESSION, Messages.common_expression); addProvidedProperties(JRDesignVariable.PROPERTY_INITIAL_VALUE_EXPRESSION, Messages.MVariable_initial_value_expression); addProvidedProperties(JRDesignVariable.PROPERTY_INCREMENT_TYPE, Messages.common_increment_type); addProvidedProperties(JRDesignVariable.PROPERTY_INCREMENTER_FACTORY_CLASS_NAME, Messages.MVariable_incrementer_factory_class_name); addProvidedProperties(JRDesignVariable.PROPERTY_RESET_TYPE, Messages.common_reset_type); }
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { super.createControls(parent, tabbedPropertySheetPage); parent.setLayout(new GridLayout(3, false)); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; createWidget4Property(parent, JRDesignVariable.PROPERTY_NAME).getControl().setLayoutData(gd); gd = new GridData(GridData.FILL_HORIZONTAL); createWidget4Property(parent, JRDesignVariable.PROPERTY_VALUE_CLASS_NAME).getControl().setLayoutData(gd); }
public String[] getToVariables() { if (toVariables == null) { List<String> res = new ArrayList<String>(); List<JRVariable> vlist = dto.getjConfig().getJasperDesign().getVariablesList(); for (Object o : vlist) { JRDesignVariable jdVar = (JRDesignVariable) o; if (!jdVar.isSystemDefined()) res.add(jdVar.getName()); } toVariables = res.toArray(new String[res.size()]); } return toVariables; }
@Override public Object getPropertyValue(Object id) { JRDesignVariable jrVariable = (JRDesignVariable) getValue(); Object s = super.getPropertyValue(id); if (s != null) return s; if (id.equals(JRDesignVariable.PROPERTY_RESET_GROUP)) { if (jrVariable.getResetTypeValue().equals(ResetTypeEnum.GROUP) && resetGroupD != null) { if (jrVariable.getResetGroup() != null){ return jrVariable.getResetGroup().getName(); } } return ""; //$NON-NLS-1$ } if (id.equals(JRDesignVariable.PROPERTY_INCREMENT_GROUP)) { if (jrVariable.getIncrementTypeValue().equals(IncrementTypeEnum.GROUP) && incrementGroupD != null) { if (jrVariable.getIncrementGroup() != null){ return jrVariable.getIncrementGroup().getName(); } } return ""; //$NON-NLS-1$ } if (id.equals(JRDesignVariable.PROPERTY_CALCULATION)) return calculationD.getEnumValue(jrVariable.getCalculationValue()); if (id.equals(JRDesignVariable.PROPERTY_RESET_TYPE)) return resetTypeD.getEnumValue(jrVariable.getResetTypeValue()); if (id.equals(JRDesignVariable.PROPERTY_INCREMENT_TYPE)) return incrementTypeD.getEnumValue(jrVariable.getIncrementTypeValue()); if (id.equals(JRDesignVariable.PROPERTY_INCREMENTER_FACTORY_CLASS_NAME)) return jrVariable.getIncrementerFactoryClassName(); if (id.equals(JRDesignVariable.PROPERTY_EXPRESSION)) { return ExprUtil.getExpression(jrVariable.getExpression()); } if (id.equals(JRDesignVariable.PROPERTY_INITIAL_VALUE_EXPRESSION)) { return ExprUtil.getExpression(jrVariable.getInitialValueExpression()); } return null; }
/** * Get a list of all the Sortfield that are using a variable, and if one of them is using * the renamed variable then its name also is updated with the new one */ @Override public Command postSetValue(IPropertySource target, Object prop, Object newValue, Object oldValue) { JSSCompoundCommand c = new JSSCompoundCommand(null); if (target instanceof MVariable && prop.equals(JRDesignVariable.PROPERTY_NAME)) { MVariable targetNode = (MVariable) target; c.setReferenceNodeIfNull(targetNode); JRDesignDataset d = ModelUtils.getDataset(targetNode); if (d != null){ for(INode field : ModelUtils.getSortFields(targetNode)){ APropertyNode sortField = (APropertyNode)field; JRDesignSortField jrField = (JRDesignSortField) sortField.getValue(); if (jrField != null){ Object fieldName = jrField.getName(); Object fieldType = jrField.getType(); if (SortFieldTypeEnum.VARIABLE.equals(fieldType) && fieldName != null && fieldName.equals(oldValue)){ SetValueCommand updateSFCommand = new SetValueCommand(); updateSFCommand.setTarget(sortField); updateSFCommand.setPropertyId(JRDesignSortField.PROPERTY_NAME); updateSFCommand.setPropertyValue(newValue); c.add(updateSFCommand); } } } } } return c; }
public DeleteVariableCommand(JasperReportsConfiguration jContext, JRDesignDataset destNode, JRDesignVariable srcNode) { super(); this.jContext = jContext; jd = jContext.getJasperDesign(); this.jrDataset = destNode; this.jrVariable = srcNode; objectName = "$V{" + jrVariable.getName() + "}"; }
public Object getPropertyValue(Object id) { JRDesignVariable jrVariable = (JRDesignVariable) getValue(); if (id.equals(JRDesignVariable.PROPERTY_NAME)) return jrVariable.getName(); if (id.equals(JRDesignVariable.PROPERTY_VALUE_CLASS_NAME)) return jrVariable.getValueClassName(); return null; }
@Override public void propertyChange(PropertyChangeEvent evt) { if (JRDesignVariable.PROPERTY_NAME.equals(evt.getPropertyName())){ JRDesignDataset d = ModelUtils.getDataset(this); JRDesignVariable jrVariable = (JRDesignVariable) getValue(); if (d != null) { d.getVariablesMap().remove(evt.getOldValue()); d.getVariablesMap().put(jrVariable.getName(), jrVariable); } } super.propertyChange(evt); }
public void setPropertyValue(Object id, Object value) { if (!isEditable()) return; JRDesignVariable jrVariable = (JRDesignVariable) getValue(); if (id.equals(JRDesignVariable.PROPERTY_NAME)){ if (!value.equals("")) { jrVariable.setName((String) value); } } else if (id.equals(JRDesignVariable.PROPERTY_VALUE_CLASS_NAME)) jrVariable.setValueClassName((String) value); }
@Override public void execute() { super.execute(); try { if (var != null) jasperDesign.addVariable((JRDesignVariable) var); } catch (JRException e) { e.printStackTrace(); } }
@Override public Command postSetValue(IPropertySource target, Object prop, Object newValue, Object oldValue) { if (target instanceof MField && prop.equals(JRDesignField.PROPERTY_NAME)) return new RenameDatasetObjectNameCommand((MField) target, (String) oldValue); if (target instanceof MVariable && prop.equals(JRDesignVariable.PROPERTY_NAME)) return new RenameDatasetObjectNameCommand((MVariable) target, (String) oldValue); if (target instanceof MParameter && prop.equals(JRDesignParameter.PROPERTY_NAME) && ((MParameter) target).getParent() != null) return new RenameDatasetObjectNameCommand((MParameter) target, (String) oldValue); if (target instanceof MDataset && prop.equals(JRDesignDataset.PROPERTY_QUERY)) return new SyncDatasetRunCommand((MDataset) target, (MQuery) newValue, (MQuery) oldValue); if (target instanceof MQuery && prop.equals(JRDesignQuery.PROPERTY_LANGUAGE)) return new SyncDatasetRunCommand((MQuery) target, (String) newValue, (String) oldValue); return null; }
public Image getColumnImage(Object element, int columnIndex) { switch (columnIndex) { case 0: if (element instanceof JRDesignField) return JaspersoftStudioPlugin.getInstance().getImage(MField.getIconDescriptor().getIcon16()); else if (element instanceof JRDesignVariable) return JaspersoftStudioPlugin.getInstance().getImage(MVariable.getIconDescriptor().getIcon16()); else if (element instanceof JRDesignParameter) return JaspersoftStudioPlugin.getInstance().getImage("icons/resources/parameter-report-16.png"); //$NON-NLS-1$ } return null; }
public String getColumnText(Object element, int columnIndex) { switch (columnIndex) { case 0: if (element instanceof JRDesignField) return ((JRDesignField) element).getName(); else if (element instanceof JRDesignVariable) return ((JRDesignVariable) element).getName(); else if (element instanceof JRDesignParameter) return ((JRDesignParameter) element).getName(); } return ""; //$NON-NLS-1$ }
@Override @SuppressWarnings("unchecked") public void setName(String s) { if (s.equals("")) { throw new IllegalArgumentException("Variable name not valid."); } List<JRVariable> currentVariables = null; JRDesignDataset dataset = getParentNode().getLookup().lookup(JRDesignDataset.class); currentVariables = (List<JRVariable>)dataset.getVariablesList(); for (JRVariable pa : currentVariables) { JRDesignVariable p = (JRDesignVariable)pa; if (p != getVariable() && p.getName().equals(s)) { throw new IllegalArgumentException("Variable name already in use."); } } String oldName = getVariable().getName(); getVariable().setName(s); dataset.getVariablesMap().remove(oldName); dataset.getVariablesMap().put(s,getVariable()); ObjectPropertyUndoableEdit opue = new ObjectPropertyUndoableEdit( getVariable(), "Name", String.class, oldName, s); IReportManager.getInstance().addUndoableEdit(opue); }
@SuppressWarnings("unchecked") public NameProperty(JRDesignVariable variable, JRDesignDataset dataset) { super(JRDesignVariable.PROPERTY_NAME, String.class, I18n.getString("VariableNode.Property.Name"), I18n.getString("VariableNode.Property.Namedetail")); this.variable = variable; this.dataset = dataset; this.setValue("oneline", Boolean.TRUE); }
@SuppressWarnings("unchecked") public ValueClassNameProperty(JRDesignVariable variable) { super(JRDesignVariable.PROPERTY_VALUE_CLASS_NAME, String.class, I18n.getString("VariableNode.Property.VariableClass"), I18n.getString("VariableNode.Property.VariableClass")); this.variable = variable; }
@SuppressWarnings("unchecked") public CalculationProperty(JRDesignVariable variable) { // TODO: Replace WhenNoDataType with the right constant super( JRDesignVariable.PROPERTY_CALCULATION,CalculationEnum.class, I18n.getString("VariableNode.Property.Calculation"), I18n.getString("VariableNode.Property.Calculationdetail"), true, true); //this.dataset = dataset; this.variable = variable; setValue("suppressCustomEditor", Boolean.TRUE); }
@SuppressWarnings("unchecked") public ResetTypeProperty(JRDesignVariable variable, JRDesignDataset dataset) { // TODO: Replace WhenNoDataType with the right constant super( JRDesignVariable.PROPERTY_RESET_TYPE,ResetTypeEnum.class, I18n.getString("VariableNode.Property.Resettype"), I18n.getString("VariableNode.Property.Resettypedetail"), true, true); this.variable = variable; this.dataset = dataset; setValue("suppressCustomEditor", Boolean.TRUE); }
@SuppressWarnings("unchecked") public ResetGroupProperty(JRDesignVariable variable, JRDesignDataset dataset) { // TODO: Replace WhenNoDataType with the right constant super( JRDesignVariable.PROPERTY_RESET_GROUP,JRGroup.class, I18n.getString("VariableNode.Property.Resetgroup"), I18n.getString("VariableNode.Property.Resetgroupdetail"), true, true); this.variable = variable; this.dataset = dataset; dataset.getEventSupport().addPropertyChangeListener(WeakListeners.propertyChange(this, dataset.getEventSupport())); setValue("suppressCustomEditor", Boolean.TRUE); }
@SuppressWarnings("unchecked") public IncrementTypeProperty(JRDesignVariable variable, JRDesignDataset dataset) { // TODO: Replace WhenNoDataType with the right constant super( JRDesignVariable.PROPERTY_INCREMENT_TYPE,IncrementTypeEnum.class, I18n.getString("VariableNode.Property.Incrementtype"), I18n.getString("VariableNode.Property.Incrementtypedetail"), true, true); this.variable = variable; this.dataset = dataset; setValue("suppressCustomEditor", Boolean.TRUE); }