You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2013/10/18 02:25:30 UTC
[08/30] AMBARI-3266. Contribute Ambari-SCOM. (Tom Beerbower via
mahadev)
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsSilverlight/WidgetsSilverlight.csproj
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsSilverlight/WidgetsSilverlight.csproj b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsSilverlight/WidgetsSilverlight.csproj
new file mode 100644
index 0000000..2f08836
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsSilverlight/WidgetsSilverlight.csproj
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.-->
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{729E6DB2-31F7-4EB1-9146-A2F2263585EE}</ProjectGuid>
+ <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Ambari.SCOM.Widgets</RootNamespace>
+ <AssemblyName>Ambari.SCOM.Widgets.Silverlight</AssemblyName>
+ <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
+ <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
+ <SilverlightApplication>false</SilverlightApplication>
+ <ValidateXaml>true</ValidateXaml>
+ <ThrowErrorsInValidation>true</ThrowErrorsInValidation>
+ <SccProjectName>SAK</SccProjectName>
+ <SccLocalPath>SAK</SccLocalPath>
+ <SccAuxPath>SAK</SccAuxPath>
+ <SccProvider>SAK</SccProvider>
+ </PropertyGroup>
+ <!-- This property group is only here to support building this project using the
+ MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs
+ to set the TargetFrameworkVersion to v3.5 -->
+ <PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'">
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>Bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>Bin\Release</OutputPath>
+ <DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.EnterpriseManagement.CompositionEngine">
+ <HintPath>..\Items\Libs\SCOM2012_Web\Microsoft.EnterpriseManagement.CompositionEngine.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.EnterpriseManagement.CompositionEngine.Extensibility">
+ <HintPath>..\Items\Libs\SCOM2012_Web\Microsoft.EnterpriseManagement.CompositionEngine.Extensibility.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.EnterpriseManagement.Presentation.Controls">
+ <HintPath>..\Items\Libs\SCOM2012_Web\Microsoft.EnterpriseManagement.Presentation.Controls.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.EnterpriseManagement.Presentation.Core">
+ <HintPath>..\Items\Libs\SCOM2012_Web\Microsoft.EnterpriseManagement.Presentation.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Practices.Unity.Silverlight">
+ <HintPath>..\Items\Libs\SCOM2012_Web\Microsoft.Practices.Unity.Silverlight.dll</HintPath>
+ </Reference>
+ <Reference Include="mscorlib" />
+ <Reference Include="System.ComponentModel.Composition, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="System.Windows" />
+ <Reference Include="system" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Windows.Controls.DataVisualization.Toolkit">
+ <HintPath>..\Items\Libs\SCOM2012_Web\System.Windows.Controls.DataVisualization.Toolkit.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Net" />
+ <Reference Include="System.Windows.Browser" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\WidgetsWpf\Charting\Axes\ForegroundDateTimeAxis.cs">
+ <Link>Charting\Axes\ForegroundDateTimeAxis.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\Axes\ForegroundDateTimeDataToAxisConverter.cs">
+ <Link>Charting\Axes\ForegroundDateTimeDataToAxisConverter.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\Axes\ForegroundLinearAxis.cs">
+ <Link>Charting\Axes\ForegroundLinearAxis.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\Axes\ForegroundLinearDataToAxisConverter.cs">
+ <Link>Charting\Axes\ForegroundLinearDataToAxisConverter.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\Chart.xaml.cs">
+ <Link>Charting\Chart.xaml.cs</Link>
+ <DependentUpon>Chart.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\ChartingConstants.cs">
+ <Link>Charting\ChartingConstants.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\DataSeriesConverters\ExtendedDataToSeriesConverterBase.cs">
+ <Link>Charting\DataSeriesConverters\ExtendedDataToSeriesConverterBase.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\DataSeriesConverters\SeriesDefinitionDataToSeriesConverter.cs">
+ <Link>Charting\DataSeriesConverters\SeriesDefinitionDataToSeriesConverter.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\DataSeriesConverters\StackedAreaDataToSeriesConverter.cs">
+ <Link>Charting\DataSeriesConverters\StackedAreaDataToSeriesConverter.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\SeriesFactories\StackableSeriesFactory.cs">
+ <Link>Charting\SeriesFactories\StackableSeriesFactory.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\SeriesStacker.cs">
+ <Link>Charting\SeriesStacker.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Charting\StackedSeriesManager.cs">
+ <Link>Charting\StackedSeriesManager.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Components\CollectionElementAccessor.cs">
+ <Link>Components\CollectionElementAccessor.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Components\EntitiesToInstancesWithRecursionLevelConverter.cs">
+ <Link>Components\EntitiesToInstancesWithRecursionLevelConverter.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Components\InitializableComponentBase.cs">
+ <Link>Components\InitializableComponentBase.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Components\StringFormatter.cs">
+ <Link>Components\StringFormatter.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Components\StringSplitter.cs">
+ <Link>Components\StringSplitter.cs</Link>
+ </Compile>
+ <Compile Include="..\WidgetsWpf\Extensions\DataTypeExtensions.cs">
+ <Link>Extensions\DataTypeExtensions.cs</Link>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Page Include="..\WidgetsWpf\Charting\Chart.xaml">
+ <Link>Charting\Chart.xaml</Link>
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
+ <SilverlightProjectProperties />
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsSilverlight/WidgetsSilverlight.csproj.user
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsSilverlight/WidgetsSilverlight.csproj.user b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsSilverlight/WidgetsSilverlight.csproj.user
new file mode 100644
index 0000000..a7da3a9
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsSilverlight/WidgetsSilverlight.csproj.user
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.-->
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
+ <SilverlightProjectProperties>
+ <StartPageUrl>
+ </StartPageUrl>
+ <StartAction>DynamicPage</StartAction>
+ <AspNetDebugging>True</AspNetDebugging>
+ <NativeDebugging>False</NativeDebugging>
+ <SQLDebugging>False</SQLDebugging>
+ <ExternalProgram>
+ </ExternalProgram>
+ <StartExternalURL>
+ </StartExternalURL>
+ <StartCmdLineArguments>
+ </StartCmdLineArguments>
+ <StartWorkingDirectory>
+ </StartWorkingDirectory>
+ <ShowWebRefOnDebugPrompt>True</ShowWebRefOnDebugPrompt>
+ <OutOfBrowserProjectToDebug>
+ </OutOfBrowserProjectToDebug>
+ <ShowRiaSvcsOnDebugPrompt>True</ShowRiaSvcsOnDebugPrompt>
+ </SilverlightProjectProperties>
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundDateTimeAxis.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundDateTimeAxis.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundDateTimeAxis.cs
new file mode 100644
index 0000000..97bc775
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundDateTimeAxis.cs
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.Reflection;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.DataVisualization;
+using System.Windows.Controls.DataVisualization.Charting;
+using System.Windows.Shapes;
+
+namespace Ambari.SCOM.Widgets.Charting.Axes {
+ [StyleTypedProperty(Property = "GridLineStyle", StyleTargetType = typeof(Line))]
+ [StyleTypedProperty(Property = "MajorTickMarkStyle", StyleTargetType = typeof(Line))]
+ [StyleTypedProperty(Property = "MinorTickMarkStyle", StyleTargetType = typeof(Line))]
+ [StyleTypedProperty(Property = "AxisLabelStyle", StyleTargetType = typeof(DateTimeAxisLabel))]
+ [StyleTypedProperty(Property = "TitleStyle", StyleTargetType = typeof(Title))]
+ [TemplatePart(Name = AxisGridName, Type = typeof(Grid))]
+ [TemplatePart(Name = AxisTitleName, Type = typeof(Title))]
+ public class ForegroundDateTimeAxis : DateTimeAxis {
+ private Canvas foregroundGridLines;
+ private Canvas ForegroundGridLines {
+ get { return foregroundGridLines; }
+ set {
+ if (foregroundGridLines == value) return;
+ var oldValue = foregroundGridLines;
+ foregroundGridLines = value;
+ OnGridLinesPropertyChanged(oldValue, value);
+ }
+ }
+
+ private PropertyInfo baseGridLines;
+ private Canvas BaseGridLines {
+ get { return baseGridLines.GetValue(this, null) as Canvas; }
+ set { baseGridLines.SetValue(this, value, null); }
+ }
+
+ public ForegroundDateTimeAxis() {
+ baseGridLines = typeof(DisplayAxis).GetProperty("GridLines", BindingFlags.NonPublic | BindingFlags.Instance);
+ }
+
+ protected override void OnShowGridLinesPropertyChanged(bool oldValue, bool newValue) {
+ // This is the only place GridLines property gets assigned in base class.
+ // Wait while GridLines are created
+ base.OnShowGridLinesPropertyChanged(oldValue, newValue);
+ // Asssign it to local member so it will get to foreground
+ ForegroundGridLines = BaseGridLines;
+ // Clear base GridLines property, so it will be removed from background
+ BaseGridLines = null;
+ }
+
+ private void OnGridLinesPropertyChanged(Canvas oldValue, Canvas newValue) {
+ if (SeriesHost != null && oldValue != null)
+ SeriesHost.ForegroundElements.Remove(oldValue);
+ if (SeriesHost != null && newValue != null)
+ SeriesHost.ForegroundElements.Add(newValue);
+ }
+
+ protected override void OnSeriesHostPropertyChanged(ISeriesHost oldValue, ISeriesHost newValue) {
+ if (oldValue != null && ForegroundGridLines != null)
+ oldValue.ForegroundElements.Remove(ForegroundGridLines);
+ if (newValue != null && ForegroundGridLines != null)
+ newValue.ForegroundElements.Add(ForegroundGridLines);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundDateTimeDataToAxisConverter.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundDateTimeDataToAxisConverter.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundDateTimeDataToAxisConverter.cs
new file mode 100644
index 0000000..34339e4
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundDateTimeDataToAxisConverter.cs
@@ -0,0 +1,116 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Composition;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Controls.DataVisualization.Charting;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using Microsoft.EnterpriseManagement.Presentation.Controls;
+using Microsoft.EnterpriseManagement.Presentation.Controls.Charting;
+using Microsoft.EnterpriseManagement.Presentation.Controls.CommonControls;
+using Microsoft.EnterpriseManagement.Presentation.DataAccess;
+
+namespace Ambari.SCOM.Widgets.Charting.Axes {
+ using IDataObject = Microsoft.EnterpriseManagement.Presentation.DataAccess.IDataObject;
+
+ [Export, PartCreationPolicy(CreationPolicy.NonShared)]
+ public class ForegroundDateTimeDataToAxisConverter : IDataToAxisConverter, INotifyPropertyChanged {
+ private static readonly Color DefaultGridLinesColor = Color.FromArgb(255, 128, 128, 128);
+
+ private IDataModel model = CreateDataModel();
+ private IColorConverter colorConverter = new HexToColorConverter();
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public IAxis Convert(IDataObject data) {
+ var axis = new ForegroundDateTimeAxis();
+ if (data == null) return axis;
+
+ SetGridLinesStyle(axis, ResolveColor(data[ChartingConstants.GridLinesColorPropertyName] as string));
+
+ var orientation = AxisOrientation.None;
+ if (data[AxisDataConstants.Orientation] != null)
+ Enum.TryParse<AxisOrientation>(data[AxisDataConstants.Orientation] as string, out orientation);
+
+ var minimum = DateTime.MinValue;
+ if (data[AxisDataConstants.Minimum] != null)
+ DateTime.TryParse(data[AxisDataConstants.Minimum].ToString(), CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out minimum);
+
+ var maximum = DateTime.MaxValue;
+ if (data[AxisDataConstants.Maximum] != null)
+ DateTime.TryParse(data[AxisDataConstants.Maximum].ToString(), CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out maximum);
+
+ int interval = 1;
+ if (data[AxisDataConstants.Interval] != null)
+ int.TryParse(data[AxisDataConstants.Interval].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out interval);
+
+ bool autoCalculate = false;
+ if (data[AxisDataConstants.AutoCalculate] != null)
+ bool.TryParse(data[AxisDataConstants.AutoCalculate].ToString(), out autoCalculate);
+
+ var intervalType = DateTimeIntervalType.Auto;
+ if (data[AxisDataConstants.DateTimeIntervalType] != null)
+ Enum.TryParse<DateTimeIntervalType>(data[AxisDataConstants.DateTimeIntervalType] as string, out intervalType);
+
+ axis.Title = data[AxisDataConstants.Title];
+ axis.Orientation = orientation;
+ // What's the difference if it's foreground or not if you won't show them? :)
+ axis.ShowGridLines = true;
+ axis.IntervalType = intervalType;
+ if (autoCalculate) {
+ axis.Interval = null;
+ axis.Minimum = null;
+ axis.Maximum = null;
+ } else {
+ if (minimum != DateTime.MinValue)
+ axis.Minimum = minimum;
+ if (maximum != DateTime.MaxValue)
+ axis.Maximum = minimum == maximum ? minimum.AddDays(1) : maximum;
+ axis.Interval = interval;
+ }
+
+ return axis;
+ }
+
+ private void SetGridLinesStyle(ForegroundDateTimeAxis axis, Color color) {
+ var gridStyle = new Style(typeof(Line));
+ gridStyle.Setters.Add(new Setter(Line.StrokeProperty, new SolidColorBrush(color)));
+ gridStyle.Setters.Add(new Setter(Line.StrokeThicknessProperty, (double)1));
+ gridStyle.Setters.Add(new Setter(Line.OpacityProperty, (double)0.5));
+ axis.GridLineStyle = gridStyle;
+ }
+
+ protected Color ResolveColor(string hexColor) {
+ var resultColor = DefaultGridLinesColor;
+ if (string.IsNullOrEmpty(hexColor)) return resultColor;
+ var colorObject = model.CreateInstance(model.Types[ChartingConstants.HexColorDataType]);
+ colorObject[ChartingConstants.HexColorPropertyName] = hexColor;
+ return colorConverter.Convert(colorObject);
+ }
+
+ private static IDataModel CreateDataModel() {
+ var model = new SimpleDataModel();
+ var colorType = model.Types.Create(ChartingConstants.HexColorDataType);
+ colorType.Properties.Create(ChartingConstants.HexColorPropertyName, typeof(string));
+ return model;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundLinearAxis.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundLinearAxis.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundLinearAxis.cs
new file mode 100644
index 0000000..8cb4071
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundLinearAxis.cs
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.DataVisualization;
+using System.Windows.Shapes;
+using System.Windows.Controls.DataVisualization.Charting;
+using System.Reflection;
+
+namespace Ambari.SCOM.Widgets.Charting.Axes {
+ [StyleTypedProperty(Property = "GridLineStyle", StyleTargetType = typeof(Line))]
+ [StyleTypedProperty(Property = "MajorTickMarkStyle", StyleTargetType = typeof(Line))]
+ [StyleTypedProperty(Property = "MinorTickMarkStyle", StyleTargetType = typeof(Line))]
+ [StyleTypedProperty(Property = "AxisLabelStyle", StyleTargetType = typeof(NumericAxisLabel))]
+ [StyleTypedProperty(Property = "TitleStyle", StyleTargetType = typeof(Title))]
+ [TemplatePart(Name = AxisGridName, Type = typeof(Grid))]
+ [TemplatePart(Name = AxisTitleName, Type = typeof(Title))]
+ public class ForegroundLinearAxis : LinearAxis {
+ private Canvas foregroundGridLines;
+ private Canvas ForegroundGridLines {
+ get { return foregroundGridLines; }
+ set {
+ if (foregroundGridLines == value) return;
+ var oldValue = foregroundGridLines;
+ foregroundGridLines = value;
+ OnGridLinesPropertyChanged(oldValue, value);
+ }
+ }
+
+ private PropertyInfo baseGridLines;
+ private Canvas BaseGridLines {
+ get { return baseGridLines.GetValue(this, null) as Canvas; }
+ set { baseGridLines.SetValue(this, value, null); }
+ }
+
+ public ForegroundLinearAxis() {
+ baseGridLines = typeof(DisplayAxis).GetProperty("GridLines", BindingFlags.NonPublic | BindingFlags.Instance);
+ }
+
+ protected override void OnShowGridLinesPropertyChanged(bool oldValue, bool newValue) {
+ // This is the only place GridLines property gets assigned in base class.
+ // Wait while GridLines are created
+ base.OnShowGridLinesPropertyChanged(oldValue, newValue);
+ // Asssign it to local member so it will get to foreground
+ ForegroundGridLines = BaseGridLines;
+ // Clear base GridLines property, so it will be removed from background
+ BaseGridLines = null;
+ }
+
+ private void OnGridLinesPropertyChanged(Canvas oldValue, Canvas newValue) {
+ if (SeriesHost != null && oldValue != null)
+ SeriesHost.ForegroundElements.Remove(oldValue);
+ if (SeriesHost != null && newValue != null)
+ SeriesHost.ForegroundElements.Add(newValue);
+ }
+
+ protected override void OnSeriesHostPropertyChanged(ISeriesHost oldValue, ISeriesHost newValue) {
+ if (oldValue != null && ForegroundGridLines != null)
+ oldValue.ForegroundElements.Remove(ForegroundGridLines);
+ if (newValue != null && ForegroundGridLines != null)
+ newValue.ForegroundElements.Add(ForegroundGridLines);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundLinearDataToAxisConverter.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundLinearDataToAxisConverter.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundLinearDataToAxisConverter.cs
new file mode 100644
index 0000000..339ec18
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Axes/ForegroundLinearDataToAxisConverter.cs
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Composition;
+using System.Globalization;
+using System.Windows.Controls.DataVisualization.Charting;
+using Microsoft.EnterpriseManagement.Presentation.Controls;
+using Microsoft.EnterpriseManagement.Presentation.Controls.Charting;
+using Microsoft.EnterpriseManagement.Presentation.DataAccess;
+
+namespace Ambari.SCOM.Widgets.Charting.Axes {
+ [Export, PartCreationPolicy(CreationPolicy.NonShared)]
+ public class ForegroundLinearDataToAxisConverter : IDataToAxisConverter, INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public IAxis Convert(IDataObject data) {
+ var axis = new ForegroundLinearAxis();
+ if (data == null) return axis;
+
+ var orientation = AxisOrientation.None;
+ if (data[AxisDataConstants.Orientation] != null)
+ Enum.TryParse<AxisOrientation>(data[AxisDataConstants.Orientation] as string, out orientation);
+
+ int minimum = 0;
+ if (data[AxisDataConstants.Minimum] != null)
+ int.TryParse(data[AxisDataConstants.Minimum].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out minimum);
+
+ int maximum = 0;
+ if (data[AxisDataConstants.Maximum] != null)
+ int.TryParse(data[AxisDataConstants.Maximum].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out maximum);
+
+ int interval = int.MinValue;
+ if (data[AxisDataConstants.Interval] != null)
+ int.TryParse(data[AxisDataConstants.Interval].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out interval);
+
+ bool autoCalculate = true;
+ if (data[AxisDataConstants.AutoCalculate] != null)
+ bool.TryParse(data[AxisDataConstants.AutoCalculate].ToString(), out autoCalculate);
+
+ axis.Title = data[AxisDataConstants.Title];
+ axis.Orientation = orientation;
+ // What's the difference if it's foreground or not if you won't show them? :)
+ axis.ShowGridLines = true;
+ if (autoCalculate) {
+ axis.Interval = null;
+ // Only maximum and interval values are auto calculated
+ axis.Minimum = minimum;
+ axis.Maximum = null;
+ } else {
+ if (interval <= 0) {
+ axis.Interval = null;
+ } else {
+ axis.Interval = interval;
+ }
+
+ axis.Minimum = minimum;
+ if (minimum == maximum) {
+ axis.Maximum = interval > 0 ? minimum + interval : minimum + 1;
+ } else {
+ axis.Maximum = maximum;
+ }
+ }
+
+ return axis;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Chart.xaml
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Chart.xaml b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Chart.xaml
new file mode 100644
index 0000000..8648341
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Chart.xaml
@@ -0,0 +1,148 @@
+<UserControl x:Class="Ambari.SCOM.Widgets.Charting.Chart"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:p="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit"
+ xmlns:vt="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
+ xmlns:system="clr-namespace:System;assembly=mscorlib"
+ xmlns:axes="clr-namespace:Ambari.SCOM.Widgets.Charting.Axes"
+ xmlns:scaxes="clr-namespace:Microsoft.EnterpriseManagement.Presentation.Controls.Chart.Axes;assembly=Microsoft.EnterpriseManagement.Presentation.Controls"
+ xmlns:slc="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
+ xmlns:c="clr-namespace:Microsoft.EnterpriseManagement.Presentation.Controls.Charting;assembly=Microsoft.EnterpriseManagement.Presentation.Controls">
+<!--## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.-->
+ <UserControl.Resources>
+ <!-- This is copy-pasted from original Chart control from Visualization library,
+ so new axes will look like original -->
+ <system:Double x:Key="UnfocusedOpacity">0.2</system:Double>
+ <system:Double x:Key="ChartFontSize">8</system:Double>
+
+ <FontFamily x:Key="ChartFontFamily">Segoe UI, Lucida Sans Unicode, Verdana</FontFamily>
+
+ <SolidColorBrush x:Key="Dashboard_Chart_GridLine" Color="#FFD3D6DD" />
+ <SolidColorBrush x:Key="Dashboard_Chart_Tick_Stroke" Color="#FFD3D6DD" />
+ <SolidColorBrush x:Key="Dashboard_Chart_MajorTick_FG" Color="#FF707175" />
+
+ <Style TargetType="axes:ForegroundLinearAxis">
+ <Setter Property="GridLineStyle">
+ <Setter.Value>
+ <Style TargetType="Line">
+ <Setter Property="Stroke" Value="{StaticResource Dashboard_Chart_GridLine}" />
+ <Setter Property="StrokeThickness" Value="1" />
+ <!-- Semi-transparency is good for foreground axis -->
+ <Setter Property="Opacity" Value="0.75" />
+ </Style>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="MajorTickMarkStyle">
+ <Setter.Value>
+ <Style TargetType="Line">
+ <Setter Property="Stroke" Value="{StaticResource Dashboard_Chart_Tick_Stroke}" />
+ <Setter Property="X2" Value="0" />
+ <Setter Property="Y2" Value="0" />
+ </Style>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="AxisLabelStyle">
+ <Setter.Value>
+ <Style TargetType="slc:AxisLabel">
+ <Setter Property="StringFormat" Value="{}{0:#,0.######}" />
+ <Setter Property="FontSize" Value="{StaticResource ChartFontSize}" />
+ <Setter Property="FontFamily" Value="{StaticResource ChartFontFamily}" />
+ <Setter Property="Margin" Value="0,0,10,0" />
+ <Setter Property="Foreground" Value="{StaticResource Dashboard_Chart_MajorTick_FG}" />
+ </Style>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <Style TargetType="axes:ForegroundDateTimeAxis">
+ <Setter Property="Location" Value="Bottom" />
+ <Setter Property="GridLineStyle">
+ <Setter.Value>
+ <Style TargetType="Line">
+ <Setter Property="Stroke" Value="{StaticResource Dashboard_Chart_GridLine}" />
+ <Setter Property="StrokeThickness" Value="1" />
+ <!-- Semi-transparency is good for foreground axis -->
+ <Setter Property="Opacity" Value="0.5" />
+ </Style>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="MajorTickMarkStyle">
+ <Setter.Value>
+ <Style TargetType="Line">
+ <Setter Property="Visibility" Value="Visible" />
+ <Setter Property="Stroke" Value="{StaticResource Dashboard_Chart_Tick_Stroke}" />
+ <Setter Property="X2" Value="8" />
+ <Setter Property="Y2" Value="8" />
+ </Style>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="AxisLabelStyle">
+ <Setter.Value>
+ <Style TargetType="slc:DateTimeAxisLabel">
+ <Setter Property="FontSize" Value="{StaticResource ChartFontSize}" />
+ <Setter Property="FontFamily" Value="{StaticResource ChartFontFamily}" />
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="slc:DateTimeAxisLabel">
+ <scaxes:DateTimeCustomTextBlock Foreground="{StaticResource Dashboard_Chart_MajorTick_FG}"
+ Tag="{TemplateBinding FormattedContent}" />
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <!-- Remove points from Area charts -->
+ <Style TargetType="slc:SeriesDefinition">
+ <Setter Property="DataPointStyle">
+ <Setter.Value>
+ <Style TargetType="slc:AreaDataPoint">
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="slc:AreaDataPoint" />
+ </Setter.Value>
+ </Setter>
+ </Style>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <!-- Remove opacity from Area chart -->
+ <Style TargetType="slc:AreaSeries">
+ <Setter Property="PathStyle">
+ <Setter.Value>
+ <Style TargetType="Path">
+ <Setter Property="Opacity" Value="1" />
+ </Style>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <Style TargetType="c:Chart">
+ <Setter Property="VerticalAlignment" Value="Stretch" />
+ <Setter Property="HorizontalAlignment" Value="Stretch" />
+ </Style>
+ </UserControl.Resources>
+
+ <Grid x:Name="MainGrid">
+ <c:Chart x:Name="ChartControl" />
+ </Grid>
+</UserControl>
+
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Chart.xaml.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Chart.xaml.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Chart.xaml.cs
new file mode 100644
index 0000000..8f4bf9b
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/Chart.xaml.cs
@@ -0,0 +1,125 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.ComponentModel.Composition;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.DataVisualization.Charting;
+using Microsoft.EnterpriseManagement.CompositionEngine;
+using Microsoft.Practices.Unity;
+
+namespace Ambari.SCOM.Widgets.Charting {
+ using IDataObject = Microsoft.EnterpriseManagement.Presentation.DataAccess.IDataObject;
+
+ /// <summary>
+ /// Encapsulates SCOM built-in chart control to add custom styles as resources.
+ /// </summary>
+ [Export]
+ [PartCreationPolicy(CreationPolicy.NonShared)]
+ [ComponentBuildUpRequired]
+ public partial class Chart : UserControl, INotifyPropertyChanged, INotifyInitialized {
+ public Chart() {
+ InitializeComponent();
+#if !SILVERLIGHT
+ // Fix Area overflow for WPF
+ var stackedAreaStyle = new Style(typeof(StackedAreaSeries));
+ stackedAreaStyle.Setters.Add(new Setter(StackedAreaSeries.ClipToBoundsProperty, true));
+ Resources.Add(stackedAreaStyle.TargetType, stackedAreaStyle);
+#endif
+ ChartControl.PropertyChanged += OnPropertyChanged;
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public bool AllowSelection { get; set; }
+
+ #region ChartComponent Properties
+
+ public ObservableCollection<IDataObject> InputData {
+ get { return ChartControl.InputData; }
+ set { ChartControl.InputData = value; }
+ }
+
+ public IEnumerable<IDataObject> Axes {
+ get { return ChartControl.Axes; }
+ set { ChartControl.Axes = value; }
+ }
+
+ public ICollection<ISeries> Series {
+ get { return ChartControl.Series; }
+ }
+
+ public IDataObject Interval {
+ get { return ChartControl.Interval; }
+ set { ChartControl.Interval = value; }
+ }
+
+ public IDataObject SelectedSeries {
+ get { return ChartControl.SelectedSeries; }
+ set { ChartControl.SelectedSeries = value; }
+ }
+
+ #endregion ChartComponent Properties
+
+ #region CompositionEngine Properties
+
+ [Dependency]
+ public IUnityContainer Container {
+ get { return ChartControl.Container; }
+ set { ChartControl.Container = value; }
+ }
+
+#pragma warning disable 3003 // Base type is not CLS-compliant
+ [Dependency]
+ public ICompositionEngine CompositionEngine {
+ get { return ChartControl.CompositionEngine; }
+ set { ChartControl.CompositionEngine = value; }
+ }
+
+#pragma warning disable 3003 // Base type is not CLS-compliant
+ [Dependency]
+ public ITypeSystem TypeSystem {
+ get { return ChartControl.TypeSystem; }
+ set { ChartControl.TypeSystem = value; }
+ }
+
+ #endregion CompositionEngine Properties
+
+ private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) {
+ if (!AllowSelection && e.PropertyName == "SelectedSeries") {
+ // Set maximum opacity for all series
+ UnSelectSeries();
+ }
+
+ if (PropertyChanged != null)
+ PropertyChanged(sender, e);
+ }
+
+ private void UnSelectSeries() {
+ foreach (var series in Series) {
+ ((UIElement)series).Opacity = (double)1;
+ }
+ }
+
+ public void Notify() {
+ ChartControl.Notify();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/ChartingConstants.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/ChartingConstants.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/ChartingConstants.cs
new file mode 100644
index 0000000..ef2d690
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/ChartingConstants.cs
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+namespace Ambari.SCOM.Widgets.Charting {
+ static class ChartingConstants {
+ public const string ColorFactoryType = "Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.ColorConverter";
+
+ public const string StackableSeriesType = "xsd://Ambari.SCOM.Presentation!Ambari.SCOM.Presentation.Schema.ChartDataTypes/StackableSeries";
+ public const string AreaSeriesType = "xsd://Ambari.SCOM.Presentation!Ambari.SCOM.Presentation.Schema.ChartDataTypes/AreaSeries";
+
+ public const string HexColorDataType = "xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.ChartDataTypes/HexColor";
+ public const string HexColorPropertyName = "HexString";
+
+ public const string StackedSeriesTypePropertyName = "StackedSeriesType";
+ public const string SeriesOrderPropertyName = "Order";
+ public const string StackedSeriesSizePropertyName = "StackSize";
+
+ public static readonly string GridLinesColorPropertyName = "GridLinesHexColor";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/ExtendedDataToSeriesConverterBase.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/ExtendedDataToSeriesConverterBase.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/ExtendedDataToSeriesConverterBase.cs
new file mode 100644
index 0000000..4a2770f
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/ExtendedDataToSeriesConverterBase.cs
@@ -0,0 +1,68 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System;
+using System.Collections.ObjectModel;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.DataVisualization.Charting;
+using System.Windows.Media;
+using Microsoft.EnterpriseManagement.Presentation.Controls;
+using Microsoft.EnterpriseManagement.Presentation.Controls.Charting;
+
+namespace Ambari.SCOM.Widgets.Charting.DataSeriesConverters {
+ using IDataObject = Microsoft.EnterpriseManagement.Presentation.DataAccess.IDataObject;
+
+ public abstract class ExtendedDataToSeriesConverterBase : DataToSeriesConverterBase {
+ private const double VisualOpacity = 1.0;
+ private const double HiddenOpacity = 0.0;
+
+ protected abstract override ISeries ConvertInternal(IDataObject data, ResourceDictionary availableResources, Color resolvedColor, ObservableCollection<IDataObject> pointCollection, Control tooltip);
+
+ protected double GetSeriesOpacity(IDataObject data) {
+ return data[SeriesDataConstants.Visibility] != null && (bool)data[SeriesDataConstants.Visibility]
+ ? VisualOpacity
+ : HiddenOpacity;
+ }
+
+ protected string GetSeriesId(IDataObject data) {
+ var id = data[SeriesDataConstants.ID] as string;
+ if (string.IsNullOrEmpty(id)) id = Guid.NewGuid().ToString();
+ return id;
+ }
+
+ protected Brush CreateGradientBrush(Color baseColor) {
+ const byte brightness = 60;
+ var gradientStops = new GradientStopCollection();
+ gradientStops.Add(new GradientStop() { Color = LightenColor(baseColor, brightness), Offset = 0.0 });
+ gradientStops.Add(new GradientStop() { Color = baseColor, Offset = 1.0 });
+ return new LinearGradientBrush(gradientStops, 90);
+ }
+
+ private Color LightenColor(Color baseColor, byte lighting) {
+ return Color.FromArgb(baseColor.A,
+ MinByte(byte.MaxValue, (int)baseColor.R + lighting),
+ MinByte(byte.MaxValue, (int)baseColor.G + lighting),
+ MinByte(byte.MaxValue, (int)baseColor.B + lighting)
+ );
+ }
+
+ private byte MinByte(int left, int right) {
+ return (byte)(left < right ? left : right);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/SeriesDefinitionDataToSeriesConverter.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/SeriesDefinitionDataToSeriesConverter.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/SeriesDefinitionDataToSeriesConverter.cs
new file mode 100644
index 0000000..928083b
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/SeriesDefinitionDataToSeriesConverter.cs
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.Collections.ObjectModel;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.DataVisualization.Charting;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using Microsoft.EnterpriseManagement.Presentation.Controls.Charting;
+
+namespace Ambari.SCOM.Widgets.Charting.DataSeriesConverters {
+ using IDataObject = Microsoft.EnterpriseManagement.Presentation.DataAccess.IDataObject;
+
+ public class SeriesDefinitionDataToSeriesConverter : ExtendedDataToSeriesConverterBase {
+ protected override ISeries ConvertInternal(IDataObject data, ResourceDictionary availableResources, Color resolvedColor, ObservableCollection<IDataObject> pointCollection, Control tooltip) {
+ var series = new SeriesDefinition {
+ Title = GetSeriesId(data),
+ Opacity = GetSeriesOpacity(data),
+ ItemsSource = pointCollection,
+ DependentValueBinding = CreateBinding(DataToSeriesConverterBase.YParameter),
+ IndependentValueBinding = CreateBinding(DataToSeriesConverterBase.XParameter),
+ Tag = data
+ };
+#if !SILVERLIGHT
+ series.ToolTip = tooltip;
+#endif
+ SetSeriesStyle(series, resolvedColor);
+ return series;
+ }
+
+ private void SetSeriesStyle(SeriesDefinition seriesDefinition, Color color) {
+ var polygonStyle = new Style(typeof(Polygon));
+ polygonStyle.Setters.Add(new Setter(Polygon.FillProperty, CreateGradientBrush(color)));
+ seriesDefinition.DataShapeStyle = polygonStyle;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/StackedAreaDataToSeriesConverter.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/StackedAreaDataToSeriesConverter.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/StackedAreaDataToSeriesConverter.cs
new file mode 100644
index 0000000..d168e77
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/DataSeriesConverters/StackedAreaDataToSeriesConverter.cs
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel.Composition;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.DataVisualization.Charting;
+using System.Windows.Media;
+using Microsoft.EnterpriseManagement.Presentation.Controls;
+using Microsoft.EnterpriseManagement.Presentation.Controls.Charting;
+
+namespace Ambari.SCOM.Widgets.Charting.DataSeriesConverters {
+ using IDataObject = Microsoft.EnterpriseManagement.Presentation.DataAccess.IDataObject;
+
+ [Export, PartCreationPolicy(CreationPolicy.NonShared)]
+ public class StackedAreaDataToSeriesConverter : DataToSeriesConverterBase {
+ private object singletonSyncObj = new object();
+
+ private IDataToSeriesConverter seriesDefinitionConverter;
+ protected IDataToSeriesConverter SeriesDefinitionConverter {
+ get {
+ if (seriesDefinitionConverter == null) lock (singletonSyncObj) if (seriesDefinitionConverter == null)
+ seriesDefinitionConverter = CreateNewSeriesDefinitionConverter();
+ return seriesDefinitionConverter;
+ }
+ }
+
+ private IDataToSeriesConverter CreateNewSeriesDefinitionConverter() {
+ return new SeriesDefinitionDataToSeriesConverter {
+ // Pass through all dependent properties
+ CompositionEngine = this.CompositionEngine,
+ Container = this.Container,
+ TypeSystem = this.TypeSystem
+ };
+ }
+
+ protected override ISeries ConvertInternal(IDataObject data, ResourceDictionary availableResources,
+ Color resolvedColor, ObservableCollection<IDataObject> seriesCollection, Control tooltip) {
+ // Chart control uses SeriesDataConstants.Visibility property from Tag
+ var series = new StackedAreaSeries {
+ Tag = data
+ };
+
+ var orderedSeriescollection = seriesCollection.OrderBy(s => s[ChartingConstants.SeriesOrderPropertyName] ?? 0);
+ foreach (var stackableSeries in orderedSeriescollection) {
+ var idoCollection = stackableSeries[SeriesDataConstants.Data] as ICollection<IDataObject>;
+ var dataPoints = new IDataObject[idoCollection.Count];
+ idoCollection.CopyTo(dataPoints, 0);
+ var observableDataPoints = new BatchObservableCollection<IDataObject>(dataPoints);
+
+ SeriesDefinitionConverter.Convert(stackableSeries, observableDataPoints, availableResources,
+ (s) => { series.SeriesDefinitions.Add((SeriesDefinition)s); });
+ }
+
+ return series;
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/SeriesFactories/StackableSeriesFactory.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/SeriesFactories/StackableSeriesFactory.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/SeriesFactories/StackableSeriesFactory.cs
new file mode 100644
index 0000000..80bb4d4
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/SeriesFactories/StackableSeriesFactory.cs
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.ComponentModel.Composition;
+using Microsoft.EnterpriseManagement.Presentation.Controls;
+using Microsoft.EnterpriseManagement.Presentation.DataAccess;
+
+namespace Ambari.SCOM.Widgets.Charting.SeriesFactories {
+ [Export, PartCreationPolicy(CreationPolicy.NonShared)]
+ public class StackableSeriesFactory : Series2DFactoryBase {
+ // There is no converter implementation for StackedSeries itself, thus nothing will be shown
+ private const string DefaultStackedSeriesType = "xsd://Ambari.SCOM.Presentation!Ambari.SCOM.Presentation.Schema.ChartDataTypes/StackedSeries";
+
+ protected override string DataTypeName {
+ get { return ChartingConstants.StackableSeriesType; }
+ }
+
+ protected override IDataObject BuildSeriesInternal(IDataObject data, IDataObject configuration, IDataModel dataModel) {
+ var ido = base.BuildSeriesInternal(data, configuration, dataModel);
+ ido[ChartingConstants.StackedSeriesTypePropertyName] = configuration[ChartingConstants.StackedSeriesTypePropertyName] ?? DefaultStackedSeriesType;
+ ido[ChartingConstants.SeriesOrderPropertyName] = configuration[ChartingConstants.SeriesOrderPropertyName] ?? 0;
+ ido[ChartingConstants.StackedSeriesSizePropertyName] = configuration[ChartingConstants.StackedSeriesSizePropertyName] ?? 0;
+ return ido;
+ }
+
+ protected override IDataModel BuildDataModel(IDataObject data) {
+ var model = base.BuildDataModel(data) as ObservableDataModel;
+ var type = model.Types[DataTypeName];
+ type.Properties.Create(ChartingConstants.StackedSeriesTypePropertyName, typeof(string));
+ type.Properties.Create(ChartingConstants.SeriesOrderPropertyName, typeof(int));
+ type.Properties.Create(ChartingConstants.StackedSeriesSizePropertyName, typeof(int));
+ return model;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/SeriesStacker.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/SeriesStacker.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/SeriesStacker.cs
new file mode 100644
index 0000000..d9d571b
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/SeriesStacker.cs
@@ -0,0 +1,137 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Linq;
+using Microsoft.EnterpriseManagement.Presentation.Controls.DataGrid.CollectionView;
+using Microsoft.EnterpriseManagement.Presentation.Collections;
+using Microsoft.EnterpriseManagement.Presentation.DataAccess;
+using Ambari.SCOM.Widgets.Components;
+using Ambari.SCOM.Widgets.Extensions;
+using System.ComponentModel.Composition;
+
+namespace Ambari.SCOM.Widgets.Charting {
+ [Export, PartCreationPolicy(CreationPolicy.NonShared)]
+ public class SeriesStacker : InitializableComponentBase {
+ private OperationsQueue operations = new OperationsQueue();
+
+ private StackedSeriesManager stackedSeriesManager = new StackedSeriesManager();
+
+ private IEnumerable<IDataObject> input;
+ public IEnumerable<IDataObject> Input {
+ get { return input; }
+ set {
+ if (input == value) return;
+ operations.ClearOperations();
+
+ if (input is INotifyCollectionChanged)
+ ((INotifyCollectionChanged)input).CollectionChanged -= HandleInputCollectionChanged;
+
+ input = value;
+
+ if (input is INotifyCollectionChanged)
+ ((INotifyCollectionChanged)input).CollectionChanged += HandleInputCollectionChanged;
+
+ HandleInputCollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, new List<IDataObject>(input), 0));
+ NotifyPropertyChanged("Input");
+ }
+ }
+
+ private ObservableCollection<IDataObject> output;
+ public IEnumerable<IDataObject> Output { get { return output; } }
+
+ private void SetOutput() {
+ output = new ObservableCollection<IDataObject>();
+ NotifyPropertyChanged("Output");
+ }
+
+ #region Handle Changes
+
+ private void HandleInputCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
+ if (!IsInitialized) return;
+ operations.QueueOperation(new Operation(o => {
+ OnInputChanged(o.UserData[0], (NotifyCollectionChangedEventArgs)o.UserData[1]);
+ return true;
+ }, sender, e));
+ }
+
+ private void OnInputChanged(object sender, NotifyCollectionChangedEventArgs e) {
+ switch (e.Action) {
+ case NotifyCollectionChangedAction.Add:
+ AddItems(e.NewItems<IDataObject>());
+ break;
+ case NotifyCollectionChangedAction.Remove:
+ RemoveItems(e.OldItems<IDataObject>());
+ break;
+ case NotifyCollectionChangedAction.Reset:
+ var currentItems = sender as ReadOnlyObservableCollection<IDataObject>;
+ ClearOutput();
+ if (currentItems == null) break;
+ AddItems(currentItems);
+ break;
+ case NotifyCollectionChangedAction.Replace:
+ RemoveItems(e.OldItems<IDataObject>());
+ AddItems(e.NewItems<IDataObject>());
+ break;
+ default: break;
+ }
+ }
+
+ private void AddItems(IList<IDataObject> items) {
+ foreach (var series in items) {
+ if (!series.Type.IsAssignableTo(ChartingConstants.StackableSeriesType)) {
+ // Pass through non-stackable series
+ output.Add(series);
+ continue;
+ }
+
+ var stackedSeries = stackedSeriesManager.Add(series);
+ if (stackedSeries != null && !output.Contains(stackedSeries))
+ output.Add(stackedSeries);
+ }
+ }
+
+ private void RemoveItems(IList<IDataObject> items) {
+ foreach (var series in items) {
+ if (!series.Type.IsAssignableTo(ChartingConstants.StackableSeriesType)) {
+ // Pass through non-stackable series
+ output.Remove(series);
+ continue;
+ }
+
+ var stackedSeries = stackedSeriesManager.Remove(series);
+ if (stackedSeries != null)
+ output.Remove(stackedSeries);
+ }
+ }
+
+ private void ClearOutput() {
+ output.Clear();
+ stackedSeriesManager.Clear();
+ }
+
+ #endregion Handle Changes
+
+ protected override void Initialize() {
+ SetOutput();
+ HandleInputCollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, new List<IDataObject>(input), 0));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/StackedSeriesManager.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/StackedSeriesManager.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/StackedSeriesManager.cs
new file mode 100644
index 0000000..48bd9f9
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Charting/StackedSeriesManager.cs
@@ -0,0 +1,102 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Microsoft.EnterpriseManagement.Presentation.Controls;
+using Microsoft.EnterpriseManagement.Presentation.DataAccess;
+using System.Collections.Generic;
+using System.Collections;
+
+namespace Ambari.SCOM.Widgets.Charting {
+ // Since StackerAreaSeries does not support dynamic inserts into specific position,
+ // this guy will wait until required number of series will be in the list
+ // and then pass it further to rendering.
+ class StackedSeriesManager {
+ private ObservableDataModel model;
+
+ private Dictionary<string, IDataObject> stackedSeries = new Dictionary<string,IDataObject>();
+
+ public StackedSeriesManager() {
+ model = new ObservableDataModel();
+ }
+
+ public IDataObject Add(IDataObject series) {
+ var stackedSeriesType = series[ChartingConstants.StackedSeriesTypePropertyName] as string;
+
+ // Stacker Type should be specified. At least default one.
+ if (string.IsNullOrEmpty(stackedSeriesType))
+ // Pass throught, since series cannot be stacked.
+ return series;
+
+ if (!stackedSeries.ContainsKey(stackedSeriesType))
+ stackedSeries.Add(stackedSeriesType, CreateStackedSeries(stackedSeriesType));
+
+ var stack = ((ICollection<IDataObject>)stackedSeries[stackedSeriesType][SeriesDataConstants.Data]);
+ stack.Add(series);
+ return stack.Count >= (int)(series[ChartingConstants.StackedSeriesSizePropertyName] ?? 0)
+ ? stackedSeries[stackedSeriesType]
+ : null;
+ }
+
+ public IDataObject Remove(IDataObject series) {
+ var stackedSeriesType = series[ChartingConstants.StackedSeriesTypePropertyName] as string;
+ if (string.IsNullOrEmpty(stackedSeriesType) ||
+ !stackedSeries.ContainsKey(stackedSeriesType)) return null;
+
+ var seriesCollection = (ICollection<IDataObject>)stackedSeries[stackedSeriesType][SeriesDataConstants.Data];
+
+ seriesCollection.Remove(series);
+ return seriesCollection.Count >= (int)(series[ChartingConstants.StackedSeriesSizePropertyName] ?? 0)
+ // Stacked series is of required size, do not remove it from the chart
+ ? null
+ // Not all series are in stack, return stacked series to remove it
+ : stackedSeries[stackedSeriesType];
+ }
+
+ public void Clear() {
+ foreach (var stackedSeriesType in stackedSeries.Keys) {
+ var seriesCollection = (ICollection<IDataObject>)stackedSeries[stackedSeriesType][SeriesDataConstants.Data];
+ seriesCollection.Clear();
+ }
+ }
+
+ private IDataObject CreateStackedSeries(string stackedSeriesType) {
+ // Create data type for specified stacked series if not exists
+ if (model.Types.FirstOrDefault(t => String.Compare(t.Name, stackedSeriesType, StringComparison.InvariantCultureIgnoreCase) == 0) == null)
+ AddSeriesTypeToDataModel(stackedSeriesType);
+
+ // Create new specific StackedSeries instance
+ var stackedSeries = model.CreateInstance(model.Types[stackedSeriesType]);
+ stackedSeries[SeriesDataConstants.ID] = stackedSeriesType;
+ stackedSeries[SeriesDataConstants.Data] = new ObservableCollection<IDataObject>();
+ stackedSeries[SeriesDataConstants.Visibility] = true;
+
+ return stackedSeries;
+ }
+
+ private void AddSeriesTypeToDataModel(string typeName) {
+ var type = model.Types.Create(typeName);
+ type.Properties.Create(SeriesDataConstants.ID, typeof(string));
+ type.Properties.Create(SeriesDataConstants.Data, typeof(IDataObject));
+ type.Properties.Create(SeriesDataConstants.Color, typeof(IDataObject));
+ type.Properties.Create(SeriesDataConstants.Visibility, typeof(bool));
+ type.Properties.Create(SeriesDataConstants.Tooltip, typeof(string));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/CollectionElementAccessor.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/CollectionElementAccessor.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/CollectionElementAccessor.cs
new file mode 100644
index 0000000..d37cb2d
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/CollectionElementAccessor.cs
@@ -0,0 +1,84 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.Linq;
+using System.Collections.Specialized;
+
+namespace Ambari.SCOM.Widgets.Components {
+ [Export, PartCreationPolicy(CreationPolicy.NonShared)]
+ public class CollectionElementAccessor : InitializableComponentBase {
+ private IEnumerable<object> collection;
+ public IEnumerable<object> Collection {
+ get { return collection; }
+ set {
+ if (collection == value) return;
+
+ if (collection is INotifyCollectionChanged)
+ ((INotifyCollectionChanged)collection).CollectionChanged -= OnInputCollectionChanged;
+
+ collection = value;
+
+ if (collection is INotifyCollectionChanged)
+ ((INotifyCollectionChanged)collection).CollectionChanged += OnInputCollectionChanged;
+
+ NotifyPropertyChanged("Collection");
+ SelectElement();
+ }
+ }
+
+ private int elementIndex;
+ public int ElementIndex {
+ get { return elementIndex; }
+ set {
+ if (elementIndex == value) return;
+ elementIndex = value;
+ NotifyPropertyChanged("ElementIndex");
+ SelectElement();
+ }
+ }
+
+ private object element;
+ public object Element {
+ get { return element; }
+ set {
+ if (element == value) return;
+ element = value;
+ NotifyPropertyChanged("Element");
+ }
+ }
+
+ protected override void Initialize() {
+ SelectElement();
+ }
+
+ private void SelectElement() {
+ if (!IsInitialized) return;
+ if (elementIndex < 0 || collection == null ||
+ elementIndex >= collection.Count()) {
+ Element = null;
+ } else {
+ Element = collection.Skip(elementIndex).First();
+ }
+ }
+
+ private void OnInputCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
+ SelectElement();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/EntitiesToInstancesWithRecursionLevelConverter.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/EntitiesToInstancesWithRecursionLevelConverter.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/EntitiesToInstancesWithRecursionLevelConverter.cs
new file mode 100644
index 0000000..f788c4f
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/EntitiesToInstancesWithRecursionLevelConverter.cs
@@ -0,0 +1,115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.ComponentModel.Composition;
+using System.Linq;
+using Microsoft.EnterpriseManagement.Presentation.DataAccess;
+
+namespace Ambari.SCOM.Widgets.Components {
+ [Export, PartCreationPolicy(CreationPolicy.NonShared)]
+ public class EntitiesToInstancesWithRecursionLevelConverter : InitializableComponentBase {
+ private const string OutputDataType = "xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataProvider/MPInstanceWithRecursionLevel";
+ private const string MpInstanceDataType = "mpinstance://System.Library!System.Entity";
+ private const string IdProperty = "Id";
+ private const string MpInstanceProperty = "MPInstance";
+ private const string RecursionLevelProperty = "RecursionLevel";
+
+ private ObservableDataModel model;
+
+ private IEnumerable<IDataObject> entities;
+ public IEnumerable<IDataObject> Entities {
+ get { return entities; }
+ set {
+ if (entities == value) return;
+
+ var notifiableCollection = entities as INotifyCollectionChanged;
+ if (notifiableCollection != null)
+ notifiableCollection.CollectionChanged -= OnEntitiesCollectionChanged;
+ entities = value;
+ notifiableCollection = entities as INotifyCollectionChanged;
+ if (notifiableCollection != null)
+ notifiableCollection.CollectionChanged += OnEntitiesCollectionChanged;
+
+ NotifyPropertyChanged("Entities");
+ Convert();
+ }
+ }
+
+ private int recursionLevel;
+ public int RecursionLevel {
+ get { return recursionLevel; }
+ set {
+ if (recursionLevel == value) return;
+ recursionLevel = value;
+ NotifyPropertyChanged("RecursionLevel");
+ Convert();
+ }
+ }
+
+ private IEnumerable<IDataObject> instancesWithRecursionLevel;
+ public IEnumerable<IDataObject> InstancesWithRecursionLevel {
+ get { return instancesWithRecursionLevel; }
+ set {
+ if (instancesWithRecursionLevel == value) return;
+ instancesWithRecursionLevel = value;
+ NotifyPropertyChanged("InstancesWithRecursionLevel");
+ }
+ }
+
+ public EntitiesToInstancesWithRecursionLevelConverter() {
+ InitializeDataModel();
+ }
+
+ protected override void Initialize() {
+ Convert();
+ }
+
+ private void Convert() {
+ if (!IsInitialized) return;
+ var outputCollection = model.CreateCollection(OutputDataType);
+ if (entities == null || !entities.Any()) {
+ outputCollection.Add(ConvertEntity(null));
+ } else {
+ foreach (var enitity in entities)
+ outputCollection.Add(ConvertEntity(enitity));
+ }
+ InstancesWithRecursionLevel = outputCollection;
+ }
+
+ private IDataObject ConvertEntity(IDataObject enitity) {
+ var dataObject = model.CreateInstance(model.Types[OutputDataType]);
+ dataObject[MpInstanceProperty] = enitity;
+ dataObject[RecursionLevelProperty] = recursionLevel;
+ return dataObject;
+ }
+
+ private void InitializeDataModel() {
+ model = new ObservableDataModel();
+ var dataType = model.Types.Create(OutputDataType);
+ dataType.Properties.Create(MpInstanceProperty, typeof(IDataObject));
+ dataType.Properties.Create(RecursionLevelProperty, typeof(int));
+ dataType = model.Types.Create(MpInstanceDataType);
+ dataType.Properties.Create(IdProperty, typeof(string));
+ }
+
+ private void OnEntitiesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
+ Convert();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/InitializableComponentBase.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/InitializableComponentBase.cs b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/InitializableComponentBase.cs
new file mode 100644
index 0000000..f095afa
--- /dev/null
+++ b/contrib/ambari-scom/management-pack/Hadoop_MP/WidgetsWpf/Components/InitializableComponentBase.cs
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.ComponentModel;
+using System.ComponentModel.Composition;
+using Microsoft.EnterpriseManagement.CompositionEngine;
+
+namespace Ambari.SCOM.Widgets.Components {
+ public abstract class InitializableComponentBase : INotifyPropertyChanged, INotifyInitialized {
+ protected bool IsInitialized { get; private set; }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public void Notify() {
+ IsInitialized = true;
+ Initialize();
+ }
+
+ protected abstract void Initialize();
+
+ protected void NotifyPropertyChanged(string propertyName) {
+ if (PropertyChanged != null)
+ PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}