// Copyright (C) 2013 João Pedro Correia - All Rights Reserved
// Code under the terms of the GPLv2 license
// URL: http://flowstudio.codeplex.com

namespace FlowStudio.ViewModel.Data
{
    using System.Activities;
    using System.Activities.Presentation.Model;

    public class OutlineVariableItem : OutlineItem
    {
        private readonly string displayText;

        public OutlineVariableItem(ModelItem variableModelItem)
            : base(variableModelItem)
        {
            // Get display text
            var variable = variableModelItem.GetCurrentValue() as Variable;

            if (variable != null)
            {
                displayText = !string.IsNullOrEmpty(variable.Name)
                                  ? variable.Name
                                  : variableModelItem.ItemType.Name;
            }

            displayText = displayText ?? variableModelItem.Name;
        }

        public override string DisplayText
        {
            get { return displayText; }
        }
    }
}
