001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.model;
015:
016: import org.gjt.xpp.XmlPullNode;
017: import org.jetbrains.annotations.NotNull;
018: import org.pentaho.reportdesigner.crm.report.PropertyKeys;
019: import org.pentaho.reportdesigner.lib.common.xml.ObjectConverterFactory;
020: import org.pentaho.reportdesigner.lib.common.xml.XMLContext;
021: import org.pentaho.reportdesigner.lib.common.xml.XMLExternalizable;
022: import org.pentaho.reportdesigner.lib.common.xml.XMLWriter;
023:
024: import java.awt.*;
025: import java.io.IOException;
026:
027: /**
028: * User: Martin
029: * Date: 02.06.2006
030: * Time: 14:39:32
031: */
032: public class RowBandingDefinition implements XMLExternalizable {
033: private boolean enabled;
034: @NotNull
035: private Color color;
036: private boolean startState;//visible or not when starting
037: private int switchItemCount;//number of elements until a switch occurs, see ElementVisibilitySwitchFunction
038:
039: public RowBandingDefinition() {
040: this .enabled = false;
041: this .color = Color.LIGHT_GRAY;
042: this .startState = true;
043: this .switchItemCount = 1;
044: }
045:
046: public RowBandingDefinition(boolean enabled, @NotNull
047: Color color, boolean startState, int switchItemCount) {
048: //noinspection ConstantConditions
049: if (color == null) {
050: throw new IllegalArgumentException("color must not be null");
051: }
052:
053: this .enabled = enabled;
054: this .color = color;
055: this .startState = startState;
056: this .switchItemCount = switchItemCount;
057: }
058:
059: public boolean isEnabled() {
060: return enabled;
061: }
062:
063: @NotNull
064: public Color getColor() {
065: return color;
066: }
067:
068: public boolean isStartState() {
069: return startState;
070: }
071:
072: public int getSwitchItemCount() {
073: return switchItemCount;
074: }
075:
076: public void externalizeObject(@NotNull
077: XMLWriter xmlWriter, @NotNull
078: XMLContext xmlContext) throws IOException {
079: xmlWriter.writeAttribute(PropertyKeys.ENABLED, String
080: .valueOf(enabled));
081: xmlWriter.writeAttribute(PropertyKeys.COLOR,
082: ObjectConverterFactory.getInstance()
083: .getColorConverter().getString(color));
084: xmlWriter.writeAttribute(PropertyKeys.START_STATE, String
085: .valueOf(startState));
086: xmlWriter.writeAttribute(PropertyKeys.SWITCH_ITEM_COUNT, String
087: .valueOf(switchItemCount));
088: }
089:
090: public void readObject(@NotNull
091: XmlPullNode node, @NotNull
092: XMLContext xmlContext) throws Exception {
093: enabled = Boolean.parseBoolean(node
094: .getAttributeValueFromRawName(PropertyKeys.ENABLED));
095: color = ObjectConverterFactory
096: .getInstance()
097: .getColorConverter()
098: .getObject(
099: node
100: .getAttributeValueFromRawName(PropertyKeys.COLOR));
101: startState = Boolean
102: .parseBoolean(node
103: .getAttributeValueFromRawName(PropertyKeys.START_STATE));
104: switchItemCount = Integer
105: .parseInt(node
106: .getAttributeValueFromRawName(PropertyKeys.SWITCH_ITEM_COUNT));
107: }
108: }
|