示例#1
0
        public bool Validate()
        {
            TreeIter first;

            if (toolListBox.Model.GetIterFirst(out first))
            {
                TreeIter current = first;
                do
                {
                    // loop through items in the tree
                    ExternalTool tool = toolListBox.Model.GetValue(current, 1) as ExternalTool;
                    string       path = FilterPath(tool.Command);
                    if (!FileService.IsValidPath(path))
                    {
                        MessageService.ShowError(String.Format(GettextCatalog.GetString("The command of tool \"{0}\" is invalid."), tool.MenuCommand));
                        return(false);
                    }
                    path = FilterPath(tool.InitialDirectory);
                    if ((tool.InitialDirectory != "") && !FileService.IsValidPath(path))
                    {
                        MessageService.ShowError(String.Format(GettextCatalog.GetString("The working directory of tool \"{0}\" is invalid."), tool.MenuCommand));
                        return(false);
                    }
                } while (toolListBox.Model.IterNext(ref current));
            }
            return(true);
        }
 void DisplayTool(ExternalTool externalTool)
 {
     SetEnabledStatus(externalTool != null, dependendControls);
     lockStoreValues = true;
     try {
         if (externalTool != null)
         {
             titleTextBox.Text              = externalTool.MenuCommand ?? "";
             browseButton.Path              = externalTool.Command ?? "";
             argumentTextBox.Text           = externalTool.Arguments ?? "";
             workingDirTextBox.Text         = externalTool.InitialDirectory ?? "";
             CurrentKey                     = externalTool.AccelKey;
             promptArgsCheckBox.Active      = externalTool.PromptForArguments;
             useOutputPadCheckBox.Active    = externalTool.UseOutputPad;
             saveCurrentFileCheckBox.Active = externalTool.SaveCurrentFile;
         }
         else
         {
             titleTextBox.Text         = browseButton.Path = argumentTextBox.Text = workingDirTextBox.Text = CurrentKey = "";
             promptArgsCheckBox.Active = useOutputPadCheckBox.Active = saveCurrentFileCheckBox.Active = false;
         }
         accelIncomplete = false;
         accelComplete   = true;
     } finally {
         lockStoreValues = false;
     }
 }
        static List <ExternalTool> LoadTools(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return(null);
            }
            List <ExternalTool> result = new List <ExternalTool> ();
            XmlReader           reader = XmlTextReader.Create(fileName);

            try {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.LocalName)
                        {
                        case Node:
                            string fileVersion = reader.GetAttribute(VersionAttribute);
                            if (fileVersion != Version)
                            {
                                return(null);
                            }
                            break;

                        case ExternalTool.Node:
                            result.Add(ExternalTool.Read(reader));
                            break;
                        }
                    }
                }
            } finally {
                reader.Close();
            }
            return(result);
        }
示例#4
0
        public static ExternalTool Read(XmlReader reader)
        {
            Debug.Assert(reader.LocalName == Node);

            ExternalTool result = new ExternalTool();

            result.menuCommand      = reader.GetAttribute(menuCommandAttribute);
            result.command          = reader.GetAttribute(commandAttribute);
            result.arguments        = reader.GetAttribute(argumentsAttribute);
            result.initialDirectory = reader.GetAttribute(initialDirectoryAttribute);
            result.menuCommand      = reader.GetAttribute(menuCommandAttribute);

            if (!String.IsNullOrEmpty(reader.GetAttribute(promptForArgumentsAttribute)))
            {
                result.promptForArguments = Boolean.Parse(reader.GetAttribute(promptForArgumentsAttribute));
            }
            if (!String.IsNullOrEmpty(reader.GetAttribute(useOutputPadAttribute)))
            {
                result.useOutputPad = Boolean.Parse(reader.GetAttribute(useOutputPadAttribute));
            }
            if (!String.IsNullOrEmpty(reader.GetAttribute(saveCurrentFileAttribute)))
            {
                result.saveCurrentFile = Boolean.Parse(reader.GetAttribute(saveCurrentFileAttribute));
            }

            // Some tag names have changed. Update them now.

            result.arguments        = UpgradeTags(result.arguments);
            result.initialDirectory = UpgradeTags(result.initialDirectory);

            return(result);
        }
        public bool Store()
        {
            List <ExternalTool> newlist = new List <ExternalTool> ();
            TreeIter            first;

            if (toolListBox.Model.GetIterFirst(out first))
            {
                TreeIter current = first;
                do
                {
                    // loop through items in the tree
                    ExternalTool tool = toolListBox.Model.GetValue(current, 1) as ExternalTool;
                    newlist.Add(tool);
                } while (toolListBox.Model.IterNext(ref current));
            }

            ExternalToolService.Tools = newlist;
            ExternalToolService.SaveTools();
            return(true);
        }
        void StoreValuesInSelectedTool(object sender, EventArgs e)
        {
            if (lockStoreValues)
            {
                return;
            }
            ExternalTool selectedItem = SelectedTool;

            if (selectedItem == null)
            {
                return;
            }

            toolListBoxStore.SetValue(SelectedIter, 0, titleTextBox.Text);
            selectedItem.MenuCommand        = titleTextBox.Text;
            selectedItem.Command            = browseButton.Path;
            selectedItem.Arguments          = argumentTextBox.Text;
            selectedItem.InitialDirectory   = workingDirTextBox.Text;
            selectedItem.PromptForArguments = promptArgsCheckBox.Active;
            selectedItem.UseOutputPad       = useOutputPadCheckBox.Active;
            selectedItem.SaveCurrentFile    = saveCurrentFileCheckBox.Active;
        }
		void DisplayTool (ExternalTool externalTool)
		{
			SetEnabledStatus (externalTool != null, dependendControls);
			lockStoreValues = true;
			try {
				if (externalTool != null) {
					titleTextBox.Text              = externalTool.MenuCommand ?? "";
					browseButton.Path              = externalTool.Command ?? "";
					argumentTextBox.Text           = externalTool.Arguments ?? "";
					workingDirTextBox.Text         = externalTool.InitialDirectory ?? "";
					CurrentKey                     = externalTool.AccelKey;
					promptArgsCheckBox.Active      = externalTool.PromptForArguments ;
					useOutputPadCheckBox.Active    = externalTool.UseOutputPad;
					saveCurrentFileCheckBox.Active = externalTool.SaveCurrentFile;
				} else {
					titleTextBox.Text = browseButton.Path = argumentTextBox.Text = workingDirTextBox.Text = CurrentKey = "";
					promptArgsCheckBox.Active = useOutputPadCheckBox.Active = saveCurrentFileCheckBox.Active = false;
				}
				accelIncomplete = false;
				accelComplete = true;
			} finally {
				lockStoreValues = false;
			}
		}
示例#8
0
		public static ExternalTool Read (XmlReader reader)
		{
			Debug.Assert (reader.LocalName == Node);
			
			ExternalTool result = new ExternalTool ();
			result.menuCommand      = reader.GetAttribute (menuCommandAttribute);
			result.command          = reader.GetAttribute (commandAttribute);
			result.arguments        = reader.GetAttribute (argumentsAttribute);
			result.initialDirectory = reader.GetAttribute (initialDirectoryAttribute);
			result.accelKey         = reader.GetAttribute (accelKeyAttribute);
			
			if (!String.IsNullOrEmpty (reader.GetAttribute (promptForArgumentsAttribute)))
			    result.promptForArguments = Boolean.Parse (reader.GetAttribute (promptForArgumentsAttribute));
			if (!String.IsNullOrEmpty (reader.GetAttribute (useOutputPadAttribute)))
			    result.useOutputPad = Boolean.Parse (reader.GetAttribute (useOutputPadAttribute));
			if (!String.IsNullOrEmpty (reader.GetAttribute (saveCurrentFileAttribute)))
			    result.saveCurrentFile = Boolean.Parse (reader.GetAttribute (saveCurrentFileAttribute));
			
			// Some tag names have changed. Update them now.
			
			result.arguments = UpgradeTags (result.arguments);
			result.initialDirectory = UpgradeTags (result.initialDirectory);
			
			return result;
		}