Exemplo n.º 1
0
        public override bool OnCommand()
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            Log.Info("P4EditModified : looking for modified files");

            if (!Plugin.App.Solution.Saved)
            {
                Log.Info($"P4EditModified : solution {Plugin.App.Solution.FullName} was dirty, checkout");
                P4Operations.EditFile(Plugin.App.Solution.FullName, false);
            }

            foreach (Project p in Plugin.App.Solution.Projects)
            {
                if (!p.Saved)
                {
                    Log.Info($"P4EditModified : project {p.FullName} was dirty, checkout");
                    P4Operations.EditFile(p.FullName, false);
                }
            }

            foreach (Document doc in Plugin.App.Documents)
            {
                if (!doc.Saved)
                {
                    Log.Info($"P4EditModified : document {doc.FullName} was dirty, checkout");
                    P4Operations.EditFile(doc.FullName, false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        private void OnProjectRemoved(Project project)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            P4Operations.EditFile(m_plugin.App.Solution.FullName, false);
            P4Operations.DeleteFile(project.FullName);
            // TODO: [jt] Do we want to automatically delete the items from perforce here?
        }
Exemplo n.º 3
0
        private void OnBeforeKeyPress(string Keypress, EnvDTE.TextSelection Selection, bool InStatementCompletion, ref bool CancelKeypress)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            if (mPlugin.App.ActiveDocument != null && mPlugin.App.ActiveDocument.ReadOnly)
            {
                P4Operations.EditFile(mPlugin.App.ActiveDocument.FullName, false);
            }
        }
Exemplo n.º 4
0
        private void OnCheckoutCurrentDocument(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            if (mPlugin.App.ActiveDocument != null && mPlugin.App.ActiveDocument.ReadOnly && !mPlugin.App.ActiveDocument.Saved)
            {
                P4Operations.EditFile(mPlugin.App.ActiveDocument.FullName, false);
            }
        }
Exemplo n.º 5
0
        private void OnProjectAdded(Project project)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            P4Operations.EditFile(m_plugin.App.Solution.FullName, false);
            P4Operations.AddFile(project.FullName);
            // TODO: [jt] We should if the operation is not a add new project but rather a add existing project
            //       step through all the project items and add them to perforce. Or maybe we want the user
            //       to do this herself?
        }
Exemplo n.º 6
0
        public override void OnExecute(SelectedItem item, string fileName)
        {
            string dirname = Path.GetDirectoryName(fileName);

            if (mMainLine)
            {
                var options = (NiftyPerforce.Config)Plugin.Options;
                fileName = P4Operations.RemapToMain(fileName, options.MainLinePath);
            }

            P4Operations.TimeLapseView(dirname, fileName);
        }
Exemplo n.º 7
0
        private void OnItemRemoved(ProjectItem item)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            P4Operations.EditFile(item.ContainingProject.FullName, false);

            for (int i = 0; i < item.FileCount; i++)
            {
                string name = item.get_FileNames((short)i);
                P4Operations.DeleteFile(name);
            }
        }
Exemplo n.º 8
0
        public override void OnExecute(SelectedItem item, string fileName)
        {
            if (!mOnlyUnchanged)
            {
                string message = "You are about to revert the file '" + fileName + "'. Do you want to do this?";
                if (MessageBox.Show(message, "Revert File?", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }
            }

            P4Operations.RevertFile(fileName, mOnlyUnchanged);
        }
Exemplo n.º 9
0
 // [jt] This handler checks for things like paste operations. In theory we should be able to remove the handler above, but
 // I can't get this one to fire reliably... Wonder how much these handlers will slow down the IDE?
 private void OnLineChanged(TextPoint StartPoint, TextPoint EndPoint, int Hint)
 {
     Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
     if ((Hint & (int)vsTextChanged.vsTextChangedNewline) == 0 &&
         (Hint & (int)vsTextChanged.vsTextChangedMultiLine) == 0 &&
         (Hint & (int)vsTextChanged.vsTextChangedNewline) == 0 &&
         (Hint != 0))
     {
         return;
     }
     if (mPlugin.App.ActiveDocument != null && mPlugin.App.ActiveDocument.ReadOnly && !mPlugin.App.ActiveDocument.Saved)
     {
         P4Operations.EditFile(mPlugin.App.ActiveDocument.FullName, false);
     }
 }
Exemplo n.º 10
0
        private void OnCheckoutSelectedProjects(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            // when I get Edit.Delete :
            if (Guid == Microsoft.VisualStudio.VSConstants.CMDSETID.StandardCommandSet97_string && ID == 17)
            {
                // see if the active window is SolutionExplorer :
                Window w = mPlugin.App.ActiveWindow;
                if (w.Type != EnvDTE.vsWindowType.vsWindowTypeSolutionExplorer)
                {
                    // it's just a delete in the text window, get out !
                    return;
                }
            }

            foreach (Project project in (Array)mPlugin.App.ActiveSolutionProjects)
            {
                P4Operations.EditFileImmediate(project.FullName);
            }
        }
Exemplo n.º 11
0
        private void OnItemAdded(ProjectItem item)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            P4Operations.EditFile(item.ContainingProject.FullName, false);

            if (item.ProjectItems != null)
            {
                for (int i = 0; i < item.FileCount; i++)
                {
                    string name = item.get_FileNames((short)i);
                    P4Operations.AddFile(name);
                }
            }
            else
            {
                if (System.IO.File.Exists(item.Name))
                {
                    P4Operations.AddFile(item.Name);
                }
            }
        }
Exemplo n.º 12
0
 public override void OnExecute(SelectedItem item, string fileName)
 {
     P4Operations.EditFile(fileName, true);
 }
Exemplo n.º 13
0
        /// <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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Load up the options from file.
            string optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftyPerforce.xml");
            Config options         = Config.Load(optionsFileName);

            // Every plugin needs a command bar.
            DTE2 application = GetGlobalService(typeof(DTE)) as DTE2;
            IVsProfferCommands3   profferCommands3      = base.GetService(typeof(SVsProfferCommands)) as IVsProfferCommands3;
            OleMenuCommandService oleMenuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            ImageList icons = new ImageList();

            icons.Images.AddStrip(Properties.Resources.Icons);
            m_plugin = new Plugin(application, profferCommands3, icons, oleMenuCommandService, "NiftyPerforce", "Aurora.NiftyPerforce.Connect", options);

            Cleanup();

            CommandBar commandBar = m_plugin.AddCommandBar("NiftyPerforce", MsoBarPosition.msoBarTop);

            m_commandRegistry = new CommandRegistry(m_plugin, commandBar, new Guid(PackageGuidString), new Guid(PackageGuidGroup));

            // Initialize the logging system.
            if (Log.HandlerCount == 0)
            {
#if DEBUG
                Log.AddHandler(new DebugLogHandler());
#endif
                Log.AddHandler(new VisualStudioLogHandler(m_plugin));
                Log.Prefix = "NiftyPerforce";
            }

            // Now we can take care of registering ourselves and all our commands and hooks.
            Log.Debug("Booting up...");
            Log.IncIndent();

            bool doContextCommands  = options.EnableContextMenus;
            bool doBindings         = options.EnableBindings;
            bool doAdvancedCommands = options.EnableAdvancedCommands;

            m_commandRegistry.RegisterCommand(doBindings, new NiftyConfigure(m_plugin, "NiftyConfig"), true);

            if (doAdvancedCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4EditModified(m_plugin, "NiftyEditModified"), true);
            }

            m_commandRegistry.RegisterCommand(doBindings, new P4EditItem(m_plugin, "NiftyEdit"), true);
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4EditItem(m_plugin, "NiftyEditItem"), false);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4EditSolution(m_plugin, "NiftyEditSolution"), false);
            }

            m_commandRegistry.RegisterCommand(doBindings, new P4DiffItem(m_plugin, "NiftyDiff"));
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4DiffItem(m_plugin, "NiftyDiffItem"), false);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4DiffSolution(m_plugin, "NiftyDiffSolution"), false);
            }

            m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistoryItem(m_plugin, "NiftyHistory", false), true);
            if (doAdvancedCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistoryItem(m_plugin, "NiftyHistoryMain", true), true);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistoryItem(m_plugin, "NiftyHistoryItem", false), false);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistoryItem(m_plugin, "NiftyHistoryItemMain", true), false);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistorySolution(m_plugin, "NiftyHistorySolution"), false);
            }

            m_commandRegistry.RegisterCommand(doBindings, new P4TimeLapseItem(m_plugin, "NiftyTimeLapse", false), true);
            if (doAdvancedCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4TimeLapseItem(m_plugin, "NiftyTimeLapseMain", true), true);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4TimeLapseItem(m_plugin, "NiftyTimeLapseItem", false), false);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4TimeLapseItem(m_plugin, "NiftyTimeLapseItemMain", true), false);
            }

            m_commandRegistry.RegisterCommand(doBindings, new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraph", false), true);
            if (doAdvancedCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraphMain", true), true);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraphItem", false), false);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraphItemMain", true), false);
            }

            m_commandRegistry.RegisterCommand(doBindings, new P4RevertItem(m_plugin, "NiftyRevert", false), true);
            m_commandRegistry.RegisterCommand(doBindings, new P4RevertItem(m_plugin, "NiftyRevertUnchanged", true), true);
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4RevertItem(m_plugin, "NiftyRevertItem", false), false);
            }
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4RevertItem(m_plugin, "NiftyRevertUnchangedItem", true), false);
            }

            m_commandRegistry.RegisterCommand(doBindings, new P4ShowItem(m_plugin, "NiftyShow"), true);
            if (doContextCommands)
            {
                m_commandRegistry.RegisterCommand(doBindings, new P4ShowItem(m_plugin, "NiftyShowItem"), false);
            }

            m_plugin.AddFeature(new AutoAddDelete(m_plugin));
            m_plugin.AddFeature(new AutoCheckoutProject(m_plugin));
            m_plugin.AddFeature(new AutoCheckoutOnBuild(m_plugin));
            m_plugin.AddFeature(new AutoCheckoutTextEdit(m_plugin));
            m_plugin.AddFeature(new AutoCheckoutOnSave(m_plugin));

#if DEBUG
            // Use this to track down event GUIDs.
            //m_plugin.AddFeature(new FindEvents(m_plugin));
#endif

            P4Operations.CheckInstalledFiles();

            AsyncProcess.Init();

            Log.DecIndent();
            Log.Debug("Initialized...");

#if DEBUG
            Log.Info("NiftyPerforce (Debug)");
#else
            //Log.Info("NiftyPerforce (Release)");
#endif
            // Show where we are and when we were compiled...
            Log.Info("I'm running {0} compiled on {1}", Assembly.GetExecutingAssembly().Location, System.IO.File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location));
        }
Exemplo n.º 14
0
 public override void OnExecute(SelectedItem item, string fileName)
 {
     P4Operations.P4VShowFile(fileName);
 }
Exemplo n.º 15
0
 internal static bool OnBeforeSave(string filename)
 {
     return(P4Operations.EditFileImmediate(filename));
 }
Exemplo n.º 16
0
        /// <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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            var dteService = GetServiceAsync(typeof(DTE));

            Microsoft.Assumes.Present(dteService);

            var application = await dteService.ConfigureAwait(false) as DTE2;

            var oleMenuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            // Switches to the UI thread in order to consume some services used in command initialization
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            // Initialize the logging system.
            if (Log.HandlerCount == 0)
            {
#if DEBUG
                Log.AddHandler(new DebugLogHandler());
#endif
                Log.AddHandler(new VisualStudioLogHandler("NiftyPerforce", this));
                Log.Prefix = "NiftyPerforce";
            }

            // Show where we are and when we were compiled...
            var     niftyAssembly        = Assembly.GetExecutingAssembly();
            Version version              = niftyAssembly.GetName().Version;
            string  versionString        = string.Join(".", version.Major, version.Minor, version.Build);
            string  informationalVersion = niftyAssembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion;
            if (informationalVersion != null)
            {
                versionString += " " + informationalVersion;
            }

            Log.Info(
                "NiftyPerforce{0} v{1} compiled on {2}"
#if DEBUG
                , " (Debug!)"
#else
                , string.Empty
#endif
                , versionString
                , System.IO.File.GetLastWriteTime(niftyAssembly.Location)
                );

            Log.Debug("    Location '{0}'", niftyAssembly.Location);

            // Now we can take care of registering ourselves and all our commands and hooks.
            Log.Debug("Booting up...");
            Log.IncIndent();

            var config = (Config)GetDialogPage(typeof(Config));
            Singleton <Config> .Instance = config;

#if NIFTY_LEGACY
            config.OnApplyEvent += (object sender, EventArgs e) =>
            {
                if (config.CleanLegacyNiftyCommands)
                {
                    Cleanup();
                    config.CleanLegacyNiftyCommands = false;
                }
            };
#endif

            m_plugin = new Plugin(application, oleMenuCommandService, config);

            m_commandRegistry = new CommandRegistry(m_plugin, new Guid(PackageGuids.guidNiftyPerforcePackageCmdSetString));

            // Add our command handlers for menu (commands must exist in the .vsct file)
            m_commandRegistry.RegisterCommand(new P4EditModified(m_plugin, "NiftyEditModified"));
            m_commandRegistry.RegisterCommand(new P4EditItem(m_plugin, "NiftyEdit"));
            m_commandRegistry.RegisterCommand(new P4DiffItem(m_plugin, "NiftyDiff"));
            m_commandRegistry.RegisterCommand(new P4RevisionHistoryItem(m_plugin, "NiftyHistory", false));
            m_commandRegistry.RegisterCommand(new P4RevisionHistoryItem(m_plugin, "NiftyHistoryMain", true));
            m_commandRegistry.RegisterCommand(new P4TimeLapseItem(m_plugin, "NiftyTimeLapse", false));
            m_commandRegistry.RegisterCommand(new P4TimeLapseItem(m_plugin, "NiftyTimeLapseMain", true));
            m_commandRegistry.RegisterCommand(new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraph", false));
            m_commandRegistry.RegisterCommand(new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraphMain", true));
            m_commandRegistry.RegisterCommand(new P4RevertItem(m_plugin, "NiftyRevert", false));
            m_commandRegistry.RegisterCommand(new P4RevertItem(m_plugin, "NiftyRevertUnchanged", true));
            m_commandRegistry.RegisterCommand(new P4ShowItem(m_plugin, "NiftyShow"));

            m_plugin.AddFeature(new AutoAddDelete(m_plugin));
            m_plugin.AddFeature(new AutoCheckoutProject(m_plugin));
            m_plugin.AddFeature(new AutoCheckoutTextEdit(m_plugin));
            m_plugin.AddFeature(new AutoCheckoutOnSave(m_plugin, this));

            P4Operations.CheckInstalledFiles();

            AsyncProcess.Init();

            Log.DecIndent();
            Log.Debug("Initialized...");
        }