@Override public void trasnferProperties(JRElement target){ super.trasnferProperties(target); JRDesignImage jrSource = (JRDesignImage) getValue(); if (jrSource != null){ JRDesignImage jrTarget = (JRDesignImage)target; jrTarget.setFill(jrSource.getOwnFillValue()); jrTarget.setScaleImage(jrSource.getOwnScaleImageValue()); jrTarget.setHorizontalAlignment(jrSource.getOwnHorizontalAlignmentValue()); jrTarget.setVerticalAlignment(jrSource.getOwnVerticalAlignmentValue()); jrTarget.setOnErrorType(jrSource.getOnErrorTypeValue()); jrTarget.setUsingCache(jrSource.getUsingCache()); jrTarget.setLazy(jrSource.isLazy()); } }
public static void setImageExpression(MImage imageModel){ if (imageModel != null){ ImageSelectionDialog d=new ImageSelectionDialog(UIUtils.getShell()); d.configureDialog(imageModel.getJasperConfiguration()); if(d.open()==Window.OK) { JRDesignExpression imageExpression = d.getImageExpression(); if(imageExpression==null){ // No image selected => remove property imageModel.setPropertyValue(JRDesignImage.PROPERTY_EXPRESSION, ""); } else { imageModel.setPropertyValue(JRDesignImage.PROPERTY_EXPRESSION, imageExpression.getText()); } } } }
public static void fixElementsExpressions(JRDesignElementGroup group, String oldName, String newName, byte chunckType, String newClassName) { List list = group.getChildren(); for (int i=0; i<list.size(); ++i) { Object obj = list.get(i); if (obj == null) continue; if (obj instanceof JRDesignElementGroup) { fixElementsExpressions((JRDesignElementGroup)obj,oldName,newName,chunckType,newClassName); } else if (obj instanceof JRDesignTextField) { fixElementExpressionText((JRDesignTextField)obj,oldName,newName,chunckType,newClassName); } else if (obj instanceof JRDesignImage) { fixElementExpressionImage((JRDesignImage)obj,oldName,newName,chunckType,newClassName); } } }
private void publishJrxml(AMJrxmlContainer mres, IProgressMonitor monitor, JasperDesign jasper, Set<String> fileset, IFile file) throws Exception { if (monitor.isCanceled()) return; MReportUnit mrunit = null; if (mres instanceof MReportUnit) mrunit = (MReportUnit) mres; else if (mres.getParent() instanceof MReportUnit) mrunit = (MReportUnit) mres.getParent(); if (mrunit != null) { List<JRDesignElement> elements = ModelUtils.getAllElements(jasper); for (JRDesignElement ele : elements) { if (ele instanceof JRDesignImage) publishImage(mrunit, monitor, jasper, fileset, file, ele, version); else if (ele instanceof JRDesignSubreport) { publishSubreport(mrunit, monitor, jasper, fileset, file, ele, version); } else { publishElement(mrunit, monitor, jasper, fileset, file, ele, version); } } publishDataAdapters(mrunit, monitor, jasper, fileset, file, version); publishBundles(mrunit, monitor, jasper, fileset, file, version); publishTemplates(mrunit, monitor, jasper, fileset, file, version); } // here extend and give possibility to contribute to plugins Activator.getExtManager().publishJrxml(mres, monitor, jasper, fileset, file, version); }
/** * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) */ public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { super.createControls(parent, tabbedPropertySheetPage); parent.setLayout(new GridLayout(2, false)); ASPropertyWidget w = createWidget4Property(parent, JRDesignImage.PROPERTY_EXPRESSION); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 1; w.getControl().setLayoutData(gd); IPropertyDescriptor pd = getPropertyDesriptor(JRDesignImage.PROPERTY_EVALUATION_TIME); IPropertyDescriptor gpd = getPropertyDesriptor(JRDesignImage.PROPERTY_EVALUATION_GROUP); getWidgetFactory().createCLabel(parent, pd.getDisplayName()); widgets.put(pd.getId(), new SPEvaluationTime(parent, this, pd, gpd)); gd = new GridData(); gd.horizontalSpan = 2; createWidget4Property(parent, JRBaseImage.PROPERTY_LAZY, false).getControl().setLayoutData(gd); createWidget4Property(parent, JRBaseImage.PROPERTY_USING_CACHE); createWidget4Property(parent, JRBaseStyle.PROPERTY_FILL); createWidget4Property(parent, JRBaseStyle.PROPERTY_SCALE_IMAGE); createWidget4Property(parent, JRBaseImage.PROPERTY_ON_ERROR_TYPE); }
protected void initializeProvidedProperties() { super.initializeProvidedProperties(); addProvidedProperties(JRDesignImage.PROPERTY_EXPRESSION, Messages.common_expression); addProvidedProperties(JRDesignImage.PROPERTY_EVALUATION_TIME, Messages.MImage_evaluation_type); addProvidedProperties(JRBaseImage.PROPERTY_LAZY, Messages.MImage_lazy); addProvidedProperties(JRBaseImage.PROPERTY_USING_CACHE, Messages.common_using_cache); addProvidedProperties(JRBaseStyle.PROPERTY_FILL, Messages.common_fill); addProvidedProperties(JRBaseStyle.PROPERTY_SCALE_IMAGE, Messages.MImage_scale_image); addProvidedProperties(JRBaseImage.PROPERTY_ON_ERROR_TYPE, Messages.MImage_on_error_type); }
@Override public JRDesignElement createJRElement(JasperDesign jasperDesign) { JRDesignElement jrDesignElement = new JRDesignImage(jasperDesign); DefaultManager.INSTANCE.applyDefault(this.getClass(), jrDesignElement); jrDesignElement.setWidth(getDefaultWidth()); jrDesignElement.setHeight(getDefaultHeight()); return jrDesignElement; }
@Override public String getToolTip() { JRDesignImage value = getValue(); if (value != null) { String tip = ""; if (value.getExpression() != null) tip += value.getExpression().getText(); return tip; } return getIconDescriptor().getToolTip(); }
/** * Return the graphical properties for an MImage */ public HashSet<String> generateGraphicalProperties(){ HashSet<String> result = super.generateGraphicalProperties(); result.add(JRBaseStyle.PROPERTY_FILL); result.add(JRBaseStyle.PROPERTY_SCALE_IMAGE); result.add(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT); result.add(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT); result.add(JRDesignImage.PROPERTY_EXPRESSION); return result; }
@Override public void addPages() { mimage = new MImage(null, new JRDesignImage(jasperDesign), -1); page5 = new WizardImagePage(); addPage(page5); page5.setMImage(mimage); }
private static void copyInheritedImageAttributes(JRDesignElement target, JRStyle style){ JRDesignImage jrTarget = (JRDesignImage)target; if (jrTarget.getOwnFillValue() == null) jrTarget.setFill(style.getFillValue()); if (jrTarget.getOwnScaleImageValue() == null) jrTarget.setScaleImage(style.getScaleImageValue()); if (jrTarget.getOwnHorizontalAlignmentValue() == null) jrTarget.setHorizontalAlignment(style.getHorizontalAlignmentValue()); if (jrTarget.getOwnVerticalAlignmentValue() == null) jrTarget.setVerticalAlignment(style.getVerticalAlignmentValue()); }
/** * Start the thread to refresh a specific image. when the thread has cached a new image then the model and the editor * are notified to ask a refresh * * @param info The timed container of the image requested (where it will be placed) * @param modelElement the model of the element where the image will be placed * @param expr the expression to get the image * @param jrContext the context to get the image * @param key the key of the image in the cache map. */ private void refreshImageInfo(final TimedCache info, final MGraphicElement modelElement, final JRExpression expr, final JasperReportsContext jrContext, final KeyValue<JasperReportsContext, String> key){ if (!pendingRequests.contains(modelElement)){ pendingRequests.add(modelElement); Job job = new Job("load image") { protected IStatus run(IProgressMonitor monitor) { try { String location = evaluatedExpression((JasperReportsConfiguration) jrContext, modelElement, expr); if (location != null){ Renderable r = RenderableUtil.getInstance(jrContext).getRenderable(location, OnErrorTypeEnum.ERROR, false); info.update(r); if (modelElement != null) { modelElement.setChangedProperty(true); } //The editor refresh must be executed inside the graphic threads Display.getDefault().asyncExec(new Runnable() { @Override public void run() { PropertyChangeEvent event = new PropertyChangeEvent(modelElement.getValue(), JRDesignImage.PROPERTY_EXPRESSION, null, expr); modelElement.setChangedProperty(true); AMultiEditor.refreshElement(jrContext, event); } }); } } catch (Throwable e) { e.printStackTrace(); } pendingRequests.remove(modelElement); return Status.OK_STATUS; } }; job.setSystem(true); job.setPriority(Job.SHORT); job.schedule(); } }
public JRDesignElement transformElement(JRDesignElement element) { if (!(element instanceof JRDesignImage)) return element; if (!Misc.getExpressionText( ((JRDesignImage)element).getExpression() ).startsWith("it.businesslogic.ireport.barcode.BcImage.getBarcodeImage(")) return element; return transformImageToBarcode((JRDesignImage)element); }
@Override protected boolean enable(Node[] activatedNodes) { if (activatedNodes == null || activatedNodes.length == 0) return false; for (Node node : activatedNodes) { if (! (node instanceof ElementNode)) return false; JRDesignElement element = ((ElementNode)node).getElement(); if (!(element instanceof JRDesignImage)) return false; if (!Misc.getExpressionText( ((JRDesignImage)element).getExpression() ).startsWith("it.businesslogic.ireport.barcode.BcImage.getBarcodeImage(")) return false; } return true; }
public static void fixElementExpressionImage(JRDesignImage imageelement, String oldName, String newName, byte chunckType, String newClassName) { JRDesignExpression exp = (JRDesignExpression)imageelement.getExpression(); replaceChunkText( exp, oldName, newName, chunckType, newClassName); if (exp != null) { imageelement.getEventSupport().firePropertyChange( JRDesignTextField.PROPERTY_EXPRESSION, null, exp); } }
@SuppressWarnings("unchecked") public ImageExpressionClassNameProperty(JRDesignImage element) { super(JRDesignExpression.PROPERTY_VALUE_CLASS_NAME, String.class, "Expression Class", "Expression Class"); this.element = element; setValue("canEditAsText", true); setValue("oneline", true); setValue("suppressCustomEditor", false); }
@SuppressWarnings("unchecked") public EvaluationGroupProperty(JRDesignImage element, JRDesignDataset dataset) { // TODO: Replace WhenNoDataType with the right constant super( JRDesignImage.PROPERTY_EVALUATION_GROUP,JRGroup.class, "Evaluation group", "Evaluate the image expression when the specified group changes", true, true); this.element = element; this.dataset = dataset; setValue("suppressCustomEditor", Boolean.TRUE); dataset.getEventSupport().addPropertyChangeListener(WeakListeners.propertyChange(this, dataset.getEventSupport())); }
public ImageExpressionFileResolver(JRDesignImage imageElement, String reportFolder, JasperDesign jd) { this.imageElement = imageElement; this.imageExpression = (JRDesignExpression) imageElement.getExpression(); this.reportFolder = reportFolder; this.jasperDesign = jd; }
/** * @param imageElement the imageElement to set */ public void setImageElement(JRDesignImage imageElement) { if (this.imageElement != imageElement || this.imageExpression != imageElement.getExpression()) { this.imageElement = imageElement; this.imageExpression = (JRDesignExpression) imageElement.getExpression(); this.file = null; resolveFile = true; } }
@SuppressWarnings("unchecked") public ImageEvaluationTimeProperty(JRDesignImage element, JRDesignDataset dataset) { super(EvaluationTimeEnum.class, element); this.element = element; this.dataset = dataset; setValue("suppressCustomEditor", Boolean.TRUE); }
public ImageExpressionProperty(JRDesignImage image, JRDesignDataset dataset) { super(image, dataset); this.image = image; // if this textfield is child of a crosstab replace the expression context.. if (ModelUtils.getTopElementGroup(image) instanceof JRDesignCellContents) { JRDesignCellContents contents = (JRDesignCellContents) ModelUtils.getTopElementGroup(image); this.setValue(ExpressionContext.ATTRIBUTE_EXPRESSION_CONTEXT, new ExpressionContext(contents.getOrigin().getCrosstab())); } }
public JRDesignElement createReportElement(JasperDesign jd) { RepositoryFile file = (RepositoryFile) getPaletteItem().getData(); JRDesignElement element = new JRDesignImage(jd); element.setWidth(100); element.setHeight(50); JRDesignExpression exp = new JRDesignExpression(); exp.setValueClassName("java.lang.String"); exp.setText("\"repo:" + file.getDescriptor().getUriString()+"\""); // Try to load the image... try { String fname = file.getFile(); ImageIcon img = new ImageIcon(fname); element.setWidth(img.getIconWidth()); element.setHeight(img.getIconHeight()); RepoImageCache.getInstance().put( JRExpressionUtil.getSimpleExpressionText(exp) , new File(fname)); } catch (Exception ex) { ex.printStackTrace(); } ((JRDesignImage)element).setExpression(exp); return element; }
private static JRDesignImage createImageField(ODLTableDefinition table, int i) { JRDesignImage image = new JRDesignImage(null); setImageBorder(image); image.setScaleImage(ScaleImageEnum.RETAIN_SHAPE); String fld = "$F{" + table.getColumnName(i) + "}"; JRDesignExpression expression = new JRDesignExpression(); expression.setText(fld); image.setExpression(expression); image.setPrintWhenDetailOverflows(false); return image; }
static void setImageBorder(JRDesignImage img) { float bw = .5f; Color c = Color.BLACK; JRLineBox box = img.getLineBox(); box.getLeftPen().setLineWidth(bw); box.getLeftPen().setLineColor(c); box.getRightPen().setLineWidth(bw); box.getRightPen().setLineColor(c); box.getBottomPen().setLineWidth(bw); box.getBottomPen().setLineColor(c); box.getTopPen().setLineWidth(bw); box.getTopPen().setLineColor(c); }
@Override public Object createObject(Attributes atts) { JRXmlLoader xmlLoader = (JRXmlLoader)digester.peek(digester.getCount() - 1); JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); JRDesignImage image = new JRDesignImage(jasperDesign); // get image attributes ScaleImageEnum scaleImage = ScaleImageEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_scaleImage)); if (scaleImage != null) { image.setScaleImage(scaleImage); } HorizontalImageAlignEnum horizontalImageAlign = HorizontalImageAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_hAlign)); if (horizontalImageAlign != null) { image.setHorizontalImageAlign(horizontalImageAlign); } VerticalImageAlignEnum verticalImageAlign = VerticalImageAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_vAlign)); if (verticalImageAlign != null) { image.setVerticalImageAlign(verticalImageAlign); } String isUsingCache = atts.getValue(JRXmlConstants.ATTRIBUTE_isUsingCache); if (isUsingCache != null && isUsingCache.length() > 0) { image.setUsingCache(Boolean.valueOf(isUsingCache)); } String isLazy = atts.getValue(JRXmlConstants.ATTRIBUTE_isLazy); if (isLazy != null && isLazy.length() > 0) { image.setLazy(Boolean.valueOf(isLazy).booleanValue()); } OnErrorTypeEnum onErrorType = OnErrorTypeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_onErrorType)); if (onErrorType != null) { image.setOnErrorType(onErrorType); } EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime)); if (evaluationTime != null) { image.setEvaluationTime(evaluationTime); } if (image.getEvaluationTimeValue() == EvaluationTimeEnum.GROUP) { xmlLoader.addGroupEvaluatedImage(image); String groupName = atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup); if (groupName != null) { JRDesignGroup group = new JRDesignGroup(); group.setName(groupName); image.setEvaluationGroup(group); } } image.setLinkType(atts.getValue(JRXmlConstants.ATTRIBUTE_hyperlinkType)); image.setLinkTarget(atts.getValue(JRXmlConstants.ATTRIBUTE_hyperlinkTarget)); String bookmarkLevelAttr = atts.getValue(JRXmlConstants.ATTRIBUTE_bookmarkLevel); if (bookmarkLevelAttr != null) { image.setBookmarkLevel(Integer.parseInt(bookmarkLevelAttr)); } return image; }
public ImageEvaluationGroupReference(JRDesignImage image) { this.image = image; }
public void addGroupEvaluatedImage(JRDesignImage image) { addGroupReference( new ImageEvaluationGroupReference(image)); }
protected JRDesignExpression getExpression(JRDesignElement img) { return (JRDesignExpression) ((JRDesignImage) img).getExpression(); }
@Override public JRDesignImage getValue() { return (JRDesignImage) super.getValue(); }
@Override public Object getPropertyValue(Object id) { JRDesignImage jrElement = (JRDesignImage) getValue(); if (id.equals(JRBaseStyle.PROPERTY_FILL)) return fillD.getEnumValue(jrElement.getOwnFillValue()); if (id.equals(JRBaseStyle.PROPERTY_SCALE_IMAGE)) return scaleImageD.getEnumValue(jrElement.getOwnScaleImageValue()); if (id.equals(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT)) return hAlignD.getEnumValue(jrElement.getOwnHorizontalAlignmentValue()); if (id.equals(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT)) return vAlignD.getEnumValue(jrElement.getOwnVerticalAlignmentValue()); if (id.equals(JRBaseImage.PROPERTY_ON_ERROR_TYPE)) return onErrorTypeD.getEnumValue(jrElement.getOnErrorTypeValue()); if (id.equals(JRDesignImage.PROPERTY_EVALUATION_TIME)) return evaluationTimeD.getEnumValue(jrElement.getEvaluationTimeValue()); if (id.equals(JRDesignImage.PROPERTY_EXPRESSION)) return ExprUtil.getExpression(jrElement.getExpression()); if (id.equals(JRDesignImage.PROPERTY_EVALUATION_GROUP)) { if (jrElement.getEvaluationGroup() != null) return jrElement.getEvaluationGroup().getName(); return ""; //$NON-NLS-1$ } if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS)) { if (propertyDTO == null) { propertyDTO = new ParameterDTO(); propertyDTO.setJasperDesign(getJasperDesign()); propertyDTO.setValue(jrElement.getHyperlinkParameters()); } return propertyDTO; } if (id.equals(JRBaseImage.PROPERTY_USING_CACHE)) return jrElement.getUsingCache(); if (id.equals(JRBaseImage.PROPERTY_LAZY)) return new Boolean(jrElement.isLazy()); // hyperlink -------------------------------------- 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_TOOLTIP_EXPRESSION)) return ExprUtil.getExpression(jrElement.getHyperlinkTooltipExpression()); if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_WHEN_EXPRESSION)) { return ExprUtil.getExpression(jrElement.getHyperlinkWhenExpression()); } if (id.equals(JRDesignImage.PROPERTY_ANCHOR_NAME_EXPRESSION)){ return ExprUtil.getExpression(jrElement.getAnchorNameExpression()); } if (id.equals(JRDesignImage.PROPERTY_BOOKMARK_LEVEL)){ return jrElement.getBookmarkLevel(); } return super.getPropertyValue(id); }
@Override public Object getPropertyActualValue(Object id) { JRDesignImage jrElement = (JRDesignImage) getValue(); if (id.equals(JRBaseStyle.PROPERTY_FILL)) return fillD.getEnumValue(jrElement.getFillValue()); if (id.equals(JRBaseStyle.PROPERTY_SCALE_IMAGE)) return scaleImageD.getEnumValue(jrElement.getScaleImageValue()); if (id.equals(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT)) return hAlignD.getEnumValue(jrElement.getHorizontalAlignmentValue()); if (id.equals(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT)) return vAlignD.getEnumValue(jrElement.getVerticalAlignmentValue()); if (id.equals(JRBaseImage.PROPERTY_ON_ERROR_TYPE)) return onErrorTypeD.getEnumValue(jrElement.getOnErrorTypeValue()); if (id.equals(JRDesignImage.PROPERTY_EVALUATION_TIME)) return evaluationTimeD.getEnumValue(jrElement.getEvaluationTimeValue()); if (id.equals(JRDesignImage.PROPERTY_EXPRESSION)) return ExprUtil.getExpression(jrElement.getExpression()); if (id.equals(JRDesignImage.PROPERTY_EVALUATION_GROUP)) { if (jrElement.getEvaluationGroup() != null) return jrElement.getEvaluationGroup().getName(); return ""; //$NON-NLS-1$ } if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS)) { if (propertyDTO == null) { propertyDTO = new ParameterDTO(); propertyDTO.setJasperDesign(getJasperDesign()); propertyDTO.setValue(jrElement.getHyperlinkParameters()); } return propertyDTO; } if (id.equals(JRBaseImage.PROPERTY_USING_CACHE)) return jrElement.getUsingCache(); if (id.equals(JRBaseImage.PROPERTY_LAZY)) return new Boolean(jrElement.isLazy()); // hyperlink -------------------------------------- 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_TOOLTIP_EXPRESSION)) return ExprUtil.getExpression(jrElement.getHyperlinkTooltipExpression()); if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_WHEN_EXPRESSION)) return ExprUtil.getExpression(jrElement.getHyperlinkWhenExpression()); return super.getPropertyActualValue(id); }
@Override public void setPropertyValue(Object id, Object value) { JRDesignImage jrElement = (JRDesignImage) getValue(); if (id.equals(JRBaseStyle.PROPERTY_FILL)) jrElement.setFill((FillEnum) fillD.getEnumValue(value)); else if (id.equals(JRBaseStyle.PROPERTY_SCALE_IMAGE)) jrElement.setScaleImage((ScaleImageEnum) scaleImageD.getEnumValue(value)); else if (id.equals(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT)) jrElement.setHorizontalAlignment((HorizontalAlignEnum) hAlignD.getEnumValue(value)); else if (id.equals(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT)) jrElement.setVerticalAlignment((VerticalAlignEnum) vAlignD.getEnumValue(value)); else if (id.equals(JRBaseImage.PROPERTY_ON_ERROR_TYPE)) jrElement.setOnErrorType((OnErrorTypeEnum) onErrorTypeD.getEnumValue(value)); else if (id.equals(JRDesignImage.PROPERTY_EVALUATION_TIME)) jrElement.setEvaluationTime((EvaluationTimeEnum) evaluationTimeD.getEnumValue(value)); else if (id.equals(JRDesignImage.PROPERTY_EVALUATION_GROUP)) { if (value != null && !value.equals("")) { //$NON-NLS-1$ JRDesignDataset dataset = (JRDesignDataset)getElementDataset(); JRGroup group = (JRGroup) dataset.getGroupsMap().get(value); jrElement.setEvaluationGroup(group); } } else if (id.equals(JRDesignImage.PROPERTY_EXPRESSION)) jrElement.setExpression(ExprUtil.setValues(jrElement.getExpression(), value)); else if (id.equals(JRBaseImage.PROPERTY_USING_CACHE)) jrElement.setUsingCache((Boolean) value); else if (id.equals(JRBaseImage.PROPERTY_LAZY)) jrElement.setLazy(((Boolean) value).booleanValue()); else if (id.equals(JRDesignHyperlink.PROPERTY_LINK_TARGET)) jrElement.setLinkTarget((String) value); else if (id.equals(JRDesignHyperlink.PROPERTY_LINK_TYPE)) jrElement.setLinkType((String) value); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_ANCHOR_EXPRESSION)) jrElement.setHyperlinkAnchorExpression(ExprUtil.setValues(jrElement.getHyperlinkAnchorExpression(), value)); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PAGE_EXPRESSION)) jrElement.setHyperlinkPageExpression(ExprUtil.setValues(jrElement.getHyperlinkPageExpression(), value)); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_REFERENCE_EXPRESSION)) jrElement.setHyperlinkReferenceExpression(ExprUtil.setValues(jrElement.getHyperlinkReferenceExpression(), value)); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_TOOLTIP_EXPRESSION)) jrElement.setHyperlinkTooltipExpression(ExprUtil.setValues(jrElement.getHyperlinkTooltipExpression(), value)); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_WHEN_EXPRESSION)) { jrElement.setHyperlinkWhenExpression(ExprUtil.setValues(jrElement.getHyperlinkWhenExpression(), value)); } else if (id.equals(JRDesignImage.PROPERTY_ANCHOR_NAME_EXPRESSION)) jrElement.setAnchorNameExpression(ExprUtil.setValues(jrElement.getAnchorNameExpression(), value)); else if (id.equals(JRDesignImage.PROPERTY_BOOKMARK_LEVEL)) jrElement.setBookmarkLevel(value != null ? Integer.parseInt(value.toString()) : 0); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS)) { if (value instanceof ParameterDTO) { ParameterDTO v = (ParameterDTO) value; JRHyperlinkParameter[] hyperlinkParameters = jrElement.getHyperlinkParameters(); if (hyperlinkParameters != null) for (JRHyperlinkParameter prm : hyperlinkParameters) jrElement.removeHyperlinkParameter(prm); for (JRHyperlinkParameter param : v.getValue()) jrElement.addHyperlinkParameter(param); propertyDTO = v; } } super.setPropertyValue(id, value); }
public JRDesignElementWidget addElementWidget(JRDesignElement de) { if (de == null) return null; JRDesignElementWidget widget = null; if (de instanceof JRDesignComponentElement) { widget = IReportManager.getComponentWidget(this, (JRDesignComponentElement)de); } else if (de instanceof JRDesignImage) { widget = new JRDesignImageWidget(this, (JRDesignImage)de); } else if (de instanceof JRDesignChart) { widget = new JRDesignChartWidget(this, (JRDesignChart)de); } if (widget == null) // Default... { widget = new JRDesignElementWidget(this, de); } //widget.getSelectionWidget().setLayout(new ResizeHandleLayout()); //widget.getSelectionWidget().getActions().addAction(createSelectAction()); widget.getActions().addAction (getReportSelectAction()); widget.getSelectionWidget().getActions().addAction( keyboardElementMoveAction ); widget.getSelectionWidget().getActions().addAction (getReportSelectAction()); widget.getSelectionWidget().getActions().addAction(createObjectHoverAction()); widget.getSelectionWidget().getActions().addAction( ActionFactory.createResizeAction( reportAlignWithResizeStrategyProvider, reportAlignWithResizeStrategyProvider) ); widget.getSelectionWidget().getActions().addAction( ActionFactory.createMoveAction( reportAlignWithMoveStrategyProvider, reportAlignWithMoveStrategyProvider) ); widget.getActions().addAction( ActionFactory.createResizeAction( reportAlignWithResizeStrategyProvider, reportAlignWithResizeStrategyProvider) ); widget.getActions().addAction( ActionFactory.createMoveAction( reportAlignWithMoveStrategyProvider, reportAlignWithMoveStrategyProvider) ); widget.getActions().addAction(inplaceEditorAction); widget.getSelectionWidget().getActions().addAction(inplaceEditorAction); widget.getActions ().addAction(tableElementPopupMenuAction); widget.getSelectionWidget().getActions().addAction(tableElementPopupMenuAction); widget.getActions().addAction( ActionFactory.createActionMapAction(elementInputMap, elementActionMap) ); widget.getSelectionWidget().getActions().addAction( ActionFactory.createActionMapAction(elementInputMap, elementActionMap) ); elementsLayer.addChild(widget); selectionLayer.addChild(widget.getSelectionWidget()); addObject(de, widget); return widget; }
public JRDesignElement transformImageToBarcode(JRDesignImage element) { StandardBarbecueComponent componentImpl = new StandardBarbecueComponent(); componentImpl.setEvaluationTimeValue( element.getEvaluationTimeValue() ); if (element.getEvaluationGroup() != null) componentImpl.setEvaluationGroup( element.getEvaluationGroup().getName() ); String imageExpression = Misc.getExpressionText(element.getExpression()); int numberOfParams = 7; String iE = imageExpression.substring(imageExpression.indexOf("(") + 1, imageExpression.lastIndexOf(")")); String[] params = iE.split(","); int paramCount = params.length; componentImpl.setType( getBarcodeName( new Integer(params[0]).intValue() )); //params[0] will always be type String barcodeExpression = ""; for (int i=0; i <= paramCount - numberOfParams; i++) { barcodeExpression += params[i+1] + ","; } componentImpl.setCodeExpression( Misc.createExpression("java.lang.String", barcodeExpression.substring(0, barcodeExpression.length() - 1) )); componentImpl.setDrawText( new Boolean(params[2 + (paramCount - numberOfParams)]).booleanValue() ); componentImpl.setChecksumRequired( new Boolean(params[3 + (paramCount - numberOfParams)]).booleanValue() ); if (params.length > 4) { componentImpl.setApplicationIdentifierExpression( Misc.createExpression("java.lang.String", "\"" + params[4 + (paramCount - numberOfParams)] + "\"")); int bW = Integer.parseInt( params[5 + (paramCount - numberOfParams)]); if (bW > 0) componentImpl.setBarWidth(bW); int bH = Integer.parseInt( params[6 + (paramCount - numberOfParams)]); if (bH > 0) componentImpl.setBarHeight(bH); } JRDesignComponentElement component = new JRDesignComponentElement(); component.setX( element.getX()); component.setY( element.getY()); component.setWidth( element.getWidth()); component.setHeight( element.getHeight()); component.setBackcolor( element.getOwnBackcolor()); component.setForecolor( element.getOwnForecolor()); component.setKey( element.getKey()); component.setMode( element.getOwnModeValue()); component.setPositionType( element.getPositionTypeValue()); component.setPrintWhenDetailOverflows( element.isPrintWhenDetailOverflows()); if (element.getPrintWhenExpression() != null) { component.setPrintWhenExpression( (JRExpression) ((JRDesignExpression)element.getPrintWhenExpression()).clone() ); } component.setPrintRepeatedValues( element.isPrintRepeatedValues()); component.setPrintInFirstWholeBand( element.isPrintInFirstWholeBand()); component.setPrintWhenGroupChanges( element.getPrintWhenGroupChanges()); component.setRemoveLineWhenBlank(element.isRemoveLineWhenBlank()); component.setStretchType(element.getStretchTypeValue()); component.setStyle(element.getStyle()); component.setStyleNameReference(element.getStyleNameReference()); component.setComponent(componentImpl); component.setComponentKey(new ComponentKey( "http://jasperreports.sourceforge.net/jasperreports/components", "jr", "barbecue")); return component; }
public boolean appliesTo(Object designElement) { return designElement instanceof JRDesignImage; }
/** * */ public void visitImage(JRImage image) { node = new ElementNode(jasperDesign, (JRDesignImage)image,doLkp); node.setIconBaseWithExtension(ICON_IMAGE); }
/** * Get the GraphicElement properties... */ public static List<Sheet.Set> getGraphicPropertySets(JRDesignGraphicElement element, JasperDesign jd) { JRDesignDataset dataset = ModelUtils.getElementDataset(element, jd); List<Sheet.Set> list = new ArrayList<Sheet.Set>(); Sheet.Set propertySet = Sheet.createPropertiesSet(); propertySet.setName("GRAPHIC_ELEMENT_PROPERTIES"); propertySet.setDisplayName("Graphic properties"); //propertySet.put(new PenProperty( element )); propertySet.put(new JRPenProperty(element.getLinePen(), element)); propertySet.put(new FillProperty( element )); list.add(propertySet); if (element instanceof JRDesignImage) { Sheet.Set imagePropertySet = Sheet.createPropertiesSet(); imagePropertySet.setName("IMAGE_ELEMENT_PROPERTIES"); imagePropertySet.setDisplayName("Image properties"); imagePropertySet.put(new ImageExpressionProperty((JRDesignImage)element, dataset)); imagePropertySet.put(new ImageExpressionClassNameProperty((JRDesignImage)element) ); imagePropertySet.put(new ScaleImageProperty( (JRDesignImage)element )); imagePropertySet.put(new HorizontalAlignmentProperty( (JRDesignImage)element )); imagePropertySet.put(new VerticalAlignmentProperty( (JRDesignImage)element )); imagePropertySet.put(new ImageUsingCacheProperty( (JRDesignImage)element )); imagePropertySet.put(new LazyProperty( (JRDesignImage)element )); imagePropertySet.put(new OnErrorTypeProperty( (JRDesignImage)element )); imagePropertySet.put(new ImageEvaluationTimeProperty((JRDesignImage)element, dataset));//, dataset)); imagePropertySet.put(new EvaluationGroupProperty((JRDesignImage)element, dataset)); list.add(imagePropertySet); } else if (element instanceof JRDesignLine) { Sheet.Set linePropertySet = Sheet.createPropertiesSet(); linePropertySet.setName("LINE_ELEMENT_PROPERTIES"); linePropertySet.setDisplayName("Line properties"); linePropertySet.put(new LineDirectionProperty( (JRDesignLine)element )); list.add(linePropertySet); } else if (element instanceof JRDesignRectangle) { Sheet.Set rectanglePropertySet = Sheet.createPropertiesSet(); rectanglePropertySet.setName("RECTANGLE_ELEMENT_PROPERTIES"); rectanglePropertySet.setDisplayName("Rectangle properties"); rectanglePropertySet.put(new RadiusProperty( (JRDesignRectangle)element )); list.add(rectanglePropertySet); } else if (element instanceof JRDesignEllipse) { // Nothing to do... } return list; }
public void addElementWidget(JRDesignElement de) { if (de == null) return; JRDesignElementWidget widget = null; if (de instanceof JRDesignImage) { widget = new JRDesignImageWidget(this, (JRDesignImage)de); } else { widget = new JRDesignElementWidget(this, de); } //widget.getSelectionWidget().setLayout(new ResizeHandleLayout()); //widget.getSelectionWidget().getActions().addAction(createSelectAction()); //widget.getActions().addAction (createSelectAction()); widget.getActions().addAction (getReportSelectAction()); widget.getSelectionWidget().getActions().addAction( keyboardElementMoveAction ); widget.getSelectionWidget().getActions().addAction (getReportSelectAction()); widget.getSelectionWidget().getActions().addAction(createObjectHoverAction()); widget.getSelectionWidget().getActions().addAction( ActionFactory.createResizeAction( reportAlignWithResizeStrategyProvider, reportAlignWithResizeStrategyProvider) ); widget.getSelectionWidget().getActions().addAction( ActionFactory.createMoveAction( reportAlignWithMoveStrategyProvider, reportAlignWithMoveStrategyProvider) ); widget.getActions().addAction( ActionFactory.createResizeAction( reportAlignWithResizeStrategyProvider, reportAlignWithResizeStrategyProvider) ); widget.getActions().addAction( ActionFactory.createMoveAction( reportAlignWithMoveStrategyProvider, reportAlignWithMoveStrategyProvider) ); widget.getActions().addAction(inplaceEditorAction); widget.getSelectionWidget().getActions().addAction(inplaceEditorAction); widget.getActions ().addAction(elementPopupMenuAction); widget.getSelectionWidget().getActions().addAction(elementPopupMenuAction); widget.getActions().addAction( ActionFactory.createActionMapAction(elementInputMap, elementActionMap) ); widget.getSelectionWidget().getActions().addAction( ActionFactory.createActionMapAction(elementInputMap, elementActionMap) ); elementsLayer.addChild(widget); selectionLayer.addChild(widget.getSelectionWidget()); addObject(de, widget); }
public JRDesignElement createReportElement(JasperDesign jd) { File parent = new File(IReportManager.getInstance().getCurrentDirectory()); // Try to figure it out the current directory of the report... if (IReportManager.getInstance().getActiveVisualView() != null) { JrxmlVisualView view = IReportManager.getInstance().getActiveVisualView(); FileObject obj = view.getEditorSupport().getDataObject().getPrimaryFile(); File f = FileUtil.toFile(obj); if (f != null && f.getParentFile().exists()) { parent = f.getParentFile(); } } final javax.swing.JFileChooser jfc = new javax.swing.JFileChooser( parent ); jfc.setDialogTitle("Select an image file...."); jfc.setFileFilter( new javax.swing.filechooser.FileFilter() { public boolean accept(java.io.File file) { String filename = file.getName(); return (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".gif") || file.isDirectory()) ; } public String getDescription() { return "Image *.gif|*.jpg"; } }); jfc.setMultiSelectionEnabled(false); final JRDesignImage element = new JRDesignImage(jd); element.setWidth(100); element.setHeight(50); jfc.setDialogType( javax.swing.JFileChooser.OPEN_DIALOG); if (jfc.showOpenDialog( null) == javax.swing.JOptionPane.OK_OPTION) { element.setExpression( Misc.createExpression("java.lang.String", "\""+ Misc.string_replace("\\\\","\\",jfc.getSelectedFile().getPath() +"\""))); IReportManager.getInstance().setCurrentDirectory(jfc.getSelectedFile().getParent(), true); // Try to identify the image size... SwingUtilities.invokeLater(new Runnable() { public void run() { try { ImageIcon image = new ImageIcon(jfc.getSelectedFile().getPath()); if (image.getIconWidth() > 0) { element.setWidth( image.getIconWidth()); } if (image.getIconHeight() > 0) { element.setHeight( image.getIconHeight()); } } catch (Exception ex) { } } }); } return element; }
/** * @return the imageElement */ public JRDesignImage getImageElement() { return imageElement; }