@Override public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) { super.createPropertyDescriptors(desc, defaultsMap); Set<IPropertyDescriptor> toRemove = new HashSet<IPropertyDescriptor>(); // remove name, defaults for (IPropertyDescriptor d : desc) { if (d.getId().equals(JRDesignStyle.PROPERTY_NAME)) toRemove.add(d); else if (d.getId().equals(JRDesignStyle.PROPERTY_DEFAULT)) toRemove.add(d); } desc.removeAll(toRemove); JRExpressionPropertyDescriptor conditionalExpressionD = new JRExpressionPropertyDescriptor( JRDesignConditionalStyle.PROPERTY_CONDITION_EXPRESSION, Messages.MConditionalStyle_conditional_expression); conditionalExpressionD.setCategory(Messages.MConditionalStyle_properties_category); conditionalExpressionD.setDescription(Messages.MConditionalStyle_conditional_expression_description); desc.add(conditionalExpressionD); }
/** * Copy all the attributes of the source style to the destination style * * @param source source style * @param dest destination style */ private void copyStyleAttributes(JRDesignConditionalStyle source, JRDesignConditionalStyle dest){ dest.setBackcolor(source.getOwnBackcolor()); dest.setBlankWhenNull(source.isOwnBlankWhenNull()); dest.setBold(source.isOwnBold()); dest.setFill(source.getOwnFillValue()); dest.setFontName(source.getOwnFontName()); dest.setFontSize(source.getOwnFontSize()); dest.setForecolor(source.getOwnForecolor()); dest.setHorizontalAlignment(source.getOwnHorizontalAlignmentValue()); dest.setItalic(source.isOwnItalic()); dest.setMarkup(source.getOwnMarkup()); dest.setMode(source.getOwnModeValue()); dest.setParentStyle(source.getStyle()); dest.setPattern(source.getOwnPattern()); dest.setPdfEmbedded(source.isOwnPdfEmbedded()); dest.setPdfEncoding(source.getOwnPdfEncoding()); dest.setPdfFontName(source.getOwnPdfFontName()); dest.setRadius(source.getOwnRadius()); dest.setRotation(source.getOwnRotationValue()); dest.setScaleImage(source.getOwnScaleImageValue()); dest.setStrikeThrough(source.isOwnStrikeThrough()); dest.setUnderline(source.isOwnUnderline()); dest.setVerticalAlignment(source.getOwnVerticalAlignmentValue()); dest.setConditionExpression(source.getConditionExpression()); }
@Override public Object createObject(Attributes atts) { JRDesignConditionalStyle style = (JRDesignConditionalStyle) digester.peek(); if (log.isWarnEnabled()) { if (atts.getValue(JRXmlConstants.ATTRIBUTE_name) != null) { log.warn("Conditional style should not have a '" + JRXmlConstants.ATTRIBUTE_name + "' attribute."); } if (atts.getValue(JRXmlConstants.ATTRIBUTE_isDefault) != null) { log.warn("Conditional style should not have an '" + JRXmlConstants.ATTRIBUTE_isDefault + "' attribute."); } if (atts.getValue(JRXmlConstants.ATTRIBUTE_style) != null) { log.warn("Conditional style cannot have a '" + JRXmlConstants.ATTRIBUTE_style + "' attribute."); } } // set common style attributes setCommonStyle(style, atts); return style; }
@Override public Object createObject(Attributes atts) { JRDesignConditionalStyle style = new JRDesignConditionalStyle(); JRDesignStyle parentStyle = (JRDesignStyle) digester.peek(); style.setParentStyle(parentStyle); parentStyle.addConditionalStyle(style); return style; }
@Override public String getDisplayText() { JRExpression conditionExpression = ((JRDesignConditionalStyle) getValue()).getConditionExpression(); if (conditionExpression != null) return conditionExpression.getText(); return "<NO CONDITION SET>"; }
@Override protected void postDescriptors(IPropertyDescriptor[] descriptors) { super.postDescriptors(descriptors); for(IPropertyDescriptor desc : descriptors){ if(JRDesignConditionalStyle.PROPERTY_CONDITION_EXPRESSION.equals(desc.getId())){ // fix the conditional expression context ((JRExpressionPropertyDescriptor) desc).setExpressionContext( ExpressionEditorSupportUtil.getReportExtendedExpressionContext()); return; } } }
@Override public Object getPropertyValue(Object id) { JRDesignConditionalStyle jrstyle = (JRDesignConditionalStyle) getValue(); if (id.equals(JRDesignConditionalStyle.PROPERTY_CONDITION_EXPRESSION)) return ExprUtil.getExpression(jrstyle.getConditionExpression()); return super.getPropertyValue(id); }
@Override public void setPropertyValue(Object id, Object value) { if (isEditable()) { JRDesignConditionalStyle jrstyle = (JRDesignConditionalStyle) getValue(); if (id.equals(JRDesignConditionalStyle.PROPERTY_CONDITION_EXPRESSION)) jrstyle.setConditionExpression(ExprUtil.setValues(jrstyle.getConditionExpression(), value)); else super.setPropertyValue(id, value); } }
@Override public void execute() { newStyle = null; if (oldStyle == null) return; JRDesignConditionalStyle defaultValueStyle = MConditionalStyle.createJRStyle(); JRDesignConditionalStyle dummyStyle = MConditionalStyle.createJRStyle(); copyStyleAttributes(oldDesignStyle, dummyStyle); newStyle = oldDesignStyle; oldDesignStyle = dummyStyle; copyStyleAttributes(defaultValueStyle, newStyle); }
public ConditionalStyleNode(JasperDesign jd, JRDesignConditionalStyle style, Lookup doLkp, JRDesignStyle parentStyle) { super(jd, style, new ProxyLookup( Lookups.singleton(style), doLkp)); this.parentStyle = parentStyle; style.getEventSupport().addPropertyChangeListener(this); this.setName("conditionalStyle"); }
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName() == null) return; if (evt.getPropertyName().equals( JRDesignConditionalStyle.PROPERTY_CONDITION_EXPRESSION )) { fireDisplayNameChange(null, null); } super.propertyChange(evt); }
@SuppressWarnings("unchecked") public ConditionExpressionProperty(JRDesignConditionalStyle conditionalStyle, JasperDesign jd) { super(conditionalStyle, new FullExpressionContext(jd)); setName( JRDesignConditionalStyle.PROPERTY_CONDITION_EXPRESSION); setDisplayName("Condition Expression"); setShortDescription("The expression used as condition. It should return a boolean object."); this.conditionalStyle = conditionalStyle; this.jd = jd; }
@SuppressWarnings("unchecked") public ConditionalStyleChildren(JasperDesign jd, JRDesignConditionalStyle style, Lookup doLkp) { super(new ArrayList()); this.jd = jd; this.doLkp=doLkp; this.style=style; }
public AbstractStyleNode(JasperDesign jd, JRDesignConditionalStyle style, Lookup doLkp) { super(new ConditionalStyleChildren(jd, style, doLkp), null, new ProxyLookup(doLkp, Lookups.fixed(jd,style))); this.jd = jd; this.style = style; init(); }
@Override protected void initializeProvidedProperties() { super.initializeProvidedProperties(); addProvidedProperties(JRDesignConditionalStyle.PROPERTY_CONDITION_EXPRESSION, Messages.MConditionalStyle_conditional_expression); }
public ResetConditionalStyleCommand(JasperDesign jd, MStyle oldStyle) { super(); this.jrDesign = jd; this.oldStyle = oldStyle; oldDesignStyle = (JRDesignConditionalStyle)oldStyle.getValue(); }
private static void addJRDesignStyles(JasperDesign jasperDesign, boolean isGrid) { try { JRDesignStyle detailShortStyle = new JRDesignStyle(); detailShortStyle.setName(STYLES.DETAIL_SHORT_STYLE); detailShortStyle.setFontSize(detailFontSize); detailShortStyle.setForecolor(new Color(0x39, 0x3B, 0x40)); JRDesignConditionalStyle conditionalStyle = new JRDesignConditionalStyle(); conditionalStyle.setForecolor(new Color(0xBF, 0x21, 0x28)); JRDesignExpression jDesignExpression = new JRDesignExpression(); String committedDateConflict = TReportLayoutBean.PSEUDO_COLUMN_NAMES.COMMITTED_DATE_CONFLICT; String targetDateConflict = TReportLayoutBean.PSEUDO_COLUMN_NAMES.TARGET_DATE_CONFLICT; String plannedValueConflict = TReportLayoutBean.PSEUDO_COLUMN_NAMES.PLANNED_VALUE_CONFLICT; String bugdetConflict = TReportLayoutBean.PSEUDO_COLUMN_NAMES.BUDGET_CONFLICT; String statusFlag = TReportLayoutBean.PSEUDO_COLUMN_NAMES.STATUS_FLAG; String archiveLevel = TReportLayoutBean.PSEUDO_COLUMN_NAMES.ARCHIVE_LEVEL; jDesignExpression.setText("new Boolean((" + getConflictExpression(committedDateConflict, targetDateConflict, true) + " || " + getConflictExpression(plannedValueConflict, bugdetConflict, true) + ") && $F{" + statusFlag + "}.intValue()!=" + TStateBean.STATEFLAGS.CLOSED + " && ($F{" + archiveLevel + "}==null || " + "$F{" + archiveLevel + "}.intValue()==" + TWorkItemBean.ARCHIVE_LEVEL_UNARCHIVED.intValue() + "))"); conditionalStyle.setConditionExpression(jDesignExpression); detailShortStyle.addConditionalStyle(conditionalStyle); jasperDesign.addStyle(detailShortStyle); JRDesignStyle detailLongStyle = new JRDesignStyle(); detailLongStyle.setName(STYLES.DETAIL_LONG_STYLE); detailLongStyle.setFontSize(detailFontSize); jasperDesign.addStyle(detailLongStyle); JRDesignStyle groupStyle = new JRDesignStyle(); groupStyle.setName(STYLES.GROUP_STYLE); groupStyle.setFontSize(groupFontSize); if (!isGrid) { groupStyle.getLinePen().setLineWidth(1); groupStyle.setBackcolor(new Color(0x99, 0x99, 0x99)); groupStyle.setMode(ModeEnum.OPAQUE); } jasperDesign.addStyle(groupStyle); JRDesignStyle headerStyle = new JRDesignStyle(); headerStyle.setName(STYLES.PAGE_HEADER_STYLE); headerStyle.setFontSize(pageHeaderFontSize); headerStyle.setBold(true); if (!isGrid) { headerStyle.setBackcolor(new Color(0xCC, 0xCC, 0xCC)); headerStyle.setMode(ModeEnum.OPAQUE); } jasperDesign.addStyle(headerStyle); } catch (Exception e) { LOGGER.error("Adding the JRDesignStyles failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } }
public JRDesignConditionalStyle getConditionalStyle() { return (JRDesignConditionalStyle)getStyle(); }
public JRDesignConditionalStyle getConditionalStyle() { return conditionalStyle; }
public JRDesignConditionalStyle getStyle() { return style; }
public void setStyle(JRDesignConditionalStyle style) { this.style = style; }
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { super.createControls(parent, tabbedPropertySheetPage); parent.setLayout(new GridLayout(2, false)); createWidget4Property(parent, JRDesignConditionalStyle.PROPERTY_CONDITION_EXPRESSION); }
/** * Instantiates a new creates the conditional style command. * * @param destNode * the dest node * @param srcNode * the src node * @param index * the index */ public CreateConditionalStyleCommand(MStyle destNode, MConditionalStyle srcNode, int index) { super(); this.index = index; this.jrStyle = (JRDesignStyle) destNode.getValue(); if (srcNode != null && srcNode.getValue() != null) { srcNode.setParent(destNode, -1); this.jrConditionalStyle = (JRDesignConditionalStyle) srcNode.getValue(); } }
/** * Instantiates a new reorder conditional style command. * * @param child * the child * @param parent * the parent * @param newIndex * the new index */ public ReorderConditionalStyleCommand(MConditionalStyle child, MStyle parent, int newIndex) { super(Messages.common_reorder_elements); this.newIndex = Math.max(0, newIndex); this.jrStyle = (JRDesignStyle) parent.getValue(); this.jrConditionalStyle = (JRDesignConditionalStyle) child.getValue(); }
/** * Instantiates a new m conditional style. * * @param parent * the parent * @param jrstyle * the jrstyle * @param newIndex * the new index */ public MConditionalStyle(ANode parent, JRDesignConditionalStyle jrstyle, int newIndex) { super(parent, newIndex); setValue(jrstyle); }
/** * Creates the jr style. * * @return the jR design conditional style */ public static JRDesignConditionalStyle createJRStyle() { JRDesignConditionalStyle jrDesignConditionalStyle = new JRDesignConditionalStyle(); return jrDesignConditionalStyle; }
/** * Instantiates a new delete conditional style command. * * @param destNode * the dest node * @param srcNode * the src node */ public DeleteConditionalStyleCommand(MStyle destNode, MConditionalStyle srcNode) { super(); this.jrStyle = (JRDesignStyle) destNode.getValue(); this.jrConditionalStyle = (JRDesignConditionalStyle) srcNode.getValue(); }
/** * Instantiates a new orphan conditional style command. * * @param parent * the parent * @param child * the child */ public OrphanConditionalStyleCommand(MStyle parent, MConditionalStyle child) { super(Messages.common_orphan_child); this.jrStyle = (JRDesignStyle) parent.getValue(); this.jrConditionalStyle = (JRDesignConditionalStyle) child.getValue(); }
/** * This method assumes that all the keys are JRDesignConditionalStyle. * * @param key * @return */ protected Node[] createNodes(Object key) { return new Node[]{new ConditionalStyleNode(jd, (JRDesignConditionalStyle)key, doLkp, getStyle())}; }