public static List<?> getGroupList(TableComponent table, JRReport report) { List<?> groupsList = null; JRDatasetRun datasetRun = table.getDatasetRun(); if (datasetRun != null) { String dataSetName = datasetRun.getDatasetName(); JRDataset[] datasets = report.getDatasets(); if (datasets != null && dataSetName != null) { for (JRDataset ds : datasets) { JRGroup[] groups = ds.getGroups(); if (dataSetName.equals(ds.getName()) && groups != null) { groupsList = Arrays.asList(groups); break; } } } } return groupsList; }
/** * */ protected JRBaseGroup getGroup(JRGroup group) { JRBaseGroup baseGroup = null; if (group != null) { baseGroup = (JRBaseGroup)get(group); if (baseGroup == null) { baseGroup = new JRBaseGroup(group, this); } } return baseGroup; }
/** * */ protected JRBaseGroup(JRGroup group, JRBaseObjectFactory factory) { factory.put(group, this); name = group.getName(); isStartNewColumn = group.isStartNewColumn(); isStartNewPage = group.isStartNewPage(); isResetPageNumber = group.isResetPageNumber(); isReprintHeaderOnEachPage = group.isReprintHeaderOnEachPage(); isReprintHeaderOnEachColumn = group.isReprintHeaderOnEachColumn(); minHeightToStartNewPage = group.getMinHeightToStartNewPage(); minDetailsToStartFromTop = group.getMinDetailsToStartFromTop(); footerPositionValue = group.getFooterPositionValue(); keepTogether = group.isKeepTogether(); preventOrphanFooter = group.isPreventOrphanFooter(); expression = factory.getExpression(group.getExpression()); groupHeaderSection = factory.getSection(group.getGroupHeaderSection()); groupFooterSection = factory.getSection(group.getGroupFooterSection()); countVariable = factory.getVariable(group.getCountVariable()); }
protected JRGroup resolveGroup(String groupName, XmlLoaderReportContext context) { JRGroup group; if (context == null) { // main dataset groups Map<String,JRGroup> groupsMap = jasperDesign.getGroupsMap(); group = groupsMap.get(groupName); } else { String datasetName = context.getSubdatesetName(); JRDesignDataset dataset = (JRDesignDataset) jasperDesign.getDatasetMap().get(datasetName); if (dataset == null) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_SUBDATASET_NOT_FOUND, new Object[]{datasetName}); } group = dataset.getGroupsMap().get(groupName); } return group; }
/** * Visits all the elements of a report. * * @param report the report */ public void visitReport(JRReport report) { visitBand(report.getBackground()); visitBand(report.getTitle()); visitBand(report.getPageHeader()); visitBand(report.getColumnHeader()); visitSection(report.getDetailSection()); visitBand(report.getColumnFooter()); visitBand(report.getPageFooter()); visitBand(report.getLastPageFooter()); visitBand(report.getSummary()); visitBand(report.getNoData()); JRGroup[] groups = report.getGroups(); if (groups != null) { for(int i = 0; i < groups.length; i++) { JRGroup group = groups[i]; visitSection(group.getGroupHeaderSection()); visitSection(group.getGroupFooterSection()); } } }
/** * Removes a group from the dataset. * * @param group the group to be removed * @return the group to be removed */ public JRGroup removeGroup(JRGroup group) { if (group != null) { removeVariable(group.getCountVariable()); int idx = groupsList.indexOf(group); if (idx >= 0) { groupsList.remove(idx); groupsMap.remove(group.getName()); getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_GROUPS, group, idx); } } return group; }
/** * */ public JRFillGroup getGroup(JRGroup group) { JRFillGroup fillGroup = null; if (group != null) { fillGroup = (JRFillGroup)get(group); if (fillGroup == null) { fillGroup = new JRFillGroup(group, this); } } return fillGroup; }
/** * */ private void setNewGroupInBands(JRGroup group) { title.setNewGroup(group, true); pageHeader.setNewGroup(group, true); columnHeader.setNewGroup(group, true); detailSection.setNewGroup(group, true); columnFooter.setNewGroup(group, true); pageFooter.setNewGroup(group, true); lastPageFooter.setNewGroup(group, true); summary.setNewGroup(group, true); if (groups != null && groups.length > 0) { for(int i = 0; i < groups.length; i++) { ((JRFillSection)groups[i].getGroupHeaderSection()).setNewGroup(group, true); ((JRFillSection)groups[i].getGroupFooterSection()).setNewGroup(group, true); } } }
/** * */ private void setNewGroupInBands(JRGroup group) { title.setNewGroup(group, true); pageHeader.setNewGroup(group, true); columnHeader.setNewGroup(group, true); detailSection.setNewGroup(group, true); columnFooter.setNewGroup(group, true); pageFooter.setNewGroup(group, true); lastPageFooter.setNewGroup(group, true); summary.setNewGroup(group, true); noData.setNewGroup(group, true); if (groups != null && groups.length > 0) { for(int i = 0; i < groups.length; i++) { ((JRFillSection)groups[i].getGroupHeaderSection()).setNewGroup(group, true); ((JRFillSection)groups[i].getGroupFooterSection()).setNewGroup(group, true); } } }
@Override protected void postDescriptors(IPropertyDescriptor[] descriptors) { super.postDescriptors(descriptors); // initialize style JasperDesign jasperDesign = getJasperDesign(); if (jasperDesign != null) { // initialize groups JRGroup[] groups = jasperDesign.getGroups(); String[] items = new String[groups.length + 1]; items[0] = ""; //$NON-NLS-1$ for (int j = 0; j < groups.length; j++) { items[j + 1] = groups[j].getName(); } setGroupItems(items); } }
private boolean fillGroupCombo(Combo widget){ List<JRGroup> groupsList = datasetInstance.getJasperDesign().getGroupsList(); if (groupsList==null || groupsList.isEmpty()){ MessageDialog.openWarning(getShell(), Messages.EditableDatasetBaseComposite_NoGroupsErrTitle, Messages.EditableDatasetBaseComposite_NoGroupsErrMsg); widget.setItems(new String[0]); widget.setEnabled(false); return false; } else { List<String> groupLst=new ArrayList<String>(); for (JRGroup g : groupsList){ groupLst.add(g.getName()); } widget.setEnabled(true); widget.setItems(groupLst.toArray(new String[]{})); return true; } }
@Override protected void postDescriptors(IPropertyDescriptor[] descriptors) { super.postDescriptors(descriptors); // initialize style JasperDesign jd = getJasperDesign(); if (jd != null && getValue() != null) { JRDataset dataset = getElementDataset(); //Calculate the groups list for the current element if (dataset != null){ JRGroup[] groups = dataset.getGroups(); String[] items = new String[groups.length]; for (int j = 0; j < groups.length; j++) { items[j] = groups[j].getName(); } setGroupItems(items); } } }
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; }
/** * Returns <code>true</code> if the selected objects is a group that can be moved down. false otherwise * * @return if the command should be enabled */ protected boolean calculateEnabled(List<?> editparts) { List<APropertyNode> selection = getOperationSet(editparts); if (selection.size() == 1) { APropertyNode groupNode = getOperationSet(editparts).get(0); MGroup groupElement = null; if (groupNode instanceof MBandGroupHeader) { groupElement = ((MBandGroupHeader) groupNode).getMGroup(); } else if (groupNode instanceof MBandGroupFooter) { groupElement = ((MBandGroupFooter) groupNode).getMGroup(); } List<JRGroup> groupList = groupNode.getJasperDesign().getGroupsList(); int index = groupList.indexOf(groupElement.getValue()); if (index <= 0) return false; return true; } return false; }
/** * Returns <code>true</code> if the selected objects is a group that can be moved down. false otherwise * * @return if the command should be enabled */ protected boolean calculateEnabled(List<?> editparts) { List<APropertyNode> selection = getOperationSet(editparts); if (selection.size() == 1) { APropertyNode groupNode = getOperationSet(editparts).get(0); MGroup groupElement = null; if (groupNode instanceof MBandGroupHeader) { groupElement = ((MBandGroupHeader) groupNode).getMGroup(); } else if (groupNode instanceof MBandGroupFooter) { groupElement = ((MBandGroupFooter) groupNode).getMGroup(); } List<JRGroup> groupList = groupNode.getJasperDesign().getGroupsList(); int index = groupList.indexOf(groupElement.getValue()); if (index == groupList.size() - 1) return false; return true; } return false; }
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (val instanceof JRGroup) { JRGroup oldValue = variable.getResetGroup(); JRGroup newValue = (JRGroup)val; variable.setResetGroup(newValue); ObjectPropertyUndoableEdit urob = new ObjectPropertyUndoableEdit( variable, "ResetGroup", JRGroup.class, oldValue,newValue); // Find the undoRedo manager... IReportManager.getInstance().addUndoableEdit(urob); } }
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (val instanceof JRGroup) { JRGroup oldValue = variable.getIncrementGroup(); JRGroup newValue = (JRGroup)val; variable.setIncrementGroup(newValue); ObjectPropertyUndoableEdit urob = new ObjectPropertyUndoableEdit( variable, "IncrementGroup", JRGroup.class, oldValue,newValue); // Find the undoRedo manager... IReportManager.getInstance().addUndoableEdit(urob); } }
@Override @SuppressWarnings("unchecked") public PropertyEditor getPropertyEditor() { if (editor == null) { java.util.ArrayList l = new java.util.ArrayList(); List groups = dataset.getGroupsList(); for (int i=0; i<groups.size(); ++i) { JRGroup group = (JRGroup)groups.get(i); l.add(new Tag( group , group.getName())); } editor = new ComboBoxPropertyEditor(false, l); } return editor; }
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (val instanceof JRGroup) { JRGroup oldValue = element.getEvaluationGroup(); JRGroup newValue = (JRGroup)val; element.setEvaluationGroup(newValue); ObjectPropertyUndoableEdit urob = new ObjectPropertyUndoableEdit( element, "EvaluationGroup", JRGroup.class, oldValue,newValue); // Find the undoRedo manager... IReportManager.getInstance().addUndoableEdit(urob); } }
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (val == null || val instanceof JRGroup) { JRGroup oldValue = element.getPrintWhenGroupChanges(); JRGroup newValue = (JRGroup)val; element.setPrintWhenGroupChanges(newValue); ObjectPropertyUndoableEdit urob = new ObjectPropertyUndoableEdit( element, "PrintWhenGroupChanges", JRGroup.class, oldValue,newValue); // Find the undoRedo manager... IReportManager.getInstance().addUndoableEdit(urob); } }
private void jComboBoxIncrementGroupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxIncrementGroupActionPerformed if (isInit() || currentSelectedChartElement == null) return; String name = (String)jComboBoxIncrementGroup.getSelectedItem(); if (name != null && name.trim().length() != 0) { ((JRDesignChartDataset)currentSelectedChartElement.getDataset()).setIncrementGroup( (JRGroup)getChartDataset().getGroupsMap().get(name)); } else { ((JRDesignChartDataset)currentSelectedChartElement.getDataset()).setIncrementGroup(null); } System.out.println("Increment group set to: " + ((JRDesignChartDataset)currentSelectedChartElement.getDataset()).getIncrementGroup()); System.out.flush(); }
/** * This method update the comboboxes where is present the goup list. */ public void updateGroups() { if (getJasperDesign() == null) { jComboBoxResetGroup.removeAllItems(); } else { List<String> groupNames = new ArrayList<String>(); List groups = getChartDataset().getGroupsList(); for (int i=0; i<groups.size(); ++i) { groupNames.add( ((JRGroup)groups.get(i)).getName()); } Misc.updateComboBox(jComboBoxResetGroup, groupNames); Misc.updateComboBox(jComboBoxIncrementGroup, groupNames); } }
/** * This method update the comboboxes where is present the goup list. */ public void updateGroups() { if (getJasperDesign() == null) { jComboBoxResetGroup.removeAllItems(); } else { List<String> groupNames = new ArrayList<String>(); List groups = getCrosstabDataset().getGroupsList(); for (int i=0; i<groups.size(); ++i) { groupNames.add( ((JRGroup)groups.get(i)).getName()); } Misc.updateComboBox(jComboBoxResetGroup, groupNames); Misc.updateComboBox(jComboBoxIncrementGroup, groupNames); } }
@Override public void setPropertyValue(Object val) { element.setEvaluationTime((EvaluationTimeEnum)val); // We need to select a group here.... if (val == EvaluationTimeEnum.GROUP) { String newGroupValue = ((JRGroup)dataset.getGroupsList().get(0)).getName(); String oldGroupValue = element.getEvaluationGroupName(); if ( (oldGroupValue == null || newGroupValue == null) && (oldGroupValue != newGroupValue) || (oldGroupValue != null && newGroupValue != null && !oldGroupValue.equals(newGroupValue))) { ObjectPropertyUndoableEdit urobGroup = new ObjectPropertyUndoableEdit( element, "EvaluationGroupName", String.class, oldGroupValue,newGroupValue); element.setEvaluationGroupName(newGroupValue); IReportManager.getInstance().addUndoableEdit(urobGroup, true); } } }
@Override public void setPropertyValue(Object val) { element.setEvaluationTime((EvaluationTimeEnum)val); // We need to select a group here.... if (val == EvaluationTimeEnum.GROUP) { JRGroup newGroupValue = ((JRGroup)dataset.getGroupsList().get(0)); JRGroup oldGroupValue = element.getEvaluationGroup(); if ( ((newGroupValue == null || oldGroupValue == null) && (newGroupValue != oldGroupValue)) || (oldGroupValue != null && newGroupValue != null && !oldGroupValue.getName().equals(newGroupValue.getName()))) { ObjectPropertyUndoableEdit urobGroup = new ObjectPropertyUndoableEdit( element, "EvaluationGroupName", String.class, oldGroupValue,newGroupValue); element.setEvaluationGroup(newGroupValue); IReportManager.getInstance().addUndoableEdit(urobGroup, true); } } }
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (val instanceof JRGroup) { String oldValue = element.getEvaluationGroupName(); String newValue = null; if (val != null) { newValue = ((JRGroup)val).getName(); } ; element.setEvaluationGroupName(newValue); ObjectPropertyUndoableEdit urob = new ObjectPropertyUndoableEdit( element, "EvaluationGroupName", String.class, oldValue,newValue); // Find the undoRedo manager... IReportManager.getInstance().addUndoableEdit(urob); } }
/** * This method checks that all the mandatory fields are * filled. This is not the best place for this method, it * should go in ReportGroupWizardPanel1, but here it's more * easy access each single UI component. * This method is called by ReportGroupWizardPanel1.validateForm() */ public boolean validateForm() { if (jTextField1.getText().trim().length() == 0) return false; // Check it the group name is already in use... List v = getWizardPanel().getJasperDesign().getGroupsList(); String s = jTextField1.getText().trim(); jLabelErrorMessage.setText(" "); for (int i=0; i<v.size(); ++i) { if (s.equals( ((JRGroup)v.get(i)).getName())) { jLabelErrorMessage.setText(I18n.getString("ReportGroupVisualPanel1.Message.Error")); return false; } } if (jRadioButton1.isSelected() && jComboBoxObject.getSelectedItem() != null) return true; if (jRadioButton2.isSelected()) return true; return false; }
@Override public void test() { super.test(); numberOfPagesTest(1); elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 16); elementPositionTest("columnHeader.filler1", 0, 0, 0, 10, 16); elementPositionTest("detail.list1", 0, 10, 42, 575, 16); elementPositionTest("detail.list1", 1, 10, 58, 575, 16); //group1 groupHeaderPositionTest(group1, 0, 10, 26, 575, 16); //column2 columnTitlePositionTest(column2, 0, 10, 0, 565, 16); columnDetailPositionTest(column2, 0, 10, 0, 565, 16); columnDetailPositionTest(column2, 1, 10, 0, 565, 16); //summary elementPositionTest("subtotalGroupFooter.list1", 0, 10, 816, 575, 16); subtotalPositionTest(subtotal1, 0, 10, 0, 565, 16); JRGroup jrGroup = getJasperReport().getGroups()[0]; Assert.assertTrue("Keep together", jrGroup.isKeepTogether()); Assert.assertEquals("Min height to start new page", new Integer(100), jrGroup.getMinHeightToStartNewPage()); }
/** * */ public JRBand[] getAllBands() { List<JRBand> bands = new ArrayList<JRBand>(); addBand(title, bands); addBand(pageHeader, bands); addBand(columnHeader, bands); JRGroup[] groups = mainDataset.getGroups(); if (groups != null) { for (JRGroup group : groups) { addBands(group.getGroupHeaderSection(), bands); addBands(group.getGroupFooterSection(), bands); } } addBands(detailSection, bands); addBand(columnFooter, bands); addBand(pageFooter, bands); addBand(lastPageFooter, bands); addBand(summary, bands); addBand(noData, bands); return bands.toArray(new JRBand[bands.size()]); }
public GroupFillParts(JRGroup group, JRFillObjectFactory fillFactory) { // this should have already been created fillGroup = fillFactory.getGroup(group); headerParts = new FillParts(group.getGroupHeaderSection(), fillFactory); footerParts = new FillParts(group.getGroupFooterSection(), fillFactory); groupEvaluatedParts = new ArrayList<DelayedPrintPart>(); }
/** * */ private void assignGroupReferences() throws JRException { for (Map.Entry<XmlGroupReference, XmlLoaderReportContext> entry : groupReferences.entrySet()) { XmlGroupReference reference = entry.getKey(); XmlLoaderReportContext context = entry.getValue(); String groupName = null; JRGroup group = reference.getGroupReference(); if (group != null) { groupName = group.getName(); group = resolveGroup(groupName, context); } if (!ignoreConsistencyProblems && group == null) { reference.groupNotFound(groupName); } else { reference.assignGroup(group); } } }
private String getGroupName(JRGroup group) { if(group != null) { if(groupsMap.get(group.getName()) == null) { writeGroup( group); } return group.getName(); } return null; }
/** * */ public void setEvaluationGroup(JRGroup evaluationGroup) { Object old = this.evaluationGroup; this.evaluationGroup = evaluationGroup; getEventSupport().firePropertyChange(PROPERTY_EVALUATION_GROUP, old, this.evaluationGroup); }
/** * */ public void setResetGroup(JRGroup group) { Object old = this.resetGroup; this.resetGroup = group; getEventSupport().firePropertyChange(PROPERTY_RESET_GROUP, old, this.resetGroup); }
/** * */ public void setIncrementGroup(JRGroup group) { Object old = this.incrementGroup; this.incrementGroup = group; getEventSupport().firePropertyChange(PROPERTY_INCREMENT_GROUP, old, this.incrementGroup); }
/** * */ public void setEvaluationGroup(JRGroup group) { Object old = this.evaluationGroup; this.evaluationGroup = group; getEventSupport().firePropertyChange(PROPERTY_EVALUATION_GROUP, old, this.evaluationGroup); }