public CustomCommandWidget(IWorkspaceObject entry, CustomCommand cmd, ConfigurationSelector configSelector, CustomCommandType[] supportedTypes) { this.Build(); this.supportedTypes = supportedTypes; this.cmd = cmd; updating = true; if (cmd == null) comboType.AppendText (GettextCatalog.GetString ("(Select a project operation)")); foreach (var ct in supportedTypes) comboType.AppendText (commandNames [(int)ct]); updating = false; this.entry = entry; UpdateControls (); this.WidgetFlags |= Gtk.WidgetFlags.NoShowAll; StringTagModelDescription tagModel; if (entry is SolutionItem) tagModel = ((SolutionItem)entry).GetStringTagModelDescription (configSelector); else if (entry is WorkspaceItem) tagModel = ((WorkspaceItem)entry).GetStringTagModelDescription (); else tagModel = new StringTagModelDescription (); tagSelectorDirectory.TagModel = tagModel; tagSelectorDirectory.TargetEntry = workingdirEntry; tagSelectorCommand.TagModel = tagModel; tagSelectorCommand.TargetEntry = entryCommand; }
public bool CanExecute(IWorkspaceObject entry, CustomCommandType type, ExecutionContext context, ConfigurationSelector configuration) { foreach (CustomCommand cmd in this) { if (cmd.Type == type) { return(cmd.CanExecute(entry, context, configuration)); } } return(false); }
public bool HasCommands(CustomCommandType type) { foreach (CustomCommand cmd in this) { if (cmd.Type == type) { return(true); } } return(false); }
public void ExecuteCommand(IProgressMonitor monitor, IWorkspaceObject entry, CustomCommandType type, ExecutionContext context, ConfigurationSelector configuration) { foreach (CustomCommand cmd in this) { if (cmd.Type == type) { cmd.Execute(monitor, entry, context, configuration); } if (monitor.IsCancelRequested) { break; } } }
public static DataSet ExecQueryDS(string strSQL, CustomCommandType cmdtype, SqlParameter[] param = null) { SqlConnection conn = null /* TODO Change to default(_) if this is not a reference type */; DataSet ds = new DataSet(); try { conn = new SqlConnection(GetConnnectionString("ConnectionString_master")); SqlCommand cmd = new SqlCommand(strSQL, conn); cmd.CommandTimeout = 500000; if (cmdtype.ToString() == "StoredPorcedure") { cmd.CommandType = CommandType.StoredProcedure; } if (cmdtype.ToString() == "SQTString") { cmd.CommandType = CommandType.Text; } if (param != null) { if (param.Length > 0) { foreach (SqlParameter par in param) { cmd.Parameters.Add(new SqlParameter(par.ParameterName, par.Value)); } } } conn.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); conn.Close(); conn.Dispose(); conn = null /* TODO Change to default(_) if this is not a reference type */; } catch (Exception ex) { conn.Close(); conn.Dispose(); conn = null /* TODO Change to default(_) if this is not a reference type */; } return(ds); }
public void Load (SolutionItem 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); }
public bool CanExecute(IWorkspaceObject entry, CustomCommandType type, ExecutionContext context, ConfigurationSelector configuration) { // Note: if this gets changed to return true if *any* of the commands can execute, then // ExecuteCommand() needs to be fixed to only execute commands that can be executed. bool hasCommandType = false; bool canExecute = true; foreach (CustomCommand cmd in this) { if (cmd.Type == type) { hasCommandType = true; if (!cmd.CanExecute(entry, context, configuration)) { canExecute = false; break; } } } return(hasCommandType && canExecute); }
/// <summary> /// Deserializes workflow markup into an CustomCommandType object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output CustomCommandType object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out CustomCommandType obj, out System.Exception exception) { exception = null; obj = default(CustomCommandType); try { obj = Deserialize(xml); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public void ExecuteCommand(IProgressMonitor monitor, IWorkspaceObject entry, CustomCommandType type, ConfigurationSelector configuration) { ExecuteCommand(monitor, entry, type, null, configuration); }
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"); } }
public async Task <bool> ExecuteCommand(ProgressMonitor monitor, WorkspaceObject entry, CustomCommandType type, ExecutionContext context, ConfigurationSelector configuration) { foreach (CustomCommand cmd in this) { if (cmd.Type == type) { if (!await cmd.Execute(monitor, entry, context, configuration)) { return(false); } } } return(true); }
public static bool Deserialize(string xml, out CustomCommandType obj) { System.Exception exception = null; return Deserialize(xml, out obj, out exception); }
public Task <bool> ExecuteCommand(ProgressMonitor monitor, WorkspaceObject entry, CustomCommandType type, ConfigurationSelector configuration) { return(ExecuteCommand(monitor, entry, type, null, configuration)); }
public CustomCommandPanel (CustomCommandType[] supportedTypes) { this.supportedTypes = supportedTypes; }
public void ExecuteCommand(IProgressMonitor monitor, SolutionEntityItem entry, CustomCommandType type, ConfigurationSelector configuration) { ExecuteCommand(monitor, entry, type, null, configuration); }
public static bool LoadFromFile(string fileName, out CustomCommandType obj) { System.Exception exception = null; return LoadFromFile(fileName, out obj, out exception); }
/// <summary> /// Deserializes xml markup from file into an CustomCommandType object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output CustomCommandType object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out CustomCommandType obj, out System.Exception exception) { exception = null; obj = default(CustomCommandType); try { obj = LoadFromFile(fileName); return true; } catch (System.Exception ex) { exception = ex; return false; } }