@Override public Object createObject(Attributes attrs) throws Exception { JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); JRDesignGenericElement element = new JRDesignGenericElement(jasperDesign); EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime)); if (evaluationTime != null) { element.setEvaluationTime(evaluationTime); } if (element.getEvaluationTimeValue() == EvaluationTimeEnum.GROUP) { String groupName = attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup); if (groupName != null) { element.setEvaluationGroupName(groupName); } } return element; }
@Override public Object getPropertyValue(Object id) { JRDesignGenericElement jrElement = (JRDesignGenericElement) getValue(); if (id.equals(JRDesignGenericElement.PROPERTY_EVALUATION_TIME)) return evaluationTimeD.getEnumValue(jrElement.getEvaluationTimeValue()); if (id.equals(JRDesignGenericElement.PROPERTY_EVALUATION_GROUP_NAME)) return jrElement.getEvaluationGroupName(); JRGenericElementType genericType = jrElement.getGenericType(); if (genericType != null) { if (id.equals(PROPERTY_NAME)) return genericType.getName(); if (id.equals(PROPERTY_NAMESPACE)) return genericType.getNamespace(); } if (id.equals(JRDesignGenericElement.PROPERTY_PARAMETERS)) { if (propertyDTO == null) { propertyDTO = new ParameterDTO(); propertyDTO.setJasperDesign(getJasperDesign()); propertyDTO.setValue(jrElement.getParameters()); } return propertyDTO; } return super.getPropertyValue(id); }
protected void addElementParameter(JRDesignGenericElement element, String name, Object value) { JRDesignGenericElementParameter param = new JRDesignGenericElementParameter(); param.setName(name); JRDesignExpression valueExpression = builtinEvaluatorFactory.createConstantExpression(value); param.setValueExpression(valueExpression); element.addParameter(param); }
protected void addElementParameter(JRDesignGenericElement element, String name, JRExpression expression) { JRDesignGenericElementParameter param = new JRDesignGenericElementParameter(); param.setName(name); param.setValueExpression(expression); element.addParameter(param); }
protected void addColumnLabelParameters(JRDesignGenericElement element, TableComponent table) { List<BaseColumn> columns = TableUtil.getAllColumns(table); for(int i = 0, ln = columns.size(); i < ln; i++) { BaseColumn column = columns.get(i); JRExpression columnHeaderExpression = getColumnHeaderLabelExpression(column.getColumnHeader()); boolean interactiveColumn = columnInteractivityMapping.get(column).first() && (TableUtil.getCellElement(JRTextField.class, ((Column)column).getDetailCell(), true) != null); String paramName = HeaderToolbarElement.PARAM_COLUMN_LABEL_PREFIX + i + "|" + column.getUUID().toString() + "|" + interactiveColumn; addElementParameter(element, paramName, columnHeaderExpression); } }
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { super.createControls(parent, tabbedPropertySheetPage); parent.setLayout(new GridLayout(2, false)); IPropertyDescriptor pd = getPropertyDesriptor(JRDesignGenericElement.PROPERTY_EVALUATION_TIME); IPropertyDescriptor gpd = getPropertyDesriptor(JRDesignGenericElement.PROPERTY_EVALUATION_GROUP_NAME); getWidgetFactory().createCLabel(parent, pd.getDisplayName()); widgets.put(pd.getId(), new SPEvaluationTime(parent, this, pd, gpd)); createWidget4Property(parent, MGenericElement.PROPERTY_NAME); createWidget4Property(parent, MGenericElement.PROPERTY_NAMESPACE); }
@Override protected void initializeProvidedProperties() { super.initializeProvidedProperties(); addProvidedProperties(JRDesignGenericElement.PROPERTY_EVALUATION_TIME, Messages.common_evaluation_time); addProvidedProperties(MGenericElement.PROPERTY_NAME, Messages.MGenericElement_generic_type_name); addProvidedProperties(MGenericElement.PROPERTY_NAMESPACE, Messages.MGenericElement_generic_type_namespace); }
@Override public void setPropertyValue(Object id, Object value) { JRDesignGenericElement jrElement = (JRDesignGenericElement) getValue(); JRGenericElementType genericType = jrElement.getGenericType(); if (id.equals(JRDesignGenericElement.PROPERTY_EVALUATION_TIME)) jrElement.setEvaluationTime((EvaluationTimeEnum) evaluationTimeD.getEnumValue(value)); else if (id.equals(JRDesignGenericElement.PROPERTY_EVALUATION_GROUP_NAME)) jrElement.setEvaluationGroupName((String) value); else if (id.equals(JRDesignGenericElement.PROPERTY_PARAMETERS)) { if (value instanceof ParameterDTO) { ParameterDTO v = (ParameterDTO) value; if (jrElement.getParameters() != null) for (JRGenericElementParameter prm : jrElement.getParameters()) jrElement.removeParameter(prm); for (JRGenericElementParameter param : v.getValue()) jrElement.addParameter(param); propertyDTO = v; } // FIXME: in JR rewrite hashCode to work with null values for namespace and name } else if (id.equals(PROPERTY_NAME)) { String namespace = genericType != null ? genericType.getNamespace() : ""; jrElement.setGenericType(new JRGenericElementType(namespace, (String) value)); } else if (id.equals(PROPERTY_NAMESPACE)) { String name = genericType != null ? genericType.getName() : ""; jrElement.setGenericType(new JRGenericElementType((String) value, name)); } super.setPropertyValue(id, value); }
@Override public JRDesignElement createJRElement(JasperDesign jasperDesign) { JRDesignGenericElement el = new JRDesignGenericElement(jasperDesign); el.setGenericType(new JRGenericElementType("namespace", "name")); DefaultManager.INSTANCE.applyDefault(this.getClass(), el); return el; }
@Override protected void draw(JSSDrawVisitor drawVisitor, JRElement jrElement) { if (cachedGraphics == null || model.hasChangedProperty()){ model.setChangedProperty(false); Graphics2D oldGraphics = drawVisitor.getGraphics2d(); cachedGraphics = new StackGraphics2D(oldGraphics); drawVisitor.setGraphics2D(cachedGraphics); drawVisitor.visitGenericElement((JRDesignGenericElement) jrElement); drawVisitor.setGraphics2D(oldGraphics); } cachedGraphics.setRealDrawer(drawVisitor.getGraphics2d()); cachedGraphics.paintStack(); }
@Override public JRDesignElement createReportElement(JasperDesign jd) { JRDesignGenericElement element = new JRDesignGenericElement(jd); JRGenericElementType type = new JRGenericElementType("http://www.somenamespace.com", "someName"); element.setGenericType(type); element.setWidth(300); element.setHeight(200); return element; }
public static Sheet.Set getGenericElementPropertySet(JRDesignGenericElement genericElement, JasperDesign jd) { JRDesignDataset dataset = ModelUtils.getElementDataset(genericElement, jd); Sheet.Set propertySet = Sheet.createPropertiesSet(); propertySet.setName("GENERIC_ELEMENT_PROPERTIES"); propertySet.setDisplayName("Generic Element properties"); propertySet.put(new GenericElementTypeNameProperty(genericElement)); propertySet.put(new GenericElementTypeNameSpaceProperty(genericElement)); propertySet.put(new GenericElementEvaluationTimeProperty(genericElement,dataset)); propertySet.put(new GenericElementEvaluationGroupProperty(genericElement,dataset)); propertySet.put(new GenericElementParametersProperty(genericElement,dataset)); return propertySet; }
@SuppressWarnings("unchecked") public GenericElementEvaluationTimeProperty(JRDesignGenericElement element, JRDesignDataset dataset) { // TODO: Replace WhenNoDataType with the right constant super(EvaluationTimeEnum.class, element); this.element = element; this.dataset = dataset; setValue("suppressCustomEditor", Boolean.TRUE); }
@SuppressWarnings("unchecked") public GenericElementTypeNameProperty(JRDesignGenericElement element) { super(element); this.element = element; setValue("canEditAsText", true); setValue("oneline", true); setValue("suppressCustomEditor", false); }
@SuppressWarnings("unchecked") public GenericElementParametersProperty(JRDesignGenericElement element, JRDesignDataset dataset) { super( JRDesignGenericElement.PROPERTY_PARAMETERS, List.class, I18n.getString("Global.Property.Parameters"),I18n.getString("Global.Property.GenericElementparameters"), true,true); setValue("canEditAsText", Boolean.FALSE); setValue("expressionContext", new ExpressionContext(dataset)); //setValue("subreport", element); this.element = element; this.dataset = dataset; }
@SuppressWarnings("unchecked") public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (val == null || !(val instanceof List)) throw new IllegalArgumentException(); // If val is the same as the old map, the user pressed cancel // in the editor.. so nothing to do... if (val == element.getParamtersList()) return; // Fill this map with the content of the map we got here... // TODO: manage UNDO for a map object... List parameters = (List)val; element.getParamtersList().clear(); element.getParamtersList().addAll(parameters); element.getEventSupport().firePropertyChange( JRDesignGenericElement.PROPERTY_PARAMETERS , null, element.getParamtersList() ); }
@SuppressWarnings("unchecked") public GenericElementEvaluationGroupProperty(JRDesignGenericElement element, JRDesignDataset dataset) { // TODO: Replace WhenNoDataType with the right constant super( JRDesignGenericElement.PROPERTY_EVALUATION_GROUP_NAME,JRGroup.class, I18n.getString("Global.Property.Evaluationgroup"), I18n.getString("Global.Property.EvalGroupdeatail"), true, true); this.element = element; this.dataset = dataset; setValue("suppressCustomEditor", Boolean.TRUE); dataset.getEventSupport().addPropertyChangeListener(WeakListeners.propertyChange(this, dataset.getEventSupport())); }
@SuppressWarnings("unchecked") public GenericElementTypeNameSpaceProperty(JRDesignGenericElement element) { super(element); this.element = element; setValue("canEditAsText", true); setValue("oneline", true); setValue("suppressCustomEditor", false); }
/** * Creates the property descriptors. * * @param desc * the desc */ @Override public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) { super.createPropertyDescriptors(desc, defaultsMap); evaluationTimeD = new JSSEnumPropertyDescriptor(JRDesignGenericElement.PROPERTY_EVALUATION_TIME, Messages.common_evaluation_time, EvaluationTimeEnum.class, NullEnum.NOTNULL); evaluationTimeD.setDescription(Messages.MGenericElement_evaluation_time_description); desc.add(evaluationTimeD); evaluationGroupNameD = new RComboBoxPropertyDescriptor(JRDesignGenericElement.PROPERTY_EVALUATION_GROUP_NAME, Messages.MGenericElement_evaluation_group_name, new String[] { "" }); //$NON-NLS-1$ evaluationGroupNameD.setDescription(Messages.MGenericElement_evaluation_group_name_description); desc.add(evaluationGroupNameD); setHelpPrefix(desc, "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#genericElement"); NTextPropertyDescriptor nameD = new NTextPropertyDescriptor(PROPERTY_NAME, Messages.MGenericElement_generic_type_name); nameD.setDescription(Messages.MGenericElement_generic_type_name_description); desc.add(nameD); NTextPropertyDescriptor nameSpaceD = new NTextPropertyDescriptor(PROPERTY_NAMESPACE, Messages.MGenericElement_generic_type_namespace); nameSpaceD.setDescription(Messages.MGenericElement_generic_type_namespace_description); desc.add(nameSpaceD); setHelpPrefix(desc, "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#genericElementType"); ParameterPropertyDescriptor parametersD = new ParameterPropertyDescriptor( JRDesignGenericElement.PROPERTY_PARAMETERS, Messages.common_parameters); parametersD.setDescription(Messages.MGenericElement_parameters_description); desc.add(parametersD); parametersD.setHelpRefBuilder(new HelpReferenceBuilder( "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#genericElementParameter")); parametersD.setCategory(Messages.MGenericElement_generic_element_properties_category); nameD.setCategory(Messages.MGenericElement_generic_element_properties_category); nameSpaceD.setCategory(Messages.MGenericElement_generic_element_properties_category); evaluationTimeD.setCategory(Messages.MGenericElement_generic_element_properties_category); evaluationGroupNameD.setCategory(Messages.MGenericElement_generic_element_properties_category); defaultsMap.put(JRDesignGenericElement.PROPERTY_EVALUATION_TIME, EvaluationTimeEnum.NOW); }
public JRDesignElement createJRElement(JasperDesign jasperDesign) { JRDesignGenericElement jrDesignGenericElement = new JRDesignGenericElement(jasperDesign); return jrDesignGenericElement; }
public void visitGenericElement(JRGenericElement genericElement) { node = new ElementNode(jasperDesign, (JRDesignGenericElement)genericElement,doLkp); node.setIconBaseWithExtension(ICON_GENERIC_ELEMENT); }
/** * Convenient way to get all the properties of an element. * Properties positions could be reordered to have a better order. */ public static List<Sheet.Set> getPropertySets(JRDesignElement element, JasperDesign jd) { List<Sheet.Set> sets = new ArrayList<Sheet.Set>(); sets.add( getCommonPropertySet(element, jd) ); if (element instanceof JRDesignGraphicElement) { sets.addAll( GraphicElementPropertiesFactory.getGraphicPropertySets((JRDesignGraphicElement)element, jd) ); } if (element instanceof JRDesignTextElement) { sets.addAll( TextElementPropertiesFactory.getPropertySets(element, jd) ); } if (element instanceof JRDesignSubreport) { sets.addAll( SubreportPropertiesFactory.getPropertySets(element, jd) ); } if (element instanceof JRDesignBreak) { sets.add( getBreakPropertySet((JRDesignBreak)element) ); } if (element instanceof JRDesignChart) { sets.addAll( ChartPropertiesFactory.getPropertySets((JRDesignChart)element, jd) ); } if (element instanceof JRBox) { sets.add( getBoxPropertySet((JRBox)element) ); } if (element instanceof JRDesignGenericElement) { sets.add( getGenericElementPropertySet((JRDesignGenericElement)element, jd ) ); } return sets; }
@Override public String getName() { return JRDesignGenericElement.PROPERTY_EVALUATION_TIME; }
@Override public String getName() { return JRDesignGenericElement.PROPERTY_GENERIC_TYPE+"_name"; }
@Override public String getName() { return JRDesignGenericElement.PROPERTY_GENERIC_TYPE+"_namespace"; }
/** * Instantiates a new m cross tab. * * @param parent * the parent * @param jrCrosstab * the jr crosstab * @param newIndex * the new index */ public MGenericElement(ANode parent, JRDesignGenericElement jrCrosstab, int newIndex) { super(parent, newIndex); setValue(jrCrosstab); }