public int OnQueryRemoveFiles(
            IVsProject pProject, int cFiles, string[] rgpszMkDocuments, VSQUERYREMOVEFILEFLAGS[] rgFlags,
            VSQUERYREMOVEFILERESULTS[] pSummaryResult, VSQUERYREMOVEFILERESULTS[] rgResults)
        {
            var hr      = VSConstants.S_OK;
            var handler = QueryRemoveFile;

            if (handler != null)
            {
                if (cFiles <= rgpszMkDocuments.Length)
                {
                    for (var fileCount = 0; fileCount < cFiles; fileCount++)
                    {
                        var args = new ModelChangeEventArgs();
                        args.OldFileName = rgpszMkDocuments[fileCount];
                        args.ProjectObj  = VSHelpers.GetProject(pProject as IVsHierarchy);
                        if (args.ProjectObj == null)
                        {
                            continue;
                        }

                        hr = handler(this, args);
                    }
                }
            }
            return(hr);
        }
コード例 #2
0
 private void vsEventBroadcaster_OnFontChanged(object sender, EventArgs e)
 {
     if (_elementHost != null)
     {
         _elementHost.Font = VSHelpers.GetVSFont(_package);
     }
 }
コード例 #3
0
        internal NewInheritanceDialog(ConceptualEntityType baseType, IEnumerable <ConceptualEntityType> entityTypes)
        {
            InitializeComponent();
            // Set the default font to VS shell font.
            var vsFont = VSHelpers.GetVSFont(Services.ServiceProvider);

            if (vsFont != null)
            {
                Font = vsFont;
            }

            _entityTypes = new SortedSet <ConceptualEntityType>(new EFNameableItemComparer());

            foreach (var et in entityTypes)
            {
                _entityTypes.Add(et);
            }

            baseEntityComboBox.Items.AddRange(_entityTypes.ToArray());
            if (baseType != null)
            {
                baseEntityComboBox.SelectedItem = baseType;
            }
            CheckOkButtonEnabled();

            cancelButton.BackColor = SystemColors.Control;
            cancelButton.ForeColor = SystemColors.ControlText;
            okButton.BackColor     = SystemColors.Control;
            okButton.ForeColor     = SystemColors.ControlText;
        }
コード例 #4
0
 private void DispatchLoadToExtensions()
 {
     if (Hierarchy != null)
     {
         var projectItem = VsUtils.GetProjectItem(Hierarchy, ItemId);
         if (projectItem != null)
         {
             var    fileContents = VSHelpers.GetTextFromVsTextLines(VsBuffer);
             string newBufferContents;
             List <ExtensionError> extensionErrors;
             if (StandaloneXmlModelProvider.TryGetBufferViaExtensions(
                     projectItem, fileContents, out newBufferContents, out extensionErrors))
             {
                 if (VSHelpers.CheckOutFilesIfEditable(ServiceProvider, new[] { FileName }))
                 {
                     VsUtils.SetTextForVsTextLines(VsBuffer, newBufferContents);
                 }
                 else
                 {
                     ErrorListHelper.LogExtensionErrors(
                         new List <ExtensionError>
                     {
                         new ExtensionError(
                             string.Format(
                                 CultureInfo.CurrentCulture, Resources.ExtensionError_SourceControlLock,
                                 Path.GetFileName(FileName)),
                             ErrorCodes.ExtensionsError_BufferNotEditable,
                             ExtensionErrorSeverity.Error)
                     },
                         projectItem);
                 }
             }
         }
     }
 }
コード例 #5
0
    public void RunStarted(object automationObject,
                           Dictionary <string, string> replacementsDictionary,
                           WizardRunKind runKind,
                           object[] customParams)
    {
        using var _ = LogUserAction(UserTask.CreateFromTemplate, new TemplateInfo(runKind, replacementsDictionary));
        Assert(automationObject is DTE2, "Automation Object is wrong kind");
        if (automationObject is DTE2 dte)
        {
            var replacementDictionaryLookup = replacementsDictionary.TryGetValue("$type$", out var result);
            Assert(replacementDictionaryLookup, "Invalid replacements dictionary in template file");
            if (!replacementDictionaryLookup)
            {
                return;
            }

            bool isDotnet = StringComparer.OrdinalIgnoreCase.Compare(result, "dotnet") == 0;
            (bool success, string fileName) = EditorConfigFileGenerator.TryAddFileToSolution(isDotnet);
            Assert(success, "Unable to add the editorconfig file to the solution");

            if (success)
            {
                VSHelpers.OpenFile(fileName);
            }
        }
    }
コード例 #6
0
        // [TestMethod, HostType("VS IDE")] http://entityframework.codeplex.com/workitem/992
        public void RefactorRenameProperty()
        {
            RefactorRenameTest(
                "RefactorRenameProperty", (artifact, cpc, programDocData) =>
            {
                var authorType = ModelHelper.FindEntityType(artifact.ConceptualModel, "author");
                Assert.IsNotNull(authorType, "Could not find author type in the model");

                var idProperty = ModelHelper.FindProperty(authorType, "au_id");
                Assert.IsNotNull(idProperty, "Could not find au_id property in the model");

                RefactorEFObject.RefactorRenameElement(idProperty, "renamedId", false);

                var textLines = VSHelpers.GetVsTextLinesFromDocData(programDocData);
                Assert.IsNotNull(textLines, "Could not get VsTextLines for program DocData");

                Assert.AreEqual(
                    RefactorRenamePropertyResult, VSHelpers.GetTextFromVsTextLines(textLines), "Refactor results are incorrect");

                authorType = ModelHelper.FindEntityType(artifact.ConceptualModel, "author");
                Assert.IsNotNull(authorType, "Could not find author type in the model");

                var renamedIdProperty = ModelHelper.FindProperty(authorType, "renamedId");
                Assert.IsNotNull(renamedIdProperty, "Could not find renamedId property in the model");
            });
        }
コード例 #7
0
ファイル: VSXmlModel.cs プロジェクト: dotnet/ef6tools
        public override bool CanEditXmlModel()
        {
            string moniker = null;

            // first attempt to extract the file path of this XML Model
            try
            {
                if (Uri != null)
                {
                    moniker = Uri.LocalPath;
                }
            }
            catch (Exception e)
            {
                Debug.Fail("Could not parse the URI of this XML model because of the exception: " + e.Message);
                // note we get out of here quickly if this happens as we don't want to allow any cases where somehow documents.Count > 0
                return(false);
            }

            if (!String.IsNullOrWhiteSpace(moniker))
            {
                return(VSHelpers.CheckOutFilesIfEditable(_serviceProvider, new[] { moniker }));
            }

            return(false);
        }
コード例 #8
0
 private void OnInvokeAboutCommand(object sender, EventArgs args)
 {
     if (sender is AboutCommand command)
     {
         VSHelpers.ShowMessage(this, command.AboutMessage, command.AboutTitle);
     }
 }
コード例 #9
0
        // virtual for testing
        public virtual XmlDocument LoadConfig()
        {
            var configFilePath = GetConfigPath();

            if (configFilePath != null)
            {
                // attempt to construct the config xml from the doc data if it is available
                try
                {
                    var textLines = _vsHelpers.GetDocData(_serviceProvider, configFilePath) as IVsTextLines;
                    return(textLines != null
                        ? EdmUtils.SafeLoadXmlFromString(
                               VSHelpers.GetTextFromVsTextLines(textLines), preserveWhitespace : true)
                        : EdmUtils.SafeLoadXmlFromPath(configFilePath));
                }
                catch (XmlException e)
                {
                    VsUtils.LogStandardError(
                        String.Format(
                            CultureInfo.CurrentCulture,
                            Resources.VSUtils_ExceptionParsingXml,
                            configFilePath,
                            e.Message),
                        configFilePath,
                        e.LineNumber,
                        e.LinePosition);

                    throw;
                }
            }

            return(null);
        }
コード例 #10
0
        internal ComplexTypePickerDialog(ConceptualEntityModel cModel)
        {
            InitializeComponent();

            // Set the default font to VS shell font.
            var vsFont = VSHelpers.GetVSFont(Services.ServiceProvider);

            if (vsFont != null)
            {
                Font = vsFont;
            }

            Debug.Assert(cModel != null, "Please specify ConceptualEntityModel");
            if (cModel != null)
            {
                var complexTypes = new List <ComplexType>(cModel.ComplexTypes());
                complexTypes.Sort(EFElement.EFElementDisplayNameComparison);
                complexTypesListBox.Items.AddRange(complexTypes.ToArray());
                ViewUtils.DisplayHScrollOnListBoxIfNecessary(complexTypesListBox);
            }

            complexTypesListBox.SelectedIndexChanged += complexTypesListBox_SelectedIndexChanged;
            complexTypesListBox.MouseDoubleClick     += complexTypesListBox_MouseDoubleClick;
            okButton.Enabled = ComplexType != null;
        }
コード例 #11
0
        private void ProcessErrors(IList <EdmSchemaError> schemaErrors, Uri projectItemUri, EFArtifact artifact)
        {
            // since we will inevitably add *all* errors from the artifact set into the error list, we can easily
            // clear the entire error list here even though we just validate the CSDL.
            var errorList = ErrorListHelper.GetSingleDocErrorList(projectItemUri);

            if (errorList != null)
            {
                errorList.Clear();
            }

            if (artifact == null)
            {
                Debug.Fail("Where is the artifact? We should have created it at least through the temporary model manager");
                return;
            }

            // we have to remove both the RMV and SFG CSDL errors to prevent duplicates
            artifact.ArtifactSet.RemoveErrorsForArtifact(artifact, ErrorClass.Runtime_CSDL);

            // add all CSDL-based SFG errors to the artifact set
            if (schemaErrors.Count > 0)
            {
                foreach (var error in schemaErrors)
                {
                    // construct an ErrorInfo with correct line/column number and add it to the artifact set. Note that the CodeGen EdmSchemaError line
                    // refers to the line of the error inside the CSDL, so to get the line of the error in the edmx file we have to offset it by the line
                    // number where the conceptual model begins.
                    var edmxErrorLine = error.Line + artifact.ConceptualModel().GetLineNumber();
                    var efobject      = artifact.FindEFObjectForLineAndColumn(edmxErrorLine, error.Column);
                    var errorInfo     = new ErrorInfo(
                        GetErrorInfoSeverity(error), error.Message, efobject, error.ErrorCode, ErrorClass.Runtime_CSDL);
                    artifact.ArtifactSet.AddError(errorInfo);
                }
            }

            // get all the ErrorInfos for this artifact and add it to the error list
            var artifactSet = artifact.ArtifactSet;

            Debug.Assert(artifactSet != null, "Where is the artifact set for this artifact?");
            if (artifactSet != null)
            {
                var errors = artifactSet.GetArtifactOnlyErrors(artifact);
                if (errors.Count > 0)
                {
                    // resolve the hierarchy and item id for adding to the error list
                    var hierarchy = VSHelpers.GetVsHierarchy(ProjectItem.ContainingProject, Services.ServiceProvider);
                    var itemId    = VsUtils.GetProjectItemId(hierarchy, ProjectItem);

                    Debug.Assert(hierarchy != null, "Why isn't there a hierarchy associated with this project item?");
                    Debug.Assert(itemId != VSConstants.VSITEMID_NIL, "There should be an item ID associated with this project item");

                    if (hierarchy != null &&
                        itemId != VSConstants.VSITEMID_NIL)
                    {
                        ErrorListHelper.AddErrorInfosToErrorList(errors, hierarchy, itemId);
                    }
                }
            }
        }
コード例 #12
0
    public static (bool success, string fileName) TryAddFileToSolution(bool?isDotnet = null)
    {
        bool hasDotNetProjects = isDotnet ?? VSHelpers.IsDotnet();

        LogEvent(EventId.FoundDotnetProjects, hasDotNetProjects);
        var(isAtSolutionLevel, path, language, selectedItem) = VSHelpers.TryGetSelectedItemLanguageAndPath();
        LogEvent(EventId.FoundDotnetLanguage, language);
        Assert(path is not null && selectedItem is not null, "Unable to get the selected item");
        if (path is null || selectedItem is null)
        {
            return(false, null);
        }

        using var _ = LogCreateOperation(hasDotNetProjects, isAtSolutionLevel, language);

        var(success1, fileName) = TryCreateFile(path, hasDotNetProjects, isAtSolutionLevel, language);
        if (!success1)
        {
            Assert(success1, "Unable to create editorconfig file");
            return(false, null);
        }

        var projectItem = selectedItem.TryAddFileToHierarchy(fileName);

        if (projectItem is null)
        {
            Assert(projectItem is not null, "Unable to add editorconfig file to hierarchy");
            return(false, null);
        }

        return(true, fileName);
    }
コード例 #13
0
        internal NewEntityDialog(ConceptualEntityModel model)
        {
            Debug.Assert(model != null, "model should not be null");
            _model = model;

            InitializeComponent();
            // Set the default font to VS shell font.
            var vsFont = VSHelpers.GetVSFont(Services.ServiceProvider);

            if (vsFont != null)
            {
                Font = vsFont;
            }
            keyPropertyCheckBox.Checked = true;

            propertyTypeComboBox.Items.AddRange(ModelHelper.AllPrimitiveTypesSorted(_model.Artifact.SchemaVersion));
            propertyTypeComboBox.SelectedItem = ModelConstants.Int32PropertyType;

            baseTypeComboBox.Items.Add(Resources.NoneDisplayValueUsedForUX);
            baseTypeComboBox.Items.AddRange(model.EntityTypes().ToArray());
            if (baseTypeComboBox.Items.Count > 0)
            {
                baseTypeComboBox.SelectedIndex = 0;
            }

            entityNameTextBox.Text = ModelHelper.GetUniqueNameWithNumber(
                typeof(EntityType), model, Model.Resources.Model_DefaultEntityTypeName);
            propertyNameTextBox.Text = Model.Resources.Model_IdPropertyName;

            cancelButton.BackColor = SystemColors.Control;
            cancelButton.ForeColor = SystemColors.ControlText;
            okButton.BackColor     = SystemColors.Control;
            okButton.ForeColor     = SystemColors.ControlText;
        }
        public int OnBeforeUnloadProject(IVsHierarchy pRealHierarchy, IVsHierarchy pStubHierarchy)
        {
            var handler = BeforeCloseProject;

            if (handler != null)
            {
                var args = new ModelChangeEventArgs();
                try
                {
                    args.ProjectObj = VSHelpers.GetProject(pRealHierarchy);
                }
                catch (ArgumentException)
                {
                    return(VSConstants.E_NOTIMPL);
                }

                if (args.ProjectObj == null)
                {
                    return(VSConstants.E_NOTIMPL);
                }
                return(handler(this, args));
            }

            return(VSConstants.S_OK);
        }
コード例 #15
0
        internal DeleteStorageEntitySetsDialog(ICollection <StorageEntitySet> storageEntitySets)
        {
            InitializeComponent();

            // Set the default font to VS shell font.
            var vsFont = VSHelpers.GetVSFont(Services.ServiceProvider);

            if (vsFont != null)
            {
                Font = vsFont;
                DescriptionLabel.Font = vsFont;
            }

            // default result is to cancel
            DialogResult = DialogResult.Cancel;

            // display StorageEntitySets ordered by name
            Debug.Assert(null != storageEntitySets, "Constructor requires a Collection of StorageEntitySets");
            if (null != storageEntitySets)
            {
                var entitySets = new List <StorageEntitySet>(storageEntitySets);
                entitySets.Sort(EFElement.EFElementDisplayNameComparison);
                StorageEntitySetsListBox.Items.AddRange(entitySets.ToArray());
                ViewUtils.DisplayHScrollOnListBoxIfNecessary(StorageEntitySetsListBox);
            }
            YesButton.BackColor = SystemColors.Control;
            YesButton.ForeColor = SystemColors.ControlText;
            NoButton.BackColor  = SystemColors.Control;
            NoButton.ForeColor  = SystemColors.ControlText;
            DeleteStorageEntitySetsDialogCancelButton.BackColor = SystemColors.Control;
            DeleteStorageEntitySetsDialogCancelButton.ForeColor = SystemColors.ControlText;
        }
コード例 #16
0
        private static MicrosoftDataEntityDesignDocData GetDocData(EditingContext editingContext)
        {
            Debug.Assert(editingContext != null, "editingContext != null");

            var artifactService = editingContext.GetEFArtifactService();

            return((MicrosoftDataEntityDesignDocData)VSHelpers.GetDocData(ServiceProvider, artifactService.Artifact.Uri.LocalPath));
        }
コード例 #17
0
ファイル: VSArtifact.cs プロジェクト: rvegajr/entityframework
        // <summary>
        //     This will do analysis to determine if a document should be opened
        //     only in the XmlEditor.
        // </summary>
        internal override void DetermineIfArtifactIsDesignerSafe()
        {
            VsUtils.EnsureProvider(this);

            base.DetermineIfArtifactIsDesignerSafe();
            //
            // TODO:  we need to figure out how to deal with errors from the wizard.
            //        when we clear the error list below, we lose errors that we put into the error
            //        list when running the wizard.
            //

            //
            // Now update the VS error list with all of the errors we want to display, which are now in the EFArtifactSet.
            //
            var errorInfos = ArtifactSet.GetAllErrors();

            if (errorInfos.Count > 0)
            {
                var currentProject = VSHelpers.GetProjectForDocument(Uri.LocalPath, PackageManager.Package);
                if (currentProject != null)
                {
                    var hierarchy = VsUtils.GetVsHierarchy(currentProject, Services.ServiceProvider);
                    if (hierarchy != null)
                    {
                        var fileFinder = new VSFileFinder(Uri.LocalPath);
                        fileFinder.FindInProject(hierarchy);

                        Debug.Assert(fileFinder.MatchingFiles.Count <= 1, "Unexpected count of matching files in project");

                        // if the EDMX file is not part of the project.
                        if (fileFinder.MatchingFiles.Count == 0)
                        {
                            var docData = VSHelpers.GetDocData(PackageManager.Package, Uri.LocalPath) as IEntityDesignDocData;
                            ErrorListHelper.AddErrorInfosToErrorList(errorInfos, docData.Hierarchy, docData.ItemId);
                        }
                        else
                        {
                            foreach (var vsFileInfo in fileFinder.MatchingFiles)
                            {
                                if (vsFileInfo.Hierarchy == VsUtils.GetVsHierarchy(currentProject, Services.ServiceProvider))
                                {
                                    var errorList = ErrorListHelper.GetSingleDocErrorList(vsFileInfo.Hierarchy, vsFileInfo.ItemId);
                                    if (errorList != null)
                                    {
                                        errorList.Clear();
                                        ErrorListHelper.AddErrorInfosToErrorList(errorInfos, vsFileInfo.Hierarchy, vsFileInfo.ItemId);
                                    }
                                    else
                                    {
                                        Debug.Fail("errorList is null!");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #18
0
        private void ProcessDependentTTFiles()
        {
            // check if template processing was turned off via designer options
            var processTemplates = true;
            var artifact         = PackageManager.Package.ModelManager.GetArtifact(Utils.FileName2Uri(FileName));

            if (artifact != null)
            {
                DesignerInfo designerInfo;
                if (artifact.DesignerInfo().TryGetDesignerInfo(OptionsDesignerInfo.ElementName, out designerInfo))
                {
                    var optionsDesignerInfo = designerInfo as OptionsDesignerInfo;
                    Debug.Assert(
                        optionsDesignerInfo != null,
                        "DesignerInfo associated with " + OptionsDesignerInfo.ElementName + "must be of type OptionsDesignerInfo");
                    if (optionsDesignerInfo != null &&
                        optionsDesignerInfo.ProcessDependentTemplatesOnSave != null &&
                        optionsDesignerInfo.ProcessDependentTemplatesOnSave.ValueAttr != null)
                    {
                        bool.TryParse(optionsDesignerInfo.ProcessDependentTemplatesOnSave.ValueAttr.Value, out processTemplates);
                    }
                }
            }

            // if template processing was turned off, return
            if (processTemplates == false)
            {
                return;
            }

            // Find all .tt files in the project and invoke custom Tool
            var fileFinder = new VSFileFinder(".tt");

            fileFinder.FindInProject(Hierarchy);
            foreach (var vsFileInfo in fileFinder.MatchingFiles)
            {
                if (IsDependentTTFile(vsFileInfo))
                {
                    var pi = VsUtils.GetProjectItem(vsFileInfo.Hierarchy, vsFileInfo.ItemId);
                    Debug.Assert(pi != null, "Couldn't find project item, but file was discovered by VSFileFinder");
                    if (pi != null)
                    {
                        try
                        {
                            VsUtils.RunCustomTool(pi);
                        }
                        catch (Exception e)
                        {
                            // Swallow exceptions here, since we don't want a custom tool to interfere with the file save.
                            var errorMsg = String.Format(
                                CultureInfo.CurrentCulture, Resources.ErrorOccurredRunningCustomTool, vsFileInfo.Path, e.Message);
                            VsUtils.LogOutputWindowPaneMessage(VSHelpers.GetProject(Hierarchy), errorMsg);
                        }
                    }
                }
            }
        }
コード例 #19
0
        private void LoadDesignerInfoAndDescriptors(EditingContext editingContext, EFArtifact artifact)
        {
            if (artifact != null &&
                artifact.DesignerInfo() != null)
            {
                DesignerInfo connectionDesignerInfo = null;
                DesignerInfo optionsDesignerInfo    = null;

                var foundConnectionDesignerInfo = artifact.DesignerInfo()
                                                  .TryGetDesignerInfo(ConnectionDesignerInfo.ElementName, out connectionDesignerInfo);

                if (foundConnectionDesignerInfo)
                {
                    var connectionDesigner = connectionDesignerInfo as ConnectionDesignerInfo;
                    Debug.Assert(connectionDesigner != null, "DesignerInfo with element name 'Connection' must be a ConnectionDesignerInfo");

                    if (connectionDesigner != null)
                    {
                        // if the owner of the edmx file is a website, then we can
                        // only have one possible value (EmbedInOutputAssembly) for metadata artifact processing
                        // however the item template just adds CopyToOutputDirectory, so we need to fix it
                        var project = VSHelpers.GetProjectForDocument(artifact.Uri.LocalPath, PackageManager.Package);
                        if (project != null)
                        {
                            var appType = VsUtils.GetApplicationType(Services.ServiceProvider, project);
                            if (appType == VisualStudioProjectSystem.Website)
                            {
                                var mapDefault = ConnectionManager.GetMetadataArtifactProcessingDefault();
                                if (connectionDesigner.MetadataArtifactProcessingProperty != null &&
                                    connectionDesigner.MetadataArtifactProcessingProperty.ValueAttr.Value != mapDefault)
                                {
                                    var cpc = new CommandProcessorContext(
                                        editingContext, EfiTransactionOriginator.PropertyWindowOriginatorId,
                                        Resources.Tx_ChangeMetadataArtifactProcessing);
                                    var cmd =
                                        new UpdateDefaultableValueCommand <string>(
                                            connectionDesigner.MetadataArtifactProcessingProperty.ValueAttr, mapDefault);
                                    CommandProcessor.InvokeSingleCommand(cpc, cmd);
                                }
                            }
                        }

                        _EFConnectionDesignerInfoDescriptor = new EFConnectionDesignerInfoDescriptor();
                        _EFConnectionDesignerInfoDescriptor.Initialize(connectionDesigner, editingContext);
                    }
                }

                var foundOptionsDesignerInfo = artifact.DesignerInfo()
                                               .TryGetDesignerInfo(OptionsDesignerInfo.ElementName, out optionsDesignerInfo);

                if (foundOptionsDesignerInfo)
                {
                    _EFOptionsDesignerInfoDescriptor = new EFOptionsDesignerInfoDescriptor();
                    _EFOptionsDesignerInfoDescriptor.Initialize(optionsDesignerInfo as OptionsDesignerInfo, editingContext);
                }
            }
        }
コード例 #20
0
        public ServerProxy Configure(string eclipsePath)
        {
            Telemetry.Client.Get().TrackEvent("App.ConfigureEditor");

            // Remove itself from properties
            TextView.Properties.RemoveProperty(typeof(JavaUnconfiguredEditor));

            // Set path in registry
            Registry.SetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\JavaPkgSrv", "EclipseInstall", eclipsePath, RegistryValueKind.String);

            // Reboot editor
            var fileName         = VSHelpers.GetFileName(TextView);
            var eclipseWorkspace = EclipseWorkspace.FromFilePath(fileName);
            var javaPkgServer    = JavaPkgServerManager.GetProxy(eclipseWorkspace);
            var javaEditor       = new JavaEditor(SubjectBuffers, TextView, javaPkgServer, eclipseWorkspace);

            Telemetry.Client.Get().TrackEvent("App.EditorOpenConfigured");

            javaPkgServer.Send(javaEditor, ProtocolHandlers.CreateOpenTypeRootRequest(fileName)).ContinueWith((System.Threading.Tasks.Task <Protocol.Response> responseTask) =>
            {
                var openTypeResponse = responseTask.Result;

                if (openTypeResponse.responseType == Protocol.Response.ResponseType.OpenTypeRoot &&
                    openTypeResponse.openTypeRootResponse != null)
                {
                    javaEditor.TypeRootIdentifier = openTypeResponse.openTypeRootResponse.typeRootIdentifier;
                }
            });

            TextView.Properties.RemoveProperty(typeof(ServerProxy));
            TextView.Properties.AddProperty(typeof(ServerProxy), javaPkgServer);

            TextView.Properties.RemoveProperty(typeof(JavaEditor));
            TextView.Properties.AddProperty(typeof(JavaEditor), javaEditor);

            foreach (var buffer in SubjectBuffers)
            {
                buffer.Properties.RemoveProperty(typeof(JavaUnconfiguredEditor));
                buffer.Properties.RemoveProperty(typeof(ServerProxy));
                buffer.Properties.AddProperty(typeof(ServerProxy), javaPkgServer);
                buffer.Properties.RemoveProperty(typeof(JavaEditor));
                buffer.Properties.AddProperty(typeof(JavaEditor), javaEditor);

                JavaOutline outline = null;
                if (buffer.Properties.TryGetProperty <JavaOutline>(typeof(JavaOutline), out outline))
                {
                    outline.JavaEditor = javaEditor;
                }

                JavaSquiggles squiggles = null;
                if (buffer.Properties.TryGetProperty <JavaSquiggles>(typeof(JavaSquiggles), out squiggles))
                {
                    squiggles.JavaEditor = javaEditor;
                }
            }
            return(javaPkgServer);
        }
コード例 #21
0
        private void SetFont()
        {
            // Set the default font to VS shell font.
            var vsFont = VSHelpers.GetVSFont(ServiceProvider);

            if (vsFont != null)
            {
                Font = vsFont;
            }
        }
コード例 #22
0
        private void RefactorRenameTest(string projectName, Action <EntityDesignArtifact, CommandProcessorContext, object> test)
        {
            var modelEdmxFilePath = Path.Combine(TestContext.DeploymentDirectory, @"TestData\Model\v3\PubSimple.edmx");
            var dte             = VsIdeTestHostContext.Dte;
            var serviceProvider = VsIdeTestHostContext.ServiceProvider;

            UITestRunner.Execute(
                () =>
            {
                EntityDesignArtifact entityDesignArtifact = null;
                try
                {
                    var project = dte.CreateProject(
                        TestContext.TestRunDirectory,
                        projectName,
                        DteExtensions.ProjectKind.Executable,
                        DteExtensions.ProjectLanguage.CSharp);

                    var projectItem = dte.AddExistingItem(new FileInfo(modelEdmxFilePath).FullName, project);
                    dte.OpenFile(projectItem.FileNames[0]);
                    entityDesignArtifact =
                        (EntityDesignArtifact) new EFArtifactHelper(EFArtifactHelper.GetEntityDesignModelManager(serviceProvider))
                        .GetNewOrExistingArtifact(TestUtils.FileName2Uri(projectItem.FileNames[0]));

                    var editingContext =
                        _package.DocumentFrameMgr.EditingContextManager.GetNewOrExistingContext(entityDesignArtifact.Uri);
                    var cpc = new CommandProcessorContext(
                        editingContext, "DiagramTest" + projectName, "DiagramTestTxn" + projectName, entityDesignArtifact);

                    var programDocData = VSHelpers.GetDocData(
                        serviceProvider, Path.Combine(Path.GetDirectoryName(project.FullName), "Program.cs"));
                    Debug.Assert(programDocData != null, "Could not get DocData for program file");

                    var textLines = VSHelpers.GetVsTextLinesFromDocData(programDocData);
                    Debug.Assert(textLines != null, "Could not get VsTextLines for program DocData");

                    VsUtils.SetTextForVsTextLines(textLines, string.Format(PubSimpleProgramText, projectName));
                    test(entityDesignArtifact, cpc, programDocData);
                }
                catch (Exception ex)
                {
                    TestContext.WriteLine(ex.ToString());
                    throw;
                }
                finally
                {
                    if (entityDesignArtifact != null)
                    {
                        entityDesignArtifact.Dispose();
                    }

                    dte.CloseSolution(false);
                }
            });
        }
コード例 #23
0
        private void OnInvokedDynamicItem(object sender, EventArgs e)
        {
            DynamicCommand invokedCommand     = (DynamicCommand)sender;
            var            commandConfig      = this.configParser.Commands.Find(c => c.Title.Equals(invokedCommand.Text));
            var            currentProjectPath = VSHelpers.GetCurrentProjectPath();

            var extentionPath = Path.GetDirectoryName(this.GetType().Assembly.Location);
            var exePath       = Path.Combine(extentionPath, Constants.CLIFolderName, Constants.CLIName);
            var fileInfo      = new FileInfo(exePath);

            if (!fileInfo.Exists)
            {
                string message = "File 'sf.exe' does not exist!";
                VSHelpers.ShowErrorMessage(this, message, commandConfig.Title);
                return;
            }

            var args = String.Format("{0}", commandConfig.Name);

            // get arguments
            var dialog = new InputDialog(commandConfig);

            if (dialog.ShowDialog() == true)
            {
                for (int i = 0; i < dialog.ResponseText.Count; i++)
                {
                    var input = dialog.ResponseText[i];
                    if (string.IsNullOrEmpty(input) || input.IndexOfAny(Path.GetInvalidFileNameChars()) > 0)
                    {
                        string message = string.Format("Invalid argument: {0}!", commandConfig.Args[i]);
                        VSHelpers.ShowErrorMessage(this, message, commandConfig.Title);
                        return;
                    }

                    // response is argument, else - response is option
                    if (i < commandConfig.Args.Count)
                    {
                        args = String.Format("{0} \"{1}\"", args, input);
                    }
                    else
                    {
                        var optionIndex = i - commandConfig.Args.Count;
                        args = String.Format("{0} {1} \"{2}\"", args, commandConfig.Options[optionIndex].Name, input);
                    }
                }

                args = String.Format("{0} -r \"{1}\"", args, currentProjectPath);

                var process = new Process();
                process.StartInfo.FileName         = fileInfo.Name;
                process.StartInfo.WorkingDirectory = fileInfo.DirectoryName;
                process.StartInfo.Arguments        = args;
                process.Start();
            }
        }
        private void SetFonts()
        {
            var shellFont = VSHelpers.GetVSFont(this);

            // get the font used for dialogs and tool windows
            if (shellFont != null)
            {
                _containerControl.Font = shellFont;
                _treeControl.Font      = shellFont;
            }
        }
コード例 #25
0
 public void StartListening()
 {
     _observable = _eventAggregator.GetEvent <ConnectionChangedEvent>().Subscribe(ConnectionChanged);
     _themeObs   = Observable
                   .FromEvent <ThemeChangedEventHandler, ThemeChangedEventArgs>(handler => VSColorTheme.ThemeChanged += handler, handler => VSColorTheme.ThemeChanged -= handler)
                   .Subscribe(args =>
     {
         CurrentTheme = ConvertToTheme(VSHelpers.DetectTheme());
         _eventAggregator.Publish(new ThemeChangedEvent(CurrentTheme));
     });
 }
コード例 #26
0
        public WizardPageBase(ModelBuilderWizardForm wizard, IServiceProvider serviceProvider)
            : base(wizard)
        {
            _wizard = wizard;
            // Set the default font to VS shell font.
            var vsFont = VSHelpers.GetVSFont(serviceProvider);

            if (vsFont != null)
            {
                Font = vsFont;
            }
        }
コード例 #27
0
        public CustomZoomDialog()
        {
            InitializeComponent();

            // Set the default font to VS shell font.
            var vsFont = VSHelpers.GetVSFont(Services.ServiceProvider);

            if (vsFont != null)
            {
                Font = vsFont;
            }
        }
コード例 #28
0
        internal Project GetProjectForArtifactSet()
        {
            Project project      = null;
            string  documentPath = null;
            var     artifact     = this.GetEntityDesignArtifact();

            if (artifact != null)
            {
                documentPath = artifact.Uri.LocalPath;
                project      = VSHelpers.GetProjectForDocument(documentPath, PackageManager.Package);
            }
            return(project);
        }
コード例 #29
0
        internal bool IsReadOnlyCodeGenerationStrategy()
        {
            if (TypedEFElement.Artifact.SchemaVersion < EntityFrameworkVersion.Version3 || UseLegacyProvider)
            {
                return(false);
            }

            var originalPath = TypedEFElement.Artifact.Uri.LocalPath;
            var project      = VSHelpers.GetProjectForDocument(originalPath, Services.ServiceProvider);
            var entityFrameworkAssemblyVersion = VsUtils.GetInstalledEntityFrameworkAssemblyVersion(project);

            return(entityFrameworkAssemblyVersion != null && entityFrameworkAssemblyVersion >= RuntimeVersion.Version6);
        }
コード例 #30
0
    protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
    {
        using var _ = LogUserAction(UserTask.CreateFromRightClickMenu);
        await Package.JoinableTaskFactory.SwitchToMainThreadAsync(Package.DisposalToken);

        var(success, fileName) = EditorConfigFileGenerator.TryAddFileToSolution();
        Assert(success, "Unable to add the editorconfig file to the solution");

        if (success)
        {
            VSHelpers.OpenFile(fileName);
        }
    }
コード例 #31
0
 internal static void RemoveSyncedProject(VSHelpers.Projects.ProjectBase project)
 {
     mSyncedProjects.Remove(project);
 }
コード例 #32
0
 internal static void AddSyncedProject(VSHelpers.Projects.ProjectBase vsp)
 {
     mSyncedProjects.Add(vsp);
     PluginManager.ReactToSyncedProjectLoad(vsp);
 }