public AddLicenseHeaderToAllProjectsCommand(LicenseHeaderReplacer licenseReplacer, IVsStatusbar statusBar, IDefaultLicenseHeaderPage licenseHeaderPage)
        {
            this.statusBar = statusBar;
              this.licenseReplacer = licenseReplacer;
              this.licenseHeaderPage = licenseHeaderPage;

              addLicenseHeaderToAllFilesCommand = new AddLicenseHeaderToAllFilesCommand(licenseReplacer);
        }
      public void SetUp ()
      {
        _extensionMock = MockRepository.GenerateMock<ILicenseHeaderExtension> ();
        _optionsPage = MockRepository.GenerateMock<IOptionsPage>();
        _replacer = new LicenseHeaderReplacer (_extensionMock);
        _projectItem = MockRepository.GenerateMock<ProjectItem> ();
        _languagesPage = MockRepository.GenerateMock<ILanguagesPage>();
        _extensionMock.Expect (x => x.LanguagesPage).Return (_languagesPage);
        _extensionMock.Expect (x => x.OptionsPage).Return (_optionsPage);
        _optionsPage.Expect (x => x.UseRequiredKeywords).Return (true);
        _optionsPage.Expect (x => x.RequiredKeywords).Return ("");

        _projectItem.Stub(x => x.Open(Constants.vsViewKindTextView)).Return(MockRepository.GenerateMock<Window>());
      }
    public void Handle (LicenseHeaderReplacer licenseHeaderReplacer, ILinkedFileFilter linkedFileFilter)
    {
      foreach (ProjectItem projectItem in linkedFileFilter.ToBeProgressed)
      {
        var headers = LicenseHeaderFinder.GetHeaderRecursive (projectItem);
        licenseHeaderReplacer.RemoveOrReplaceHeader (projectItem, headers, true);
      }

      if (linkedFileFilter.NoLicenseHeaderFile.Any () || linkedFileFilter.NotInSolution.Any ())
      {
        List<ProjectItem> notProgressedItems =
          linkedFileFilter.NoLicenseHeaderFile.Concat (linkedFileFilter.NotInSolution).ToList ();

        List<string> notProgressedNames = notProgressedItems.Select(x => x.Name).ToList();

        Message +=
          string.Format (Resources.LinkedFileUpdateInformation, string.Join ("\n", notProgressedNames))
            .Replace (@"\n", "\n");
      }
    }
    /// <summary>
    /// Initialization of the package; this method is called right after the package is sited, so this is the 
    /// place where you can put all the initilaization code that rely on services provided by VisualStudio.
    /// </summary>
    protected override void Initialize ()
    {
      base.Initialize ();
      _licenseReplacer = new LicenseHeaderReplacer (this);
      _dte = GetService (typeof (DTE)) as DTE2;
      _addedItems = new Stack<ProjectItem>();

      //register commands
      OleMenuCommandService mcs = GetService (typeof (IMenuCommandService)) as OleMenuCommandService;
      if (mcs != null)
      {
        _addLicenseHeaderCommand = RegisterCommand (mcs, PkgCmdIDList.cmdIdAddLicenseHeader, AddLicenseHeaderCallback);
        _removeLicenseHeaderCommand = RegisterCommand (mcs, PkgCmdIDList.cmdIdRemoveLicenseHeader, RemoveLicenseHeaderCallback);
        _addLicenseHeaderCommand.BeforeQueryStatus += QueryEditCommandStatus;

        _addLicenseHeaderToProjectItemCommand = RegisterCommand (mcs, PkgCmdIDList.cmdIdAddLicenseHeaderToProjectItem, AddLicenseHeaderToProjectItemCallback);
        _removeLicenseHeaderFromProjectItemCommand = RegisterCommand (mcs, PkgCmdIDList.cmdIdRemoveLicenseHeaderFromProjectItem, RemoveLicenseHeaderFromProjectItemCallback);
        _addLicenseHeaderToProjectItemCommand.BeforeQueryStatus += QueryProjectItemCommandStatus;

        _addLicenseHeadersToAllFilesCommand = RegisterCommand (mcs, PkgCmdIDList.cmdIdAddLicenseHeadersToAllFiles, AddLicenseHeadersToAllFilesCallback);
        _removeLicenseHeadersFromAllFilesCommand = RegisterCommand (mcs, PkgCmdIDList.cmdIdRemoveLicenseHeadersFromAllFiles, RemoveLicenseHeadersFromAllFilesCallback);
        _addLicenseHeadersToAllFilesCommand.BeforeQueryStatus += QueryAllFilesCommandStatus;

        RegisterCommand (mcs, PkgCmdIDList.cmdIdAddLicenseHeaderDefinitionFile, AddLicenseHeaderDefinitionFileCallback);
        RegisterCommand (mcs, PkgCmdIDList.cmdIdAddExistingLicenseHeaderDefinitionFile, AddExistingLicenseHeaderDefinitionFileCallback);
        RegisterCommand (mcs, PkgCmdIDList.cmdIdLicenseHeaderOptions, LicenseHeaderOptionsCallback);
      }

      //register ItemAdded event handler
      var events = _dte.Events as Events2;
      if (events != null)
      {
        _projectItemEvents = events.ProjectItemsEvents; //we need to keep a reference, otherwise the object is garbage collected and the event won't be fired
        _projectItemEvents.ItemAdded += ItemAdded;
      }

      //register event handlers for linked commands
      var page = (OptionsPage) GetDialogPage (typeof (OptionsPage));
      if (page != null)
      {
        foreach (var command in page.LinkedCommands)
        {
          command.Events = _dte.Events.CommandEvents[command.Guid, command.Id];

          switch (command.ExecutionTime)
          {
            case ExecutionTime.Before:
              command.Events.BeforeExecute += BeforeLinkedCommandExecuted;
              break;
            case ExecutionTime.After:
              command.Events.AfterExecute += AfterLinkedCommandExecuted;
              break;
          }
        }

        page.LinkedCommandsChanged += CommandsChanged;

        //register global event handler for ItemAdded
        _commandEvents = _dte.Events.CommandEvents;
        _commandEvents.BeforeExecute += BeforeAnyCommandExecuted;
      }
    }
 public AddLicenseHeaderToAllProjectsButtonHandler(LicenseHeaderReplacer licenseReplacer, IDefaultLicenseHeaderPage defaultLicenseHeaderPage, DTE2 dte2)
 {
   _licenseReplacer = licenseReplacer;
   _defaultLicenseHeaderPage = defaultLicenseHeaderPage;
   _dte2 = dte2;
 }
 public RemoveLicenseHeaderFromAllProjectsCommand(IVsStatusbar statusBar, LicenseHeaderReplacer licenseReplacer)
 {
   this._statusBar = statusBar;
   this._licenseReplacer = licenseReplacer;
 }
 public RemoveLicenseHeaderFromAllFilesCommand(LicenseHeaderReplacer licenseReplacer)
 {
   this.licenseReplacer = licenseReplacer;
 }
 public AddLicenseHeaderToAllFilesCommand(LicenseHeaderReplacer licenseReplacer)
 {
   this.licenseReplacer = licenseReplacer;
 }
 public ButtonHandlerFactory(ILicenseHeaderExtension licenseHeadersPackage, LicenseHeaderReplacer licenseHeaderReplacer)
 {
   _licenseHeadersPackage = licenseHeadersPackage;
   _licenseHeaderReplacer = licenseHeaderReplacer;
 }
 public AddLicenseHeaderToAllProjectsCommand(LicenseHeaderReplacer licenseReplacer, IDefaultLicenseHeaderPage licenseHeaderPage, SolutionUpdateViewModel solutionUpdateViewModel)
 {
   _licenseHeaderPage = licenseHeaderPage;
   _licenseReplacer = licenseReplacer;
   _solutionUpdateViewModel = solutionUpdateViewModel;
 }