/** * */ 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); } } } }
/** * Evaluate a hyperlink specification. * * @param hyperlink the hyperlink specification * @param expressionEvaluator the expression evaluator to use for evaluation the hyperlink expressions * @param evaluationType the evaluation type, as in {@link JRFillExpressionEvaluator#evaluate(JRExpression, byte) JRFillExpressionEvaluator.evaluate(JRExpression, byte)} * @return a {@link JRPrintHyperlink print hyperlink} resulted from the expression evaluations. * @throws JRException */ public static JRPrintHyperlink evaluateHyperlink(JRHyperlink hyperlink, JRFillExpressionEvaluator expressionEvaluator, byte evaluationType) throws JRException { if (hyperlink == null) { return null; } Boolean hyperlinkWhen = (Boolean) expressionEvaluator.evaluate(hyperlink.getHyperlinkWhenExpression(), evaluationType); if (hyperlink.getHyperlinkWhenExpression() != null && Boolean.TRUE.equals(hyperlinkWhen)) { return null; } JRBasePrintHyperlink printHyperlink = new JRBasePrintHyperlink(); printHyperlink.setLinkType(hyperlink.getLinkType()); printHyperlink.setLinkTarget(hyperlink.getLinkTarget()); printHyperlink.setHyperlinkReference((String) expressionEvaluator.evaluate(hyperlink.getHyperlinkReferenceExpression(), evaluationType)); printHyperlink.setHyperlinkAnchor((String) expressionEvaluator.evaluate(hyperlink.getHyperlinkAnchorExpression(), evaluationType)); printHyperlink.setHyperlinkPage((Integer) expressionEvaluator.evaluate(hyperlink.getHyperlinkPageExpression(), evaluationType)); printHyperlink.setHyperlinkTooltip((String) expressionEvaluator.evaluate(hyperlink.getHyperlinkTooltipExpression(), evaluationType)); printHyperlink.setHyperlinkParameters(evaluateHyperlinkParameters(hyperlink, expressionEvaluator, evaluationType)); return printHyperlink; }
protected void performAction(org.openide.nodes.Node[] activatedNodes) { ElementNode node = (ElementNode)activatedNodes[0]; if (node.getElement() instanceof JRDesignComponentElement && ((JRDesignComponentElement)node.getElement()).getComponent() instanceof SpiderChartComponent) { SpiderChartComponent component = (SpiderChartComponent) ((JRDesignComponentElement)node.getElement()).getComponent(); if (component.getChartSettings() == null) { component.setChartSettings(new StandardChartSettings()); } JRHyperlink hyperlink = (JRHyperlink)component.getChartSettings(); JasperDesign design = ((ElementNode)activatedNodes[0]).getJasperDesign(); HyperlinkPanel pd = new HyperlinkPanel(); pd.setExpressionContext(new ExpressionContext( ModelUtils.getElementDataset(((ElementNode)activatedNodes[0]).getElement(), design)) ); pd.setHyperlink(hyperlink); pd.showDialog( Misc.getMainFrame() ); } }
public void mouseMoved(MouseEvent e) { JRPrintImageAreaHyperlink imageArea = getImageMapArea(e); if (imageArea != null && imageArea.getHyperlink().getHyperlinkType() != JRHyperlink.HYPERLINK_TYPE_NONE) { e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { e.getComponent().setCursor(Cursor.getDefaultCursor()); } }
/** * Sets the hyperlink specification for pie chart sections. * * @param sectionHyperlink the hyperlink specification * @see #getSectionHyperlink() */ public void setSectionHyperlink(JRHyperlink sectionHyperlink) { Object old = this.sectionHyperlink; this.sectionHyperlink = sectionHyperlink; getEventSupport().firePropertyChange(PROPERTY_SECTION_HYPERLINK, old, this.sectionHyperlink); }
/** * Sets the hyperlink specification for chart items. * * @param itemHyperlink the hyperlink specification * @see #getItemHyperlink() */ public void setItemHyperlink(JRHyperlink itemHyperlink) { Object old = this.itemHyperlink; this.itemHyperlink = itemHyperlink; getEventSupport().firePropertyChange(PROPERTY_ITEM_HYPERLINK, old, this.itemHyperlink); }
/** * @deprecated Replaced by {@link #getSeries()}. */ public void setSectionHyperlink(JRHyperlink sectionHyperlink) { if (pieSeriesList.size() == 0) { addPieSeries(new JRDesignPieSeries()); } ((JRDesignPieSeries)pieSeriesList.get(0)).setSectionHyperlink(sectionHyperlink); }
/** * */ public void setOtherSectionHyperlink(JRHyperlink otherSectionHyperlink) { Object old = this.otherSectionHyperlink; this.otherSectionHyperlink = otherSectionHyperlink; getEventSupport().firePropertyChange(PROPERTY_OTHER_SECTION_HYPERLINK, old, this.otherSectionHyperlink); }
protected JRBaseHyperlink(JRHyperlink link, JRBaseObjectFactory factory) { factory.put(link, this); linkType = link.getLinkType(); linkTarget = link.getLinkTarget(); hyperlinkReferenceExpression = factory.getExpression(link.getHyperlinkReferenceExpression()); hyperlinkWhenExpression = factory.getExpression(link.getHyperlinkWhenExpression()); hyperlinkAnchorExpression = factory.getExpression(link.getHyperlinkAnchorExpression()); hyperlinkPageExpression = factory.getExpression(link.getHyperlinkPageExpression()); hyperlinkTooltipExpression = factory.getExpression(link.getHyperlinkTooltipExpression()); hyperlinkParameters = copyHyperlinkParameters(link, factory); }
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; }
public void writeHyperlink(String tagName, XmlNamespace namespace, JRHyperlink hyperlink) throws IOException { if (hyperlink != null) { writer.startElement(tagName, namespace); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, hyperlink.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, hyperlink.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkReferenceExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkWhenExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkAnchorExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkPageExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(hyperlink.getHyperlinkParameters()); if(isNewerVersionOrEqual(JRConstants.VERSION_3_5_1)) { writer.closeElement(true); } else { writer.closeElement(); } } }
/** * 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; }
public Object getPropertyValue(Object id) { // pen JRHyperlink jrElement = (JRHyperlink) getValue(); if (jrElement != null) { if (id.equals(JRDesignHyperlink.PROPERTY_LINK_TARGET)) return jrElement.getLinkTarget(); if (id.equals(JRDesignHyperlink.PROPERTY_LINK_TYPE)) return jrElement.getLinkType(); if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_ANCHOR_EXPRESSION)) return ExprUtil.getExpression(jrElement.getHyperlinkAnchorExpression()); if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PAGE_EXPRESSION)) return ExprUtil.getExpression(jrElement.getHyperlinkPageExpression()); if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_REFERENCE_EXPRESSION)) return ExprUtil.getExpression(jrElement.getHyperlinkReferenceExpression()); if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_WHEN_EXPRESSION)) return ExprUtil.getExpression(jrElement.getHyperlinkWhenExpression()); if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_TOOLTIP_EXPRESSION)) return ExprUtil.getExpression(jrElement.getHyperlinkTooltipExpression()); if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS)) { if (propertyDTO == null) { propertyDTO = new ParameterDTO(); propertyDTO.setJasperDesign(getJasperDesign()); propertyDTO.setValue(jrElement.getHyperlinkParameters()); } return propertyDTO; } } return null; }
public static void copyHyperlink(JRHyperlink from, JRHyperlink to) { if (from == null || to == null) return; try { setHyperlinkAttribute(to, "HyperlinkAnchorExpression", JRExpression.class, (from.getHyperlinkAnchorExpression() == null) ? null : from.getHyperlinkAnchorExpression().clone() ); setHyperlinkAttribute(to, "HyperlinkPageExpression", JRExpression.class, (from.getHyperlinkPageExpression() == null) ? null : from.getHyperlinkPageExpression().clone() ); setHyperlinkAttribute(to, "HyperlinkReferenceExpression", JRExpression.class, (from.getHyperlinkReferenceExpression() == null) ? null : from.getHyperlinkReferenceExpression().clone() ); setHyperlinkAttribute(to, "LinkTarget", String.class, from.getLinkTarget() ); setHyperlinkAttribute(to, "HyperlinkTarget", Byte.TYPE, from.getHyperlinkTarget() ); setHyperlinkAttribute(to, "HyperlinkTooltipExpression", JRExpression.class, (from.getHyperlinkTooltipExpression() == null) ? null : from.getHyperlinkTooltipExpression().clone() ); setHyperlinkAttribute(to, "LinkType", String.class, (from.getLinkType() == null) ? null : from.getLinkType() ); setHyperlinkAttribute(to, "HyperlinkWhenExpression", JRExpression.class, (from.getHyperlinkWhenExpression()== null) ? null : from.getHyperlinkWhenExpression().clone() ); // remove all the old params... JRHyperlinkParameter[] params = from.getHyperlinkParameters(); List parameters = getHyperlinkParametersList(to); parameters.clear(); if (params != null) { for (int i=0; i<params.length; ++i) { parameters.add( params[i].clone() ); } } } catch (Throwable t) { t.printStackTrace(); } }
/** * We assume the JRHyperlink has always a way to get the parameters a list... * @param hl * @return the list of parameters */ private static List getHyperlinkParametersList(JRHyperlink hyperlink) { if (hyperlink == null) return null; try { Method m = hyperlink.getClass().getMethod("getHyperlinkParametersList"); return (List)m.invoke(hyperlink); } catch (Throwable t) { t.printStackTrace(); } return null; }
/** * We assume the JRHyperlink has always a way to get the parameters a list... * @param hl * @return the list of parameters */ private static void setHyperlinkAttribute(JRHyperlink hyperlink, String attribute, Class clazz, Object value) { if (hyperlink == null) return; try { Method m = hyperlink.getClass().getMethod("set" + attribute, clazz); m.invoke(hyperlink, value); IReportManager.getInstance().notifyReportChange(); } catch (Throwable t) { t.printStackTrace(); } }
protected String getFallbackTooltip(JRPrintHyperlink hyperlink) { String toolTip = null; switch(hyperlink.getHyperlinkType()) { case JRHyperlink.HYPERLINK_TYPE_REFERENCE : { toolTip = hyperlink.getHyperlinkReference(); break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_ANCHOR : { if (hyperlink.getHyperlinkAnchor() != null) { toolTip = "#" + hyperlink.getHyperlinkAnchor(); } break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE : { if (hyperlink.getHyperlinkPage() != null) { toolTip = "#page " + hyperlink.getHyperlinkPage(); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR : { toolTip = ""; if (hyperlink.getHyperlinkReference() != null) { toolTip = toolTip + hyperlink.getHyperlinkReference(); } if (hyperlink.getHyperlinkAnchor() != null) { toolTip = toolTip + "#" + hyperlink.getHyperlinkAnchor(); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE : { toolTip = ""; if (hyperlink.getHyperlinkReference() != null) { toolTip = toolTip + hyperlink.getHyperlinkReference(); } if (hyperlink.getHyperlinkPage() != null) { toolTip = toolTip + "#page " + hyperlink.getHyperlinkPage(); } break; } default : { break; } } return toolTip; }
@Override public JRHyperlink getOtherSectionHyperlink() { return otherSectionHyperlink; }
@Override public JRHyperlink getItemHyperlink() { return itemHyperlink; }
@Override public JRHyperlink getSectionHyperlink() { return sectionHyperlink; }
/** * @deprecated Replaced by {@link #getSeries()}. */ public JRHyperlink getSectionHyperlink() { return pieSeriesList.size() > 0 ? (pieSeriesList.get(0)).getSectionHyperlink() : null; }
public void setItemHyperlink(JRHyperlink itemHyperlink) { Object old = this.itemHyperlink; this.itemHyperlink = itemHyperlink; getEventSupport().firePropertyChange(PROPERTY_ITEM_HYPERLINK, old, this.itemHyperlink); }
@Override public JRHyperlink getItemHyperlink() { return parent.getItemHyperlink(); }
@Override public JRHyperlink getSectionHyperlink() { return parent.getSectionHyperlink(); }