private ListItem CreateActionListItem(string actionName) { WorkflowAction action = new PushTransientStateNavigationTransition(new Guid(), actionName, actionName, null, null, null, null); ListItem item = new ListItem("Name", action.DisplayTitle) { Command = new MethodDelegateCommand(action.Execute), Enabled = true }; item.AdditionalProperties[AbstractConfigurationConverter.KEY_ITEM_ACTION] = action; item.SetLabel("Help", action.HelpText); return(item); }
public void UpdateMenuActions(NavigationContext context, IDictionary <Guid, WorkflowAction> actions) { IConfigurationManager configurationManager = ServiceRegistration.Get <IConfigurationManager>(); string configLocation = GetConfigLocation(context); WorkflowState mainState; ServiceRegistration.Get <IWorkflowManager>().States.TryGetValue(new Guid(CONFIGURATION_MAIN_STATE_ID_STR), out mainState); IConfigurationNode currentNode = configurationManager.GetNode(configLocation); foreach (IConfigurationNode childNode in currentNode.ChildNodes) { if (childNode.ConfigObj is ConfigSection) { bool supportedSettings = NumSettingsSupported(childNode) > 0; // Hint (Albert): Instead of skipping, we could disable the transition in case there are no supported // settings contained in it if (!supportedSettings) { continue; } ConfigSection section = (ConfigSection)childNode.ConfigObj; // Create transient state for new config section WorkflowState newState = WorkflowState.CreateTransientState( string.Format("Config: '{0}'", childNode.Location), section.SectionMetadata.Text, false, CONFIGURATION_SECTION_SCREEN, false, WorkflowType.Workflow, context.WorkflowState.HideGroups); // Add action for menu IResourceString res = LocalizationHelper.CreateResourceString(section.Metadata.Text); WorkflowAction wa = new PushTransientStateNavigationTransition( Guid.NewGuid(), context.WorkflowState.Name + "->" + childNode.Location, null, new Guid[] { context.WorkflowState.StateId }, newState, res) { DisplayCategory = ACTIONS_WORKFLOW_CATEGORY, SortOrder = childNode.Sort ?? res.Evaluate(), WorkflowNavigationContextVariables = new Dictionary <string, object> { { CONFIG_LOCATION_KEY, childNode.Location } } }; actions.Add(wa.ActionId, wa); } } }