/// <summary> /// Load the registered build tools from the session persistence /// store. /// </summary> public void LoadTools() { _buildTools.ClearAll(); List <String> toolStrings = _persistenceManager.ReadStrings( Constants.KEY_TOOLS_COLLECTION); foreach (string s in toolStrings) { BuildTool tool = BuildTool.Parse(s); if (tool != null) { _buildTools.AddTool(tool); } } List <String> selectedToolStrings = _persistenceManager.ReadStrings( Constants.KEY_SELECTED_TOOLS_COLLECTION); foreach (string s in selectedToolStrings) { _buildTools.SelectTool(s); } }
private void CloneTool() { ListViewItem lvi = GetSelectedItem(); if (lvi == null) { return; } string toolId = lvi.Tag as string; if (toolId == null) { return; } BuildTool oldTool = _buildTools.GetTool(toolId); BuildTool newTool = new BuildTool( Guid.NewGuid().ToString(), oldTool.DocumentType, String.Format(Resources.CloneCopyName, oldTool.DisplayName)); newTool.Action = oldTool.Action; newTool.Path = oldTool.Path; newTool.Args = oldTool.Args; newTool.UserArgs = oldTool.UserArgs; newTool.BuildCommand = oldTool.BuildCommand; newTool.LineParser = oldTool.LineParser; newTool.LineParserName = oldTool.LineParserName; _buildTools.AddTool(newTool); Load(); }
/// <summary> /// Create or update the tool in the build tools collection. /// </summary> /// <returns></returns> private bool SaveTool() { _displayNameTextBox.BackColor = Color.Empty; _toolPathTextBox.BackColor = Color.Empty; string id = (_toolId != null) ? _toolId : Guid.NewGuid().ToString(); string documentTypeString = _documentTypeComboBox.SelectedItem as string; string displayName = _displayNameTextBox.Text.Trim(); string toolAction = _actionComboBox.SelectedItem as string; string toolPath = _toolPathTextBox.Text.Trim(); string toolArgs = _toolArgsTextBox.Text.Trim(); string userArgs = _userArgsTextBox.Text.Trim(); string lineParserName = String.Empty; if (_parserComboBox.SelectedIndex > 0) { lineParserName = _parserComboBox.SelectedItem as string; } id = MakeSafeForSerialization(id); documentTypeString = MakeSafeForSerialization(documentTypeString); displayName = MakeSafeForSerialization(displayName); toolAction = MakeSafeForSerialization(toolAction); toolPath = MakeSafeForSerialization(toolPath); toolArgs = MakeSafeForSerialization(toolArgs); userArgs = MakeSafeForSerialization(userArgs); lineParserName = MakeSafeForSerialization(lineParserName); bool validated = true; if (displayName == String.Empty) { validated = false; _displayNameTextBox.BackColor = Color.Yellow; } if (toolPath == String.Empty) { validated = false; _toolPathTextBox.BackColor = Color.Yellow; } if (!validated) { return(false); } DocumentType documentType = new DocumentType(documentTypeString); BuildTool tool = new BuildTool(id, documentType, displayName); tool.Action = toolAction; tool.Path = toolPath; tool.Args = toolArgs; tool.UserArgs = userArgs; tool.BuildCommand = _buildToolManager.GetBuildCommand(documentType, toolAction); tool.LineParserName = lineParserName; tool.LineParser = _buildToolManager.GetLineParser(tool.LineParserName); _buildTools.AddTool(tool); return(true); }