internal IAction BuildAction() { IAction action = AbstractAction.Create(_action); Stack <PathSegment> stack = new Stack <PathSegment>(); AbstractActionModelTreeNode current = this; do { stack.Push(current.PathSegment); current = current.Parent; } while (current != null); Path path = new Path(stack.Pop()); // the first path segment is the site, which is never processed through the resource resolver while (stack.Count > 0) { // for each subsequent segment, ensure the action's resolver will resolve the string in the expected way PathSegment pathSegment = stack.Pop(); string localizedString = action.ResourceResolver.LocalizeString(pathSegment.ResourceKey); if (localizedString == pathSegment.LocalizedText) { path = path.Append(pathSegment); } else { path = path.Append(new PathSegment(pathSegment.LocalizedText, pathSegment.LocalizedText)); } } action.Path = new ActionPath(path.ToString(), action.ResourceResolver); return(action); }
public AbstractActionModelTreeLeafAction(IAction action) : base(action.Path.LastSegment) { Platform.CheckForNullReference(action, "action"); Platform.CheckTrue(action.Persistent, "Action must be persistent."); // this allows us to keep a "clone" that is independent of the live action objects // that might (probably are) in use or cached in some tool or component somewhere. _action = AbstractAction.Create(action); CheckState = _action.Available ? CheckState.Checked : CheckState.Unchecked; IconSet iconSet; if (action.IconSet == null || action.ResourceResolver == null) { iconSet = new IconSet("Icons.ActionModelNullSmall.png", "Icons.ActionModelNullMedium.png", "Icons.ActionModelNullLarge.png"); ResourceResolver = new ApplicationThemeResourceResolver(typeof(AbstractActionModelTreeLeafAction).Assembly, action.ResourceResolver); } else { iconSet = _action.IconSet; ResourceResolver = _action.ResourceResolver; } if (_action.Permissible) { IconSet = iconSet; } else { IconSet = new UnavailableActionIconSet(iconSet); Description = SR.TooltipActionNotPermitted; Tooltip = String.IsNullOrEmpty(CanonicalLabel) ? SR.TooltipActionNotPermitted : String.Format(SR.TooltipFormatActionNotPermitted, CanonicalLabel); } }
private static IActionSet CreateAbstractActionSet(string actionModelId) { var dummyResourceResolver = new ResourceResolver(typeof(ActionModelsTool), false); var actionNodes = ActionModelSettings.DefaultInstance.ActionModelsXml.SelectNodes(string.Format("/action-models/action-model[@id='{0}']/action", actionModelId)); return(actionNodes != null ? new ActionSet((from XmlElement action in actionNodes select AbstractAction.Create(action.GetAttribute("id"), action.GetAttribute("path"), true, dummyResourceResolver)).ToList()) : new ActionSet()); }