/// <exclude /> public override IEnumerable <PackageFragmentValidationResult> Validate() { List <PackageFragmentValidationResult> validationResults = new List <PackageFragmentValidationResult>(); if (this.Configuration.Count(f => f.Name == "Locales") > 1) { validationResults.AddFatal(GetText("VirtualElementProviderNodePackageFragmentUninstaller.OnlyOneElement")); return(validationResults); } XElement localesElement = this.Configuration.SingleOrDefault(f => f.Name == "Locales"); _culturesToUninstall = new List <CultureInfo>(); if (localesElement != null) { XAttribute oldDefaultAttribute = localesElement.Attribute("oldDefault"); if (oldDefaultAttribute != null) { _oldDefaultCultureInfo = CultureInfo.CreateSpecificCulture(oldDefaultAttribute.Value); } foreach (XElement localeElement in localesElement.Elements("Locale").Reverse()) { CultureInfo locale = CultureInfo.CreateSpecificCulture(localeElement.Attribute("name").Value); if ((_oldDefaultCultureInfo == null) && (LocalizationFacade.IsDefaultLocale(locale))) { // Locale is default -> not possible to unintall validationResults.AddFatal(GetText("VirtualElementProviderNodePackageFragmentUninstaller.OnlyOneElement")); continue; } if (LocalizationFacade.IsOnlyActiveLocaleForSomeUsers(locale)) { // only active for the a user validationResults.AddFatal(GetText("VirtualElementProviderNodePackageFragmentUninstaller.OnlyOneElement")); continue; } if (LocalizationFacade.IsLocaleInstalled(locale)) { _culturesToUninstall.Add(locale); } } } if (validationResults.Count > 0) { _culturesToUninstall = null; _oldDefaultCultureInfo = null; } return(validationResults); }
private void IsCurrentDefaultLocale(object sender, ConditionalEventArgs e) { CultureInfo cultureInfo = CreateCultureInfo(); e.Result = LocalizationFacade.IsDefaultLocale(cultureInfo); }
public IEnumerable <Element> GetChildren(EntityToken entityToken, SearchToken seachToken) { if ((entityToken is LocalizationElementProviderRootEntityToken) == false) { throw new InvalidOperationException(); } IEnumerable <ISystemActiveLocale> locales = DataFacade.GetData <ISystemActiveLocale>().ToList(); List <Element> elements = new List <Element>(); foreach (ISystemActiveLocale locale in locales) { bool isDefault = LocalizationFacade.IsDefaultLocale(locale.CultureName); ResourceHandle iconHandle = LocaleItemIcon; if (isDefault) { //lable = string.Format("{0} ({1})", lable, StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "ElementProvider.DefaultLabel")); iconHandle = DefaultLocaleItemIcon; } Element element = new Element(_context.CreateElementHandle(locale.GetDataEntityToken())); element.VisualData = new ElementVisualizedData { Label = DataLocalizationFacade.GetCultureTitle(new CultureInfo(locale.CultureName)), ToolTip = DataLocalizationFacade.GetCultureTitle(new CultureInfo(locale.CultureName)), HasChildren = false, Icon = iconHandle }; element.AddAction(new ElementAction(new ActionHandle( new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.LocalizationElementProvider.EditSystemLocaleWorkflow"), new PermissionType[] { PermissionType.Administrate } ))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "EditSystemLocaleWorkflow.EditElementActionLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "EditSystemLocaleWorkflow.EditElementActionToolTip"), Icon = EditSystemLocaleIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); if (isDefault == false) { element.AddAction(new ElementAction(new ActionHandle( new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.LocalizationElementProvider.DefineDefaultActiveLocaleWorkflow"), new PermissionType[] { PermissionType.Administrate } ))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "DefineDefaultActiveLocaleWorkflow.ElementActionLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "DefineDefaultActiveLocaleWorkflow.ElementActionToolTip"), Icon = SetAsDefaultIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); element.AddAction(new ElementAction(new ActionHandle( new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.LocalizationElementProvider.RemoveSystemLocaleWorkflow"), new PermissionType[] { PermissionType.Administrate } ))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "RemoveSystemLocaleWorkflow.RemoveElementActionLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "RemoveSystemLocaleWorkflow.RemoveElementActionToolTip"), Icon = RemoveSystemLocaleIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Delete, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); } elements.Add(element); } return(elements.OrderBy(f => f.VisualData.Label)); }