/*******************************************************************************
 * Copyright (c) 2010 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.csstudio.trends.databrowser2.export;

import org.csstudio.archive.vtype.Style;
import org.csstudio.archive.vtype.VTypeHelper;
import org.csstudio.trends.databrowser2.Messages;
import org.epics.vtype.VType;

/** Format an IValue to show the value as well as the severity/status
 *  @author Kay Kasemir
 */
public class ValueWithInfoFormatter extends ValueFormatter
{
    /** Initialize
     *  @param format Number format to use
     *  @param precision Precision
     */
    public ValueWithInfoFormatter(final Style style, final int precision)
    {
        super(style, precision);
    }

    /** {@inheritDoc} */
    @Override
    public String getHeader()
    {
        return super.getHeader() + Messages.Export_Delimiter + Messages.SeverityColumn +
            Messages.Export_Delimiter + Messages.StatusColumn;
    }

    /** {@inheritDoc} */
    @Override
    public String format(final VType value)
    {
        if (Double.isNaN(VTypeHelper.toDouble(value)))
            return super.format(null) +
                Messages.Export_Delimiter + Messages.Export_NoValueMarker +
                Messages.Export_Delimiter + Messages.Export_NoValueMarker;
        return super.format(value) + Messages.Export_Delimiter +
            VTypeHelper.getSeverity(value) + Messages.Export_Delimiter +
            VTypeHelper.getMessage(value);
    }
}

@@ -642,16 +642,85 @@
 ssages;%0A
+import org.epics.vtype.VString;%0Aimport org.epics.vtype.VStringArray;%0A
 import o
@@ -1453,20 +1453,83 @@
   %7B%0A
-        if (
+%09%09if (value instanceof VString%0A%09%09%09%09%7C%7C value instanceof VStringArray%0A%09%09%09%09%7C%7C 
 Doub
@@ -1603,12 +1603,13 @@
 mat(
-null
+value
 ) +%0A

Support export of VString samples when Severity/Status option checked.