Exemplo n.º 1
0
    /// <summary>
    /// Rename the underlying document based on the change the user just made to the edit label.
    /// </summary>
    public override int SetEditLabel(string label, string strRelPath) {

      uint oldId = this.hierarchyId;
      string strSavePath = Path.GetDirectoryName(new Uri(this.xmlNode.OwnerDocument.BaseURI).LocalPath);
      strSavePath = Path.Combine(strSavePath, strRelPath);
      string strNewName = Path.Combine(strSavePath, label); 
      string strOldName = this.Url;

      // must update the caption prior to calling RenameDocument, since it may
      // cause queries of that property (such as from open editors).
      string oldrelPath = this.xmlNode.GetAttribute("RelPath");
      this.xmlNode.SetAttribute("RelPath",this.parentNode.XmlNode.GetAttribute("RelPath") + label);

      try  {
        if (!RenameDocument(strOldName, strNewName)) {
          this.xmlNode.SetAttribute("RelPath", oldrelPath);
        }
      }
      catch (Exception e){
        System.Windows.Forms.MessageBox.Show(e.Message);
        CCITracing.Trace(e);
        this.xmlNode.SetAttribute("RelPath", oldrelPath);
        return (int)HResult.E_FAIL;
      }

      /// Return S_FALSE if the hierarchy item id has changed.  This forces VS to flush the stale
      /// hierarchy item id.
      return (oldId == this.hierarchyId) ? 0 : (int)HResult.S_FALSE;
    }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a folder nodes physical directory
        /// Override if your node does not use file system folder
        /// </summary>
        /// <param name="newName"></param>
        /// <returns></returns>
        public virtual void CreateDirectory(string newName)
        {
            if (String.IsNullOrEmpty(newName))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "newName");
            }

            try
            {
                // on a new dir && enter, we get called with the same name (so do nothing if name is the same
                char[] dummy = new char[1];
                dummy[0] = Path.DirectorySeparatorChar;
                string oldDir = this.Url;
                oldDir = oldDir.TrimEnd(dummy);
                string strNewDir = Path.Combine(Path.GetDirectoryName(oldDir), newName);

                if (String.Compare(strNewDir, oldDir, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    if (Directory.Exists(strNewDir))
                    {
                        throw new InvalidOperationException(SR.GetString(SR.DirectoryExistError, CultureInfo.CurrentUICulture));
                    }
                    Directory.CreateDirectory(strNewDir);
                }
            }
            //TODO - this should not digest all exceptions.
            catch (System.Exception e)
            {
                CCITracing.Trace(e);
                throw e;
            }
        }
Exemplo n.º 3
0
        public virtual string GetRegistrationScript()
        {
            string packageScript  = GetResourceAsString(typeof(PackageInstaller), "Microsoft.VisualStudio.Project.InstallPackage.rgs");
            string projectScript  = GetResourceAsString(typeof(PackageInstaller), "Microsoft.VisualStudio.Project.InstallProject.rgs");
            string languageScript = GetResourceAsString(typeof(PackageInstaller), "Microsoft.VisualStudio.Project.InstallLanguage.rgs");
            string editorScript   = GetResourceAsString(typeof(PackageInstaller), "Microsoft.VisualStudio.Project.InstallEditor.rgs");
            string debuggerScript = GetResourceAsString(typeof(PackageInstaller), "Microsoft.VisualStudio.Project.InstallDebugger.rgs");
            string vsipLicense    = GetResourceAsString(typeof(PackageInstaller), "Microsoft.VisualStudio.Project.InstallVSIPLicense.rgs");
            string result         = packageScript;

            if (this.LanguageServiceType != null)
            {
                result += languageScript;
            }
            if (this.EditorFactoryType != null)
            {
                result += editorScript;
            }
            if (this.ProjectFactoryType != null)
            {
                result += projectScript;
            }
            if (this.DebuggerEEGuid != null)
            {
                result += debuggerScript;
            }
            if (this.InstalVSIPLicense)
            {
                result += vsipLicense;
            }
            CCITracing.Trace(result);
            return(result);
        }
Exemplo n.º 4
0
 /// <summary>
 /// creates the physical directory for a folder node
 /// Override if your node does not use file system folder
 /// </summary>
 public virtual void CreateDirectory()
 {
     try
     {
         if (Directory.Exists(this.Url) == false)
         {
             Directory.CreateDirectory(this.Url);
         }
     }
     //TODO - this should not digest all exceptions.
     catch (System.Exception e)
     {
         CCITracing.Trace(e);
         throw e;
     }
 }
Exemplo n.º 5
0
        /// <include file='doc\HierarchyItem.uex' path='docs/doc[@for="HierarchyItemNode.SetEditLabel1"]/*' />
        /// <summary>
        /// Rename the underlying document based on the change the user just made to the edit label.
        /// </summary>
        public override int SetEditLabel(string label, string strRelPath)
        {
            uint   oldId       = this.hierarchyId;
            string strSavePath = Path.GetDirectoryName(strRelPath);
            string newRelPath  = Path.Combine(strSavePath, label);

            if (!Path.IsPathRooted(strRelPath))
            {
                strSavePath = Path.Combine(Path.GetDirectoryName(this.ProjectMgr.BaseURI.Uri.LocalPath), strSavePath);
            }
            string strNewName = Path.Combine(strSavePath, label);
            string strOldName = this.Url;
            // must update the caption prior to calling RenameDocument, since it may
            // cause queries of that property (such as from open editors).
            string oldrelPath = this.ItemNode.GetAttribute("Include");

            this.ItemNode.Rename(newRelPath);

            try
            {
                if (!RenameDocument(strOldName, strNewName))
                {
                    this.ItemNode.Rename(oldrelPath);
                    this.itemNode.RefreshProperties();
                }
            }
            catch (Exception e)
            {
                // Just re-throw the exception so we don't get duplicate message boxes.
                //RTLAwareMessageBox.Show(null, e.Message, null, MessageBoxButtons.OK,
                //    MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
                CCITracing.Trace(e);
                this.ItemNode.Rename(oldrelPath);
                throw e;
                //return (int)NativeMethods.E_FAIL;
            }
            /// Return S_FALSE if the hierarchy item id has changed.  This forces VS to flush the stale
            /// hierarchy item id.
            return((oldId == this.hierarchyId) ? 0 : (int)NativeMethods.S_FALSE);
        }
Exemplo n.º 6
0
 public virtual void Terminate()
 {
     CCITracing.Trace(this.GetType().FullName + ": terminated.");
 }
Exemplo n.º 7
0
 /// <summary>
 /// Override this method to intercept the IOleCommandTarget::Exec call.
 /// </summary>
 /// <returns>Usually returns 0 if ok, or OLECMDERR_E_NOTSUPPORTED</returns>
 protected virtual int ExecCommand(ref Guid guidCmdGroup, uint nCmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
 {
     CCITracing.Trace(String.Format("ExecCommand({0},{1})", guidCmdGroup.ToString(), nCmdId));
     unchecked { return((int)OleDocumentError.OLECMDERR_E_NOTSUPPORTED); }
 }