Ejemplo n.º 1
0
        public void Load(SolutionEntityItem entry, CustomCommandCollection commands, ConfigurationSelector configSelector, CustomCommandType[] supportedTypes)
        {
            this.entry          = entry;
            this.commands       = commands;
            this.configSelector = configSelector;
            this.supportedTypes = supportedTypes;

            // Clean the list
            foreach (CustomCommandWidget ccw in vboxCommands.Children)
            {
                ccw.CommandCreated -= OnCommandCreated;
                ccw.CommandRemoved -= OnCommandRemoved;
                vboxCommands.Remove(ccw);
                ccw.Destroy();
            }

            foreach (CustomCommand cmd in commands)
            {
                if (supportedTypes.Contains(cmd.Type))
                {
                    AddCommandSlot(cmd);
                }
            }
            // Add an empty slot to allow adding more commands.
            AddCommandSlot(null);
        }
Ejemplo n.º 2
0
 public void InitializeTest()
 {
     chat       = new ChatWriterMock();
     command    = new CustomChatCommand();
     collection = new CustomCommandCollection();
     command.CommandCollection = collection;
 }
Ejemplo n.º 3
0
        void InitializeChatCommands()
        {
            chatCommands      = new Dictionary <string, IChatCommand>();
            commandCollection = LoadCustomCommands();
            commandCollection.CollectionModified += () =>
                                                    SaveCustomCommands(commandCollection);

            var commandMappings = ChatCommandFactory.BuildFromReflection();

            foreach (var commandInfo in commandMappings)
            {
                var customProcessor = commandInfo.Instance as ICustomCommandProcessor;
                if (customProcessor != null)
                {
                    customProcessor.CommandCollection = commandCollection;
                }

                foreach (var alias in commandInfo.Aliases)
                {
                    if (chatCommands.ContainsKey(alias))
                    {
                        MessageBox.Show($"Chat alias {alias} is colliding for {commandInfo.Name}!\nThe alias will be ignored.",
                                        "Chat Command Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                        continue;
                    }

                    chatCommands[alias] = commandInfo.Instance;
                }
            }
        }
        void EmitCustomCommandTargets(CustomCommandCollection commands, Project project, StringBuilder builder, string configName, CustomCommandType[] types, ProgressMonitor monitor)
        {
            bool warned = false;

            configName = configName.ToUpper();
            foreach (CustomCommandType type in types)
            {
                bool targetEmitted = false;
                for (int i = 0; i < commands.Count; i++)
                {
                    CustomCommand cmd = commands [i];
                    if (cmd.Type != type)
                    {
                        if (!warned && Array.IndexOf(types, cmd.Type) < 0)
                        {
                            //Warn (only once) if unsupported custom command is found,
                            StringBuilder types_list = new StringBuilder();
                            foreach (CustomCommandType t in types)
                            {
                                types_list.AppendFormat("{0}, ", t);
                            }
                            monitor.ReportWarning(GettextCatalog.GetString(
                                                      "Custom commands of only the following types are supported: {0}.", types_list.ToString()));
                            warned = true;
                        }
                        continue;
                    }

                    if (!targetEmitted)
                    {
                        builder.AppendFormat("{0}_{1}:\n", configName, type.ToString());
                        targetEmitted = true;
                    }

                    string dir, exe, args;
                    ResolveCustomCommand(project, cmd, out dir, out exe, out args);
                    builder.AppendFormat("\t(cd {0} && {1} {2})\n", dir, exe, args);
                }
                if (targetEmitted)
                {
                    builder.Append("\n");
                }
            }
        }
		public void Load (SolutionEntityItem entry, CustomCommandCollection commands, ConfigurationSelector configSelector)
		{
			this.entry = entry;
			this.commands = commands;
			this.configSelector = configSelector;
			
			// Clean the list
			foreach (CustomCommandWidget ccw in vboxCommands.Children) {
				ccw.CommandCreated -= OnCommandCreated;
				ccw.CommandRemoved -= OnCommandRemoved;
				vboxCommands.Remove (ccw);
				ccw.Destroy ();
			}
			
			foreach (CustomCommand cmd in commands) {
				AddCommandSlot (cmd);
			}
			// Add an empty slot to allow adding more commands.
			AddCommandSlot (null);
		}
		protected virtual void OnCopyFrom (ItemConfiguration configuration, bool isRename)
		{
			if (configuration.properties != null) {
				properties = new Hashtable ();
				foreach (DictionaryEntry e in configuration.properties) {
					if (e.Value is ICloneable)
						properties [e.Key] = ((ICloneable)e.Value).Clone ();
					else
						properties [e.Key] = e.Value;
				}
			}
			else
				properties = null;
			customCommands = configuration.customCommands.Clone ();
		}
Ejemplo n.º 7
0
 public void InitializeTest()
 {
     collection = new CustomCommandCollection();
 }
		void EmitCustomCommandTargets (CustomCommandCollection commands, Project project, StringBuilder builder, string configName, CustomCommandType[] types, IProgressMonitor monitor)
		{
			bool warned = false;
			configName = configName.ToUpper ();
			foreach (CustomCommandType type in types) {
				bool targetEmitted = false;
				for (int i = 0; i < commands.Count; i ++) {
					CustomCommand cmd = commands [i];
					if (cmd.Type != type) {
						if (!warned && Array.IndexOf (types, cmd.Type) < 0) {
							//Warn (only once) if unsupported custom command is found,
							StringBuilder types_list = new StringBuilder ();
							foreach (CustomCommandType t in types)
								types_list.AppendFormat ("{0}, ", t);
							monitor.ReportWarning (GettextCatalog.GetString (
								"Custom commands of only the following types are supported: {0}.", types_list.ToString ()));
							warned = true;
						}
						continue;
					}

					if (!targetEmitted) {
						builder.AppendFormat ("{0}_{1}:\n", configName, type.ToString ());
						targetEmitted = true;
					}

					string dir, exe, args;
					ResolveCustomCommand (project, cmd, out dir, out exe, out args);
					builder.AppendFormat ("\t(cd {0} && {1} {2})\n", dir, exe, args);
				}
				if (targetEmitted)
					builder.Append ("\n");
			}
		}
Ejemplo n.º 9
0
		public virtual void CopyFrom (ItemConfiguration configuration)
		{
			ItemConfiguration other = (ItemConfiguration) configuration;
			if (other.properties != null) {
				properties = new Hashtable ();
				foreach (DictionaryEntry e in other.properties) {
					if (e.Value is ICloneable)
						properties [e.Key] = ((ICloneable)e.Value).Clone ();
					else
						properties [e.Key] = e.Value;
				}
			}
			else
				properties = null;
			customCommands = other.customCommands.Clone ();
		}
Ejemplo n.º 10
0
        void SaveCustomCommands(CustomCommandCollection collection)
        {
            string json = JsonConvert.SerializeObject(collection, Formatting.Indented);

            File.WriteAllText(CommandCollectionFilename, json, Encoding.UTF8);
        }