/** * */ public void verifyHyperlink(JRHyperlink hyperlink) { if (hyperlink != null) { JRHyperlinkParameter[] parameters = hyperlink.getHyperlinkParameters(); if (parameters != null) { for (int i = 0; i < parameters.length; i++) { JRHyperlinkParameter parameter = parameters[i]; verifyHyperlinkParameter(parameter); } } } }
/** * Drop action, get a list of string from the event, where the first position it the name of the unit and the other * are the parameters of the unit, using this set the parameter inside the element model */ @Override protected void handleDrop() { if (getTargetEditPart() instanceof TextFieldFigureEditPart || getTargetEditPart() instanceof ImageFigureEditPart){ APropertyNode textField = (APropertyNode)getTargetEditPart().getModel(); if (textField != null){ ParameterDTO parameters = (ParameterDTO)textField.getPropertyValue(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS); if (parameters.getValue()== null){ parameters.setValue(new JRHyperlinkParameter[0]); } //JRHyperlinkParameter[] params = parameters.getValue(); List<JRHyperlinkParameter> newParams = new ArrayList<JRHyperlinkParameter>(); //newParams.addAll(Arrays.asList(params)); String[] dropParameters = (String[])getCurrentEvent().data; newParams.add(generateParameter("_report", dropParameters[0])); for(int i=1; i<dropParameters.length;i++){ newParams.add(generateParameter(dropParameters[i], "")); } parameters.setValue(newParams.toArray(new JRHyperlinkParameter[newParams.size()])); textField.setPropertyValue(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS, parameters); textField.setPropertyValue(JRDesignHyperlink.PROPERTY_LINK_TYPE, "ReportExecution"); } } }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus,row, column); setIcon(null); if (value instanceof JRHyperlinkParameter && value != null) { setText( ((JRHyperlinkParameter)value).getName() ); } else if (value instanceof JRExpression) { setText( Misc.getExpressionText( (JRExpression)value )); } return this; }
public static JRHyperlinkParameter[] copyHyperlinkParameters(JRHyperlink link, JRBaseObjectFactory factory) { JRHyperlinkParameter[] linkParameters = link.getHyperlinkParameters(); JRHyperlinkParameter[] parameters = null; if (linkParameters != null && linkParameters.length > 0) { parameters = new JRHyperlinkParameter[linkParameters.length]; for (int i = 0; i < linkParameters.length; i++) { JRHyperlinkParameter parameter = linkParameters[i]; parameters[i] = factory.getHyperlinkParameter(parameter); } } return parameters; }
/** * Creates an instance equivalent to an existing hyperlink parameter. * * @param parameter the parameter to replicate * @param factory the base object factory */ public JRBaseHyperlinkParameter(JRHyperlinkParameter parameter, JRBaseObjectFactory factory) { factory.put(parameter, this); this.name = parameter.getName(); this.valueExpression = factory.getExpression(parameter.getValueExpression()); }
private static void addHyperlinkParameterRules(Digester digester) { String hyperlinkParameterPattern = "*/" + JRXmlConstants.ELEMENT_hyperlinkParameter; digester.addFactoryCreate(hyperlinkParameterPattern, JRHyperlinkParameterFactory.class.getName()); digester.addSetNext(hyperlinkParameterPattern, "addHyperlinkParameter", JRHyperlinkParameter.class.getName()); String hyperlinkParameterExpressionPattern = hyperlinkParameterPattern + '/' + JRXmlConstants.ELEMENT_hyperlinkParameterExpression; @SuppressWarnings("deprecation") Class<?> lcDepStringExprFactoryClass = JRStringExpressionFactory.class; digester.addFactoryCreate(hyperlinkParameterExpressionPattern, lcDepStringExprFactoryClass.getName()); digester.addSetNext(hyperlinkParameterExpressionPattern, "setValueExpression", JRExpression.class.getName()); digester.addCallMethod(hyperlinkParameterExpressionPattern, "setText", 0); }
protected void writeHyperlinkParameters(JRHyperlinkParameter[] parameters) throws IOException { if (parameters != null) { for (int i = 0; i < parameters.length; i++) { JRHyperlinkParameter parameter = parameters[i]; writeHyperlinkParameter(parameter); } } }
protected void writeHyperlinkParameter(JRHyperlinkParameter parameter) throws IOException { if (parameter != null) { writer.startElement(JRXmlConstants.ELEMENT_hyperlinkParameter, JASPERREPORTS_NAMESPACE); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, parameter.getName()); writeExpression(JRXmlConstants.ELEMENT_hyperlinkParameterExpression, parameter.getValueExpression(), true, String.class.getName()); writer.closeElement(); } }
/** * */ protected void writeHyperlinkParameters( JRHyperlinkParameter[] parameters, String parentName) { if (parameters != null) { for (int i = 0; i < parameters.length; i++) { JRHyperlinkParameter parameter = parameters[i]; writeHyperlinkParameter( parameter, parentName + "HyperlinkParameter" +i); write( parentName + ".addHyperlinkParameter(" + parentName + "HyperlinkParameter" + i + ");\n"); } flush(); } }
/** * */ protected void writeHyperlinkParameter( JRHyperlinkParameter parameter, String parameterName) { if (parameter != null) { write( "JRDesignHyperlinkParameter " + parameterName + " = new JRDesignHyperlinkParameter();\n"); write( parameterName + ".setName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(parameter.getName())); writeExpression( parameter.getValueExpression(), parameterName, "ValueExpression", String.class.getName()); flush(); } }
/** * */ public JRDesignTextField() { super(null); hyperlinkParameters = new ArrayList<JRHyperlinkParameter>(); }
/** * */ public JRDesignTextField(JRDefaultStyleProvider defaultStyleProvider) { super(defaultStyleProvider); hyperlinkParameters = new ArrayList<JRHyperlinkParameter>(); }
@Override public JRHyperlinkParameter[] getHyperlinkParameters() { JRHyperlinkParameter[] parameters; if (hyperlinkParameters.isEmpty()) { parameters = null; } else { parameters = new JRHyperlinkParameter[hyperlinkParameters.size()]; hyperlinkParameters.toArray(parameters); } return parameters; }
/** * Adds a custom hyperlink parameter. * * @param parameter the parameter to add */ public void addHyperlinkParameter(JRHyperlinkParameter parameter) { hyperlinkParameters.add(parameter); getEventSupport().fireCollectionElementAddedEvent(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS, parameter, hyperlinkParameters.size() - 1); }
/** * Removes a custom hyperlink parameter. * * @param parameter the parameter to remove */ public void removeHyperlinkParameter(JRHyperlinkParameter parameter) { int idx = hyperlinkParameters.indexOf(parameter); if (idx >= 0) { hyperlinkParameters.remove(idx); getEventSupport().fireCollectionElementRemovedEvent(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS, parameter, idx); } }
/** * Removes a custom hyperlink parameter. * <p> * If multiple parameters having the specified name exist, all of them * will be removed * </p> * * @param parameterName the parameter name */ public void removeHyperlinkParameter(String parameterName) { for (ListIterator<JRHyperlinkParameter> it = hyperlinkParameters.listIterator(); it.hasNext();) { JRHyperlinkParameter parameter = it.next(); if (parameter.getName() != null && parameter.getName().equals(parameterName)) { it.remove(); getEventSupport().fireCollectionElementRemovedEvent(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS, parameter, it.nextIndex()); } } }
protected void verifyHyperlinkParameter(JRHyperlinkParameter parameter) { if (parameter != null) { String name = parameter.getName(); if (name == null || name.length() == 0) { addBrokenRule("Hyperlink parameter name missing.", parameter); } } }
/** * Adds a custom hyperlink parameter. * * @param parameter the parameter to add */ public void addHyperlinkParameter(JRHyperlinkParameter parameter) { hyperlinkParameters.add(parameter); getEventSupport().fireCollectionElementAddedEvent(PROPERTY_HYPERLINK_PARAMETERS, parameter, hyperlinkParameters.size() - 1); }
/** * Removes a custom hyperlink parameter. * * @param parameter the parameter to remove */ public void removeHyperlinkParameter(JRHyperlinkParameter parameter) { int idx = hyperlinkParameters.indexOf(parameter); if (idx >= 0) { hyperlinkParameters.remove(idx); getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_HYPERLINK_PARAMETERS, parameter, idx); } }
/** * Removes a custom hyperlink parameter. * <p> * If multiple parameters having the specified name exist, all of them * will be removed * </p> * * @param parameterName the parameter name */ public void removeHyperlinkParameter(String parameterName) { for (ListIterator<JRHyperlinkParameter> it = hyperlinkParameters.listIterator(); it.hasNext();) { JRHyperlinkParameter parameter = it.next(); if (parameter.getName() != null && parameter.getName().equals(parameterName)) { it.remove(); getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_HYPERLINK_PARAMETERS, parameter, it.nextIndex()); } } }
/** * */ public JRDesignChart(JRDefaultStyleProvider defaultStyleProvider, byte chartType) { super(defaultStyleProvider); setChartType(chartType); hyperlinkParameters = new ArrayList<JRHyperlinkParameter>(); lineBox = new JRBaseLineBox(this); }
/** * */ public JRDesignImage(JRDefaultStyleProvider defaultStyleProvider) { super(defaultStyleProvider); hyperlinkParameters = new ArrayList<JRHyperlinkParameter>(); lineBox = new JRBaseLineBox(this); }
/** * Evaluates a list of hyperlink parameters and produces a hyperlink parameters set * that can be associated with a print element. * * @param hyperlink the hyperlink instance * @param expressionEvaluator the expression evaluator to use for evaluation parameter value * @param evaluationType the evaluation type * @return a print hyperlink parameters set * @throws JRException */ public static JRPrintHyperlinkParameters evaluateHyperlinkParameters( JRHyperlink hyperlink, JRFillExpressionEvaluator expressionEvaluator, byte evaluationType) throws JRException { JRHyperlinkParameter[] hyperlinkParameters = hyperlink.getHyperlinkParameters(); JRPrintHyperlinkParameters printParameters; if (hyperlinkParameters == null) { printParameters = null; } else { printParameters = new JRPrintHyperlinkParameters(); for (int i = 0; i < hyperlinkParameters.length; i++) { JRHyperlinkParameter hyperlinkParameter = hyperlinkParameters[i]; JRExpression valueExpression = hyperlinkParameter.getValueExpression(); Class<?> valueClass; Object value; if (valueExpression == null) { value = null; valueClass = Object.class; } else { value = expressionEvaluator.evaluate(valueExpression, evaluationType); valueClass = value == null ? Object.class : value.getClass(); } JRPrintHyperlinkParameter printParam = new JRPrintHyperlinkParameter(hyperlinkParameter.getName(), valueClass.getName(), value); printParameters.addParameter(printParam); } } return printParameters; }
private void writeHyperlinkParameters(JRHyperlinkParameter[] parameters, JRXmlWriteHelper writer) throws IOException { if (parameters != null) { for (int i = 0; i < parameters.length; i++) { JRHyperlinkParameter parameter = parameters[i]; writeHyperlinkParameter(parameter, writer); } } }
private void writeHyperlinkParameter(JRHyperlinkParameter parameter, JRXmlWriteHelper writer) throws IOException { if (parameter != null) { writer.startElement(JRXmlConstants.ELEMENT_hyperlinkParameter, JRXmlWriter.JASPERREPORTS_NAMESPACE); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, parameter.getName()); writeExpression(JRXmlConstants.ELEMENT_hyperlinkParameterExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, parameter.getValueExpression(), false, writer); writer.closeElement(); } }
public StandardChartSettings(ChartSettings chart, JRBaseObjectFactory factory) { showLegend = chart.getShowLegend(); backcolor = chart.getBackcolor(); linkType = chart.getLinkType(); linkTarget = chart.getLinkTarget(); titlePosition = chart.getTitlePosition(); titleColor = chart.getTitleColor(); subtitleColor = chart.getSubtitleColor(); legendColor = chart.getLegendColor(); legendBackgroundColor = chart.getLegendBackgroundColor(); legendPosition = chart.getLegendPosition(); renderType = chart.getRenderType(); titleFont = chart.getTitleFont(); subtitleFont = chart.getSubtitleFont(); legendFont = chart.getLegendFont(); titleExpression = factory.getExpression(chart.getTitleExpression()); subtitleExpression = factory.getExpression(chart.getSubtitleExpression()); anchorNameExpression = factory.getExpression(chart.getAnchorNameExpression()); hyperlinkReferenceExpression = factory.getExpression(chart.getHyperlinkReferenceExpression()); hyperlinkWhenExpression = factory.getExpression(chart.getHyperlinkWhenExpression()); hyperlinkAnchorExpression = factory.getExpression(chart.getHyperlinkAnchorExpression()); hyperlinkPageExpression = factory.getExpression(chart.getHyperlinkPageExpression()); hyperlinkTooltipExpression = factory.getExpression(chart.getHyperlinkTooltipExpression()); bookmarkLevel = chart.getBookmarkLevel(); customizerClass = chart.getCustomizerClass(); JRHyperlinkParameter[] hyperlinkParams = chart.getHyperlinkParameters(); if (hyperlinkParams != null && hyperlinkParams.length > 0) { for(int i = 0; i < hyperlinkParams.length; i++) { addHyperlinkParameter(factory.getHyperlinkParameter(hyperlinkParams[i])); } } }
@Override public JRHyperlinkParameter[] getHyperlinkParameters() { JRHyperlinkParameter[] parameters = null; if (!hyperlinkParameters.isEmpty()) { parameters = new JRHyperlinkParameter[hyperlinkParameters.size()]; hyperlinkParameters.toArray(parameters); } return parameters; }
public static void collectExpressions(ChartSettings chart, JRExpressionCollector collector) { if(chart != null) { collector.addExpression(chart.getTitleExpression()); collector.addExpression(chart.getSubtitleExpression()); collector.addExpression(chart.getAnchorNameExpression()); collector.addExpression(chart.getHyperlinkReferenceExpression()); collector.addExpression(chart.getHyperlinkWhenExpression()); collector.addExpression(chart.getHyperlinkAnchorExpression()); collector.addExpression(chart.getHyperlinkPageExpression()); collector.addExpression(chart.getHyperlinkTooltipExpression()); JRHyperlinkParameter[] hyperlinkParameters = chart.getHyperlinkParameters(); if (hyperlinkParameters != null) { for (int i = 0; i < hyperlinkParameters.length; i++) { JRHyperlinkParameter parameter = hyperlinkParameters[i]; if (parameter != null) { collector.addExpression(parameter.getValueExpression()); } } } } }