Exemple #1
0
        public void OnStatusChangeInDiagram(object sender, EventArgs e)
        {
            DynamicStatusMenuCommand command = sender as DynamicStatusMenuCommand;

            command.Visible = command.Enabled = !this.IsCurrentDiagramEmpty() &&
                                                this.IsDiagramSelected();
        }
        /// <summary>
        /// Provide the menu commands that this command set handles
        /// </summary>
        /// <param name="commandList"></param>
        protected override void GetMenuCommands(IList commandList)
        {
            // Get the standard commands
            base.GetMenuCommands(commandList);

            // Add View Model Explorer command in the top-level menu.
            // Use a ContextBoundMenuCommand for this, because availability of the command is
            // based on whether or not the command context of our editor is active.
            MenuCommand menuCommand = new CommandContextBoundMenuCommand(this.ServiceProvider,
                                                                         new EventHandler(OnMenuViewModelExplorer),
                                                                         new CommandID(GuidList.guidFeatureModelLanguageCmdSet, (int)PackageCommandIdList.cmdIdViewExplorer),
                                                                         GuidList.guidEditorFactory);

            commandList.Add(menuCommand);

            MenuCommand Model2XMLMenuCommand = new CommandContextBoundMenuCommand(this.ServiceProvider, new EventHandler(OnCheckModelValidity), new CommandID(GuidList.guidFeatureModelLanguageCmdSet, (int)CustomCommandIdList.cmdIdGenerateXmlFromModel), GuidList.guidEditorFactory);

            commandList.Add(Model2XMLMenuCommand);



            // Add validation menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusValidate), new EventHandler(OnMenuValidate), CommonModelingCommands.ValidateModel);
            commandList.Add(menuCommand);
        }
Exemple #3
0
        public void OnStatusChangeInViewGeneratedCode(object sender, EventArgs e)
        {
            DynamicStatusMenuCommand command = sender as DynamicStatusMenuCommand;

            command.Visible = command.Enabled = this.IsSingleSelection() &&
                                                !this.IsDiagramSelected() &&
                                                IsValidSelectedContainer();
        }
Exemple #4
0
        private static DynamicStatusMenuCommand CreateDynamicStatusMenuCommand(Action <MenuCommand> onStatusAction,
                                                                               Action <MenuCommand> onMenuAction, CommandID commandID)
        {
            var menuCommand = new DynamicStatusMenuCommand(
                (sender, eventArgs) => onStatusAction(sender as MenuCommand),
                (sender, eventArgs) => onMenuAction(sender as MenuCommand),
                commandID);

            return(menuCommand);
        }
Exemple #5
0
        internal static DynamicStatusMenuCommand CreateCommand <T>(object owner) where T : MenuCommandBase, new()
        {
            T command = new T();

            command.SetOwner(owner);
            DynamicStatusMenuCommand dynamicStatusMenuCommand = CreateDynamicStatusMenuCommand(
                command.QueryStatus, command.ExecCommand,
                new CommandID(new Guid(GetMenuGroupFromOwner(owner)), command.CommandId));

            return(dynamicStatusMenuCommand);
        }
Exemple #6
0
        protected override IList <MenuCommand> GetMenuCommands()
        {
            // Get the list of generated commands.
            IList <MenuCommand> commands = base.GetMenuCommands();

            // CollapseAll command:
            DynamicStatusMenuCommand collapseAllContextMenuCommand =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusCollapseAllContextMenuCommand),
                    new EventHandler(OnMenuCollapseAllContextMenuCommand),
                    new CommandID(guidDiagramToolsMenuCmdSet, cmdidCollapseAllContextMenuCommand));

            commands.Add(collapseAllContextMenuCommand);

            // collapseAll command:
            DynamicStatusMenuCommand expandAllContextMenuCommand =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusExpandAllContextMenuCommand),
                    new EventHandler(OnMenuExpandAllContextMenuCommand),
                    new CommandID(guidDiagramToolsMenuCmdSet, cmdidExpandAllContextMenuCommand));

            commands.Add(expandAllContextMenuCommand);

            // collapseAll command:
            DynamicStatusMenuCommand alignSymbolsContextMenuCommand =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusAlignSymbolsContextMenuCommand),
                    new EventHandler(OnMenuAlignSymbolsContextMenuCommand),
                    new CommandID(guidDiagramToolsMenuCmdSet, cmdidAlignSymbolsContextMenuCommand));

            commands.Add(alignSymbolsContextMenuCommand);

            // FitSymbolsToContent command:
            DynamicStatusMenuCommand fitSymbolsToContentContextMenuCommand =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusFitSymbolsToContentContextMenuCommand),
                    new EventHandler(OnMenuFitSymbolsToContentContextMenuCommand),
                    new CommandID(guidDiagramToolsMenuCmdSet, cmdidFitSymbolsToContentContextMenuCommand));

            commands.Add(fitSymbolsToContentContextMenuCommand);

            // FitSymbolsToDefault command:
            DynamicStatusMenuCommand fitSymbolsToDefaultContextMenuCommand =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusFitSymbolsToDefaultContextMenuCommand),
                    new EventHandler(OnMenuFitSymbolsToDefaultContextMenuCommand),
                    new CommandID(guidDiagramToolsMenuCmdSet, cmdidFitSymbolsToDefaultContextMenuCommand));

            commands.Add(fitSymbolsToDefaultContextMenuCommand);
            return(commands);
        }
Exemple #7
0
        protected override IList <MenuCommand> GetMenuCommands()
        {
            // Get the list of generated commands.
            IList <MenuCommand> commands = base.GetMenuCommands();
            // Add a custom command:
            DynamicStatusMenuCommand genAPrologCommand =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusMyContextMenuCommand),
                    new EventHandler(OnMenuMyContextMenuCommand),
                    new CommandID(guidGenPrologCmdSet, cmdidGenAPrologCommand));

            commands.Add(genAPrologCommand);
            // Add more commands here.
            return(commands);
        }
        protected override IList <MenuCommand> GetMenuCommands()
        {
            var commands = base.GetMenuCommands();

            var cmdGenerateEntities = new DynamicStatusMenuCommand(
                OnPopupMenuDisplayActionGenerateEntities,
                OnPopupMenuClickGenerateEntities,
                new CommandID(cmdGenerateEntitiesGuid, cmdGenerateEntitiesId));
            var cmdViewSimpleOrmMappingRules = new DynamicStatusMenuCommand(
                OnPopUpMenuDisplayActionMappingRule,
                OnPopUpMenuClickMappingRule,
                new CommandID(cmdViewSimpleOrmMappingRulesGuid, cmdViewSimpleOrmMappingRulesId));

            commands.Add(cmdGenerateEntities);
            commands.Add(cmdViewSimpleOrmMappingRules);

            return(commands);
        }
        protected override IList<MenuCommand> GetMenuCommands()
        {
            var commands = base.GetMenuCommands();

            var cmdGenerateEntities = new DynamicStatusMenuCommand(
                OnPopupMenuDisplayActionGenerateEntities,
                OnPopupMenuClickGenerateEntities,
                new CommandID(cmdGenerateEntitiesGuid, cmdGenerateEntitiesId));
            var cmdViewSimpleOrmMappingRules = new DynamicStatusMenuCommand(
                OnPopUpMenuDisplayActionMappingRule,
                OnPopUpMenuClickMappingRule,
                new CommandID(cmdViewSimpleOrmMappingRulesGuid, cmdViewSimpleOrmMappingRulesId));

            commands.Add(cmdGenerateEntities);
            commands.Add(cmdViewSimpleOrmMappingRules);

            return commands;
        }
        /// <summary>
        /// Adds command handlers for commands that appear in the context menu.  Base implementation
        /// will only add command handlers if a handler is not already registered, to allow derived
        /// classes to override handling of a particular command.  For this reason, derived classes
        /// should add commands first before calling the base class.
        /// </summary>
        /// <param name="menuCommandService">IMenuCommandService to which commands should be added.</param>
        public override void AddCommandHandlers(IMenuCommandService menuCommandService)
        {
            DynamicStatusMenuCommand gotoCodeCommand =
                new DynamicStatusMenuCommand(OnStatusGoToCode, OnMenuGoToCode, new CommandID(EFModelCommandSet.guidMenuExplorerCmdSet, EFModelCommandSet.cmdidGoToCode));

            menuCommandService.AddCommand(gotoCodeCommand);

            DynamicStatusMenuCommand expandCommand =
                new DynamicStatusMenuCommand(OnStatusExpandAll, OnMenuExpandAll, new CommandID(EFModelCommandSet.guidMenuExplorerCmdSet, EFModelCommandSet.cmdidExpandAll));

            menuCommandService.AddCommand(expandCommand);

            DynamicStatusMenuCommand collapseCommand =
                new DynamicStatusMenuCommand(OnStatusCollapseAll, OnMenuCollapseAll, new CommandID(EFModelCommandSet.guidMenuExplorerCmdSet, EFModelCommandSet.cmdidCollapseAll));

            menuCommandService.AddCommand(collapseCommand);

            base.AddCommandHandlers(menuCommandService);
        }
Exemple #11
0
        public void OnStatusChangeInGenerateCode(object sender, EventArgs e)
        {
            DynamicStatusMenuCommand command = sender as DynamicStatusMenuCommand;
            bool activateCommand             = false;

            if (!this.IsCurrentDiagramEmpty() &&
                this.IsSingleSelection())
            {
                try
                {
                    activateCommand = ModelCollector.HasValidArtifactsAndRoles(this.ServiceProvider);
                }
                catch (Exception error)
                {
                    Logger.Write(error);
                }
            }

            command.Visible = command.Enabled = activateCommand;
        }
        protected override IList <MenuCommand> GetMenuCommands()
        {
            IList <MenuCommand> commands = base.GetMenuCommands();
            Guid guidCmdSet = new Guid(Constants.HostDesignerCommandSetId);

            DynamicStatusMenuCommand cmdAddServiceReference =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusChangeAddServiceReference),
                    new EventHandler(OnMenuChangeAddServiceReference),
                    new CommandID(guidCmdSet, cmdAddServiceReferenceId));

            commands.Add(cmdAddServiceReference);

            commandSetUtility =
                new DslCommandSetUtility <HostDesignerDiagram>(
                    this.ServiceProvider,
                    Resources.AddNewHostDesignerTitle,
                    "Web Service Software Factory 2010 Host Model");
            return(commandSetUtility.GetMenuCommands(commands, guidCmdSet));
        }
        protected override IList<MenuCommand> GetMenuCommands()
        {
            IList<MenuCommand> commands = base.GetMenuCommands();
            Guid guidCmdSet = new Guid(Constants.HostDesignerCommandSetId);

            DynamicStatusMenuCommand cmdAddServiceReference =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusChangeAddServiceReference),
                    new EventHandler(OnMenuChangeAddServiceReference),
                    new CommandID(guidCmdSet, cmdAddServiceReferenceId));

            commands.Add(cmdAddServiceReference);

            commandSetUtility =
                new DslCommandSetUtility<HostDesignerDiagram>(
                    this.ServiceProvider,
                    Resources.AddNewHostDesignerTitle,
                    "Web Service Software Factory 2010 Host Model");
            return commandSetUtility.GetMenuCommands(commands, guidCmdSet);
        }
Exemple #14
0
        /// <summary>
        /// Get the set of commands for this CQRS/DSL tool
        /// </summary>
        protected override IList <MenuCommand> GetMenuCommands()
        {
            // Get the standard base commands
            global::System.Collections.Generic.IList <global::System.ComponentModel.Design.MenuCommand> commands = base.GetMenuCommands();

            // Add custom commands
            global::System.ComponentModel.Design.MenuCommand menuCommand = null;

            // Add handler for "Show/Hide tooltips" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusShowHideModelTips),
                                                       new EventHandler(OnMenuShowHideModelTips),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidShowHideModelTipsContextMenuCommand));
            commands.Add(menuCommand);

            // Add handler for "Increment event version" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusIncrementEventVersion),
                                                       new EventHandler(OnMenuIncrementEventVersion),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidIncrementEventVersionContextMenuCommand));
            commands.Add(menuCommand);

            // Add handler for "Expand / CollapseAggregate" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusExpandCollapseAggregate),
                                                       new EventHandler(OnMenuExpandCollapseAggregate),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidExpandCollapseAggregateContextMenuCommand));
            commands.Add(menuCommand);

            // Add handler for "Generate code" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusGenerateCQRSModelCode),
                                                       new EventHandler(OnMenuGenerateCQRSModelCode),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidGenerateCQRSModelCode));
            commands.Add(menuCommand);

            // Add handler for "Generate documentation" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusGenerateCQRSModelDocumentation),
                                                       new EventHandler(OnMenuGenerateCQRSModelDocumentation),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidGenerateCQRSModelDocumentation));
            commands.Add(menuCommand);

            // return the resulting list
            return(commands);
        }
Exemple #15
0
        protected override IList <MenuCommand> GetMenuCommands()
        {
            IList <MenuCommand> commands = base.GetMenuCommands();
            Guid guidCmdSet = new Guid(Constants.DataContractDslCommandSetId);

            DynamicStatusMenuCommand cmdOrderAllDataMembers =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusChangeOrderAllDataMembers),
                    new EventHandler(OnMenuChangeOrderAllDataMembers),
                    new CommandID(guidCmdSet, cmdOrderAllDataMembersId));

            commands.Add(cmdOrderAllDataMembers);

            commandSetUtility =
                new DslCommandSetUtility <DataContractDiagram>(
                    this.ServiceProvider,
                    Properties.Resources.AddNewDataContractTitle,
                    "Web Service Software Factory 2010 DC Model");

            return(commandSetUtility.GetMenuCommands(commands, guidCmdSet));
        }
        protected override IList<MenuCommand> GetMenuCommands()
        {
            IList<MenuCommand> commands = base.GetMenuCommands();
            Guid guidCmdSet = new Guid(Constants.DataContractDslCommandSetId);

            DynamicStatusMenuCommand cmdOrderAllDataMembers =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusChangeOrderAllDataMembers),
                    new EventHandler(OnMenuChangeOrderAllDataMembers),
                    new CommandID(guidCmdSet, cmdOrderAllDataMembersId));

            commands.Add(cmdOrderAllDataMembers);

            commandSetUtility =
                new DslCommandSetUtility<DataContractDiagram>(
                    this.ServiceProvider,
                    Properties.Resources.AddNewDataContractTitle,
                    "Web Service Software Factory 2010 DC Model");

            return commandSetUtility.GetMenuCommands(commands, guidCmdSet);
        }
        /// <summary>
        /// Provide the menu commands that this command set handles.
        /// </summary>
        /// <returns>A list of commands.</returns>
        protected override IList <MenuCommand> GetMenuCommands()
        {
            // Execute base
            IList <MenuCommand> commands = base.GetMenuCommands();

            // Add the MovePropertyUp menu command
            DynamicStatusMenuCommand cmdMovePropertyUp =
                new DynamicStatusMenuCommand(
                    new EventHandler(this.OnPopUpMenuDisplayAction),
                    new EventHandler(this.OnPopUpMenuClick),
                    new CommandID(
                        this.cmdMovePropertyUpGUID,
                        cmdMovePropertyUpID));

            commands.Add(cmdMovePropertyUp);

            // Add the MovePropertyDown menu command
            DynamicStatusMenuCommand cmdMovePropertyDown =
                new DynamicStatusMenuCommand(
                    new EventHandler(this.OnPopUpMenuDisplayAction),
                    new EventHandler(this.OnPopUpMenuClick),
                    new CommandID(
                        this.cmdMovePropertyDownGUID,
                        cmdMovePropertyDownID));

            commands.Add(cmdMovePropertyDown);

            // Add the ImportExternalEnum menu command
            DynamicStatusMenuCommand cmdImportExternalEnum =
                new DynamicStatusMenuCommand(
                    new EventHandler(this.OnPopUpMenuDisplayAction),
                    new EventHandler(this.OnPopUpMenuClick),
                    new CommandID(
                        this.cmdImportExternalEnumGUID,
                        cmdImportExternalEnumID));

            commands.Add(cmdImportExternalEnum);

            return(commands);
        }
Exemple #18
0
        public IList <MenuCommand> GetMenuCommands(IList <MenuCommand> commands, Guid guidCmdSet)
        {
            DynamicStatusMenuCommand cmdAddNewModelCommand =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusChangeInAddNewItem),
                    new EventHandler(OnMenuChangeAddNewItem),
                    new CommandID(guidCmdSet, cmdAddNewItem));

            DynamicStatusMenuCommand cmdAutoLayout =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusChangeInDiagram),
                    new EventHandler(OnMenuChangeAutoLayout),
                    new CommandID(guidCmdSet, cmdAutoLayoutId));

            DynamicStatusMenuCommand cmdGenerateCode =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusChangeInGenerateCode),
                    new EventHandler(OnMenuChangeGenerateCode),
                    new CommandID(guidCmdSet, cmdGenerateCodeId));

            DynamicStatusMenuCommand cmdGenerateAllCode =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusChangeInGenerateCode),
                    new EventHandler(OnMenuChangeGenerateAllCode),
                    new CommandID(guidCmdSet, cmdGenerateAllCodeId));

            DynamicStatusMenuCommand cmdViewGeneratedCode =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnStatusChangeInViewGeneratedCode),
                    new EventHandler(OnMenuChangeViewGeneratedCode),
                    new CommandID(guidCmdSet, cmdViewGeneratedCodeId));

            commands.Add(cmdAddNewModelCommand);
            commands.Add(cmdAutoLayout);
            commands.Add(cmdGenerateCode);
            commands.Add(cmdGenerateAllCode);
            commands.Add(cmdViewGeneratedCode);

            return(commands);
        }
Exemple #19
0
        /// <summary>
        /// Adds commands to this diagram and returns them.
        /// </summary>
        /// <returns></returns>
        protected override IList <MenuCommand> GetMenuCommands()
        {
            IList <MenuCommand>      commands = base.GetMenuCommands();
            DynamicStatusMenuCommand cmdGoToParentFeatureModel =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnGoToParentFeatureModelDisplayAction),
                    new EventHandler(OnGoToParentFeatureModelClick),
                    new CommandID(cmdGoToParentFeatureModelGuid, cmdGoToParentFeatureModelID));

            commands.Add(cmdGoToParentFeatureModel);

            DynamicStatusMenuCommand cmdGoToDefinitionFeatureModel =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnGoToDefinitionFeatureModelDisplayAction),
                    new EventHandler(OnGoToDefinitionFeatureModelClick),
                    new CommandID(cmdGoToDefinitionFeatureModelGuid, cmdGoToDefinitionFeatureModelID));

            commands.Add(cmdGoToDefinitionFeatureModel);

            DynamicStatusMenuCommand cmdExportDiagram =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnExportDiagramDisplayAction),
                    new EventHandler(OnExportDiagramClick),
                    new CommandID(cmdExportDiagramGuid, cmdExportDiagramID));

            commands.Add(cmdExportDiagram);

            DynamicStatusMenuCommand cmdViewConfeaturator =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnViewConfeaturatorDisplayAction),
                    new EventHandler(OnViewConfeaturatorClick),
                    new CommandID(cmdViewConfeaturatorGuid, cmdViewConfeaturatorID));

            commands.Add(cmdViewConfeaturator);

            return(commands);
        }
        protected override void OnBeforeShowContextMenu()
        {
            // Creating commands for adding scalar and complex properties to complex types (one for each complex type from the model).
            // Since the scalar types can change dependent on the schemaVersion and since complex types can be added or deleted
            // we need to compute these commands each time a context menu is requested

            // only need to do this if selected is ExplorerComplexType
            var selectedElement = CurrentExplorerInfo._explorerFrame.GetSelectedExplorerEFElement();
            if (selectedElement is ExplorerComplexType)
            {
                var service = EditingContext.GetEFArtifactService();
                Debug.Assert(service != null && service.Artifact != null, "service and service.Artifact must both be non-null");
                if (service != null
                    && service.Artifact != null)
                {
                    // Creating commands for adding scalar properties to complex types (one for each primitive type)
                    var i = 0;
                    foreach (var type in ModelHelper.AllPrimitiveTypesSorted(service.Artifact.SchemaVersion))
                    {
                        var cmdId = new CommandID(
                            PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddScalarPropertyBase + i);
                        var cmd = MenuCommandService.FindCommand(cmdId);
                        if (cmd == null)
                        {
                            cmd = new DynamicStatusMenuCommand(OnStatusAddComplexTypeProperty, OnMenuAddComplexTypeProperty, cmdId);
                            cmd.Properties[PackageConstants.guidEscherCmdSet] = type;
                            MenuCommandService.AddCommand(cmd);
                        }
                        else
                        {
                            cmd.Properties[PackageConstants.guidEscherCmdSet] = type;
                        }
                        i++;
                    }

                    // set up commands for complex types
                    var conceptualModel = service.Artifact.ConceptualModel();
                    Debug.Assert(conceptualModel != null, "service.Artifact.ConceptualModel() should not be null");
                    if (conceptualModel != null)
                    {
                        var complexTypes = new List<ComplexType>(conceptualModel.ComplexTypes());
                        complexTypes.Sort(EFElement.EFElementDisplayNameComparison);

                        i = 0;
                        foreach (var complexType in complexTypes)
                        {
                            // don't add an item for a ComplexType that is same as currently selected one
                            if (selectedElement.ModelItem == complexType)
                            {
                                continue;
                            }

                            // if we find an old command with the same cmdId remove it and replace
                            // with the new one to force VS to refresh the text
                            var cmdId = new CommandID(
                                PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddComplexPropertyBase + i);
                            var cmd = MenuCommandService.FindCommand(cmdId);
                            if (cmd != null)
                            {
                                MenuCommandService.RemoveCommand(cmd);
                            }
                            cmd = new DynamicStatusMenuCommand(OnStatusAddComplexTypeProperty, OnMenuAddComplexTypeProperty, cmdId);
                            cmd.Properties[PackageConstants.guidEscherCmdSet] = complexType;
                            MenuCommandService.AddCommand(cmd);

                            i++;
                            if (i >= AddComplexPropertyCommandMaxCount)
                            {
                                // break after adding 10 ComplexTypes
                                break;
                            }
                        }

                        // if some of the complex types were removed, we need to remove unnecessary commands
                        var cmd2 =
                            MenuCommandService.FindCommand(
                                new CommandID(PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddComplexPropertyBase + i));
                        while (i < AddComplexPropertyCommandMaxCount
                               && cmd2 != null)
                        {
                            MenuCommandService.RemoveCommand(cmd2);
                            i++;
                            cmd2 =
                                MenuCommandService.FindCommand(
                                    new CommandID(
                                        PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddComplexPropertyBase + i));
                        }
                    }
                }
            }
        }
Exemple #21
0
        /// <summary>
        /// Provide the menu commands that this command set handles
        /// </summary>
        /// <returns></returns>
        protected override IList <MenuCommand> GetMenuCommands()
        {
            IList <MenuCommand> commandList = base.GetMenuCommands();

            // Ajout d'une ligne dans le menu show other windows pour afficher le repository
            MenuCommand menuCommand = new CommandContextBoundMenuCommand(this.ServiceProvider,
                                                                         new EventHandler(OnShowRepositoryToolWindow),
                                                                         new CommandID(new global::System.Guid(Constants.CandleCommandSetId), cmdIDShowRepositoryToolWindow),
                                                                         typeof(CandleEditorFactory).GUID);

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusShowModel),
                new EventHandler(OnShowModel),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDShowModel));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusShowStrategies),
                new EventHandler(OnShowStrategies),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDShowStrategies));
            commandList.Add(menuCommand);


            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusImplementAll),
                new EventHandler(OnImplementAll),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDImplementAll));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusImplementAll),
                new EventHandler(OnImplementAll),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDImplementAllG));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusImplementAll),
                new EventHandler(OnImplementAll),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDImplementAllT));
            commandList.Add(menuCommand);


            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusImplement),
                new EventHandler(OnImplement),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDImplement));

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusImportModels),
                new EventHandler(OnImportModels),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDImportModels));

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusImportInterfaces),
                new EventHandler(OnImportInterfaces),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDImportInterfaces));

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusArrangeShapes),
                new EventHandler(OnArrangeShapes),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDArrangeShape));

            commandList.Add(menuCommand);

            //menuCommand = new DynamicStatusMenuCommand(
            //    new EventHandler(OnStatusShowDataLayer),
            //     new EventHandler(OnShowDataLayer),
            //      new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDShowDataLayer));

            //commandList.Add(menuCommand);

            //menuCommand = new DynamicStatusMenuCommand(
            //    new EventHandler( OnStatusPropertyToAssociation ),
            //    new EventHandler( OnPropertyToAssociation ),
            //    new CommandID( new Guid(Constants.CandleCommandSetId), cmdIDPropertyToAssociation ) );

            //commandList.Add( menuCommand );

            //menuCommand = new DynamicStatusMenuCommand(
            //    new EventHandler( OnStatusAssociationToProperty ),
            //    new EventHandler( OnAssociationToProperty ),
            //    new CommandID( new Guid(Constants.CandleCommandSetId), cmdIDAssociationToProperty ) );

            //commandList.Add( menuCommand );

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusExportDiagramAsBitmap),
                new EventHandler(OnExportDiagramAsBitmap),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDExportDiagramAsBitmap));

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusPublishModel),
                new EventHandler(OnPublishModel),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDPublishModel));

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusPublishModel),
                new EventHandler(OnPublishModel),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDPublishModelG));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusPublishModel),
                new EventHandler(OnPublishModel),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDPublishModelT));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusPublishAsTemplate),
                new EventHandler(OnPublishAsTemplate),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDPublishAsTemplate));

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusImportAssemblies),
                new EventHandler(OnImportAssemblies),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDImportAssemblies));

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusShowDependencies),
                new EventHandler(OnShowDependencies),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDShowDependencies));

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusModelAffectation),
                new EventHandler(OnModelAffectation),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDModelAffectation));

            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusManageArtifacts),
                new EventHandler(OnManageArtifacts),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDManageArtifacts));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusManageConfiguration),
                new EventHandler(OnManageConfiguration),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDManageConfigurations));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusImportWSDL),
                new EventHandler(OnImportWSDL),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDImportWSDL));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusCopy),
                new EventHandler(OnCopy),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDCopy));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusPaste),
                new EventHandler(OnPaste),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDPaste));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusGetLastVersion),
                new EventHandler(OnGetLastVersion),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDGetLastVersion));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusShowProperties),
                new EventHandler(OnShowProperties),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDShowProperties));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusImportXmi),
                new EventHandler(OnImportXmi),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDImportXmi));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusPropagateOperations),
                new EventHandler(OnPropagateOperations),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDPropagatesOperations));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusShowDocumentation),
                new EventHandler(OnShowDocumentation),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDShowDocumentation));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusShowRelationShips),
                new EventHandler(OnShowRelationShips),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDShowRelationShips));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusZoomIn),
                new EventHandler(OnZoomIn),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDZoomIn));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(
                new EventHandler(OnStatusZoomOut),
                new EventHandler(OnZoomOut),
                new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDZoomOut));
            commandList.Add(menuCommand);

            menuCommand = new DynamicStatusMenuCommand(OnStatusUpdateDotNetAssembly,
                                                       OnUpdateDotNetAssembly,
                                                       new CommandID(new Guid(Constants.CandleCommandSetId), cmdIDUpdateAssembly));
            commandList.Add(menuCommand);
            //// Copy/Paste
            //AddPasteCommand(commandList);
            //AddCopyCommand(commandList);

            return(commandList);
        }
Exemple #22
0
        protected override IList <MenuCommand> GetMenuCommands()
        {
            IList <MenuCommand> commands = base.GetMenuCommands();

            DynamicStatusMenuCommand findCommand =
                new DynamicStatusMenuCommand(OnStatusFind, OnMenuFind, new CommandID(guidEFDiagramMenuCmdSet, cmdidFind));

            commands.Add(findCommand);

            DynamicStatusMenuCommand addAttributesCommand =
                new DynamicStatusMenuCommand(OnStatusAddProperties, OnMenuAddProperties, new CommandID(guidEFDiagramMenuCmdSet, cmdidAddCodeProperties));

            commands.Add(addAttributesCommand);

            DynamicStatusMenuCommand addValuesCommand =
                new DynamicStatusMenuCommand(OnStatusAddValues, OnMenuAddValues, new CommandID(guidEFDiagramMenuCmdSet, cmdidAddCodeValues));

            commands.Add(addValuesCommand);

            DynamicStatusMenuCommand layoutDiagramCommand =
                new DynamicStatusMenuCommand(OnStatusLayoutDiagram, OnMenuLayoutDiagram, new CommandID(guidEFDiagramMenuCmdSet, cmdidLayoutDiagram));

            commands.Add(layoutDiagramCommand);

            DynamicStatusMenuCommand hideShapeCommand =
                new DynamicStatusMenuCommand(OnStatusHideShape, OnMenuHideShape, new CommandID(guidEFDiagramMenuCmdSet, cmdidHideShape));

            commands.Add(hideShapeCommand);

            DynamicStatusMenuCommand showShapeCommand =
                new DynamicStatusMenuCommand(OnStatusShowShape, OnMenuShowShape, new CommandID(guidEFDiagramMenuCmdSet, cmdidShowShape));

            commands.Add(showShapeCommand);

            DynamicStatusMenuCommand generateCodeCommand =
                new DynamicStatusMenuCommand(OnStatusGenerateCode, OnMenuGenerateCode, new CommandID(guidEFDiagramMenuCmdSet, cmdidGenerateCode));

            commands.Add(generateCodeCommand);

            DynamicStatusMenuCommand saveAsImageCommand =
                new DynamicStatusMenuCommand(OnStatusSaveAsImage, OnMenuSaveAsImage, new CommandID(guidEFDiagramMenuCmdSet, cmdidSaveAsImage));

            commands.Add(saveAsImageCommand);

            DynamicStatusMenuCommand loadNuGetCommand =
                new DynamicStatusMenuCommand(OnStatusLoadNuGet, OnMenuLoadNuGet, new CommandID(guidEFDiagramMenuCmdSet, cmdidLoadNuGet));

            commands.Add(loadNuGetCommand);

            DynamicStatusMenuCommand selectClassesCommand =
                new DynamicStatusMenuCommand(OnStatusSelectClasses, OnMenuSelectClasses, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectClasses));

            commands.Add(selectClassesCommand);

            DynamicStatusMenuCommand selectEnumsCommand =
                new DynamicStatusMenuCommand(OnStatusSelectEnums, OnMenuSelectEnums, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectEnums));

            commands.Add(selectEnumsCommand);

            DynamicStatusMenuCommand selectAssocsCommand =
                new DynamicStatusMenuCommand(OnStatusSelectAssocs, OnMenuSelectAssocs, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectAssocs));

            commands.Add(selectAssocsCommand);

            DynamicStatusMenuCommand selectUnidirCommand =
                new DynamicStatusMenuCommand(OnStatusSelectUnidir, OnMenuSelectUnidir, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectUnidir));

            commands.Add(selectUnidirCommand);

            DynamicStatusMenuCommand selectBidirCommand =
                new DynamicStatusMenuCommand(OnStatusSelectBidir, OnMenuSelectBidir, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectBidir));

            commands.Add(selectBidirCommand);

            DynamicStatusMenuCommand expandSelectedCommand =
                new DynamicStatusMenuCommand(OnStatusExpandSelected, OnMenuExpandSelected, new CommandID(guidEFDiagramMenuCmdSet, cmdidExpandSelected));

            commands.Add(expandSelectedCommand);

            DynamicStatusMenuCommand collapseSelectedCommand =
                new DynamicStatusMenuCommand(OnStatusCollapseSelected, OnMenuCollapseSelected, new CommandID(guidEFDiagramMenuCmdSet, cmdidCollapseSelected));

            commands.Add(collapseSelectedCommand);

            DynamicStatusMenuCommand mergeAssociationsCommand =
                new DynamicStatusMenuCommand(OnStatusMergeAssociations, OnMenuMergeAssociations, new CommandID(guidEFDiagramMenuCmdSet, cmdidMergeAssociations));

            commands.Add(mergeAssociationsCommand);

            DynamicStatusMenuCommand splitAssociationCommand =
                new DynamicStatusMenuCommand(OnStatusSplitAssociation, OnMenuSplitAssociation, new CommandID(guidEFDiagramMenuCmdSet, cmdidSplitAssociation));

            commands.Add(splitAssociationCommand);

            // Additional commands go here.
            return(commands);
        }
Exemple #23
0
        public void OnStatusChangeInAddNewItem(object sender, EventArgs e)
        {
            DynamicStatusMenuCommand command = sender as DynamicStatusMenuCommand;

            command.Visible = command.Enabled = DteLanguage.IsCSharpOrVbProject(this.ServiceProvider, true);
        }
Exemple #24
0
        protected override IList <MenuCommand> GetMenuCommands()
        {
            IList <MenuCommand> commands = base.GetMenuCommands();

            DynamicStatusMenuCommand findCommand =
                new DynamicStatusMenuCommand(OnStatusFind, OnMenuFind, new CommandID(guidEFDiagramMenuCmdSet, cmdidFind));

            commands.Add(findCommand);

            DynamicStatusMenuCommand addAttributesCommand =
                new DynamicStatusMenuCommand(OnStatusAddProperties, OnMenuAddProperties, new CommandID(guidEFDiagramMenuCmdSet, cmdidAddCodeProperties));

            commands.Add(addAttributesCommand);

            DynamicStatusMenuCommand layoutDiagramCommand =
                new DynamicStatusMenuCommand(OnStatusLayoutDiagram, OnMenuLayoutDiagram, new CommandID(guidEFDiagramMenuCmdSet, cmdidLayoutDiagram));

            commands.Add(layoutDiagramCommand);

            DynamicStatusMenuCommand hideShapeCommand =
                new DynamicStatusMenuCommand(OnStatusHideShape, OnMenuHideShape, new CommandID(guidEFDiagramMenuCmdSet, cmdidHideShape));

            commands.Add(hideShapeCommand);

            DynamicStatusMenuCommand showShapeCommand =
                new DynamicStatusMenuCommand(OnStatusShowShape, OnMenuShowShape, new CommandID(guidEFDiagramMenuCmdSet, cmdidShowShape));

            commands.Add(showShapeCommand);

            DynamicStatusMenuCommand generateCodeCommand =
                new DynamicStatusMenuCommand(OnStatusGenerateCode, OnMenuGenerateCode, new CommandID(guidEFDiagramMenuCmdSet, cmdidGenerateCode));

            commands.Add(generateCodeCommand);

            DynamicStatusMenuCommand saveAsImageCommand =
                new DynamicStatusMenuCommand(OnStatusSaveAsImage, OnMenuSaveAsImage, new CommandID(guidEFDiagramMenuCmdSet, cmdidSaveAsImage));

            commands.Add(saveAsImageCommand);

            DynamicStatusMenuCommand selectClassesCommand =
                new DynamicStatusMenuCommand(OnStatusSelectClasses, OnMenuSelectClasses, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectClasses));

            commands.Add(selectClassesCommand);

            DynamicStatusMenuCommand selectEnumsCommand =
                new DynamicStatusMenuCommand(OnStatusSelectEnums, OnMenuSelectEnums, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectEnums));

            commands.Add(selectEnumsCommand);

            DynamicStatusMenuCommand selectAssocsCommand =
                new DynamicStatusMenuCommand(OnStatusSelectAssocs, OnMenuSelectAssocs, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectAssocs));

            commands.Add(selectAssocsCommand);

            DynamicStatusMenuCommand selectUnidirCommand =
                new DynamicStatusMenuCommand(OnStatusSelectUnidir, OnMenuSelectUnidir, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectUnidir));

            commands.Add(selectUnidirCommand);

            DynamicStatusMenuCommand selectBidirCommand =
                new DynamicStatusMenuCommand(OnStatusSelectBidir, OnMenuSelectBidir, new CommandID(guidEFDiagramMenuCmdSet, cmdidSelectBidir));

            commands.Add(selectBidirCommand);

            // Add more commands here.
            return(commands);
        }
        /// <summary>
        /// Adds commands to this diagram and returns them.
        /// </summary>
        /// <returns></returns>
        protected override IList<MenuCommand> GetMenuCommands()
        {
            IList<MenuCommand> commands = base.GetMenuCommands();
            DynamicStatusMenuCommand cmdGoToParentFeatureModel =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnGoToParentFeatureModelDisplayAction),
                    new EventHandler(OnGoToParentFeatureModelClick),
                    new CommandID(cmdGoToParentFeatureModelGuid, cmdGoToParentFeatureModelID));
            commands.Add(cmdGoToParentFeatureModel);

            DynamicStatusMenuCommand cmdGoToDefinitionFeatureModel =
               new DynamicStatusMenuCommand(
                   new EventHandler(OnGoToDefinitionFeatureModelDisplayAction),
                   new EventHandler(OnGoToDefinitionFeatureModelClick),
                   new CommandID(cmdGoToDefinitionFeatureModelGuid, cmdGoToDefinitionFeatureModelID));
            commands.Add(cmdGoToDefinitionFeatureModel);

            DynamicStatusMenuCommand cmdExportDiagram =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnExportDiagramDisplayAction),
                    new EventHandler(OnExportDiagramClick),
                    new CommandID(cmdExportDiagramGuid, cmdExportDiagramID));
            commands.Add(cmdExportDiagram);

            DynamicStatusMenuCommand cmdViewConfeaturator =
                new DynamicStatusMenuCommand(
                    new EventHandler(OnViewConfeaturatorDisplayAction),
                    new EventHandler(OnViewConfeaturatorClick),
                    new CommandID(cmdViewConfeaturatorGuid, cmdViewConfeaturatorID));
            commands.Add(cmdViewConfeaturator);

            return commands;
        }
Exemple #26
0
        /// <summary>
        /// Get the set of commands for this CQRS/DSL tool
        /// </summary>
        protected override IList <MenuCommand> GetMenuCommands()
        {
            // Get the standard base commands
            global::System.Collections.Generic.IList <global::System.ComponentModel.Design.MenuCommand> commands = base.GetMenuCommands();

            // Add custom commands
            global::System.ComponentModel.Design.MenuCommand menuCommand = null;

            // Add handler for "Show/Hide tooltips" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusShowHideModelTips),
                                                       new EventHandler(OnMenuShowHideModelTips),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidShowHideModelTipsContextMenuCommand));
            commands.Add(menuCommand);

            // Add handler for "Increment event version" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusIncrementEventVersion),
                                                       new EventHandler(OnMenuIncrementEventVersion),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidIncrementEventVersionContextMenuCommand));
            commands.Add(menuCommand);

            // Add handler for "Expand / CollapseAggregate" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusExpandCollapseAggregate),
                                                       new EventHandler(OnMenuExpandCollapseAggregate),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidExpandCollapseAggregateContextMenuCommand));
            commands.Add(menuCommand);

            // Add handler for the "Model properties" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusModelProperties),
                                                       new EventHandler(OnMenuModelProperties),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidModelSettings));
            commands.Add(menuCommand);

            // Add handler for "Generate code" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusGenerateCQRSModelCode),
                                                       new EventHandler(OnMenuGenerateCQRSModelCode),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidGenerateCQRSModelCode));
            commands.Add(menuCommand);

            // Add handler for "Generate documentation" menu command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusGenerateCQRSModelDocumentation),
                                                       new EventHandler(OnMenuGenerateCQRSModelDocumentation),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidGenerateCQRSModelDocumentation));
            commands.Add(menuCommand);

            // Add handler for the "Data" top level menu
            menuCommand = new MenuCommand(
                new EventHandler(OnMenuDataTopLevelMenuCommand),
                new CommandID(guidCustomDiagramMenuCmdSet, cmdidDataTopLevelMenuCommand));
            commands.Add(menuCommand);

            // Add handler for "AddAggregateInstance" Menu Command
            menuCommand = new DynamicStatusMenuCommand(new EventHandler(OnStatusAddAggregateInstanceMenuCommand),
                                                       new EventHandler(OnMenuAddAggregateInstanceMenuCommand),
                                                       new CommandID(guidCustomDiagramMenuCmdSet, cmdidDataAddAggregateInstanceMenuCommand));
            commands.Add(menuCommand);

            // Add handler for "AddEventToAggregateInstance" Menu Command
            // Add handler for "ShowEventsForAggregateInstance" Menu Command
            // Add handler for "RunProjectionForAggregateInstance" Menu Command
            // Add handler for "RunClassifierForAggregateInstance" Menu Command
            // Add handler for "ShowIdentifierGroupMembers" Menu Command
            // Add handler for "RunQueryForIdentifierGroup" Menu Command
            // Add handler for "RunCommandForIdentifierGroup" Menu Command

            // add handler for the "DataImport" menu command
            menuCommand = new MenuCommand(new EventHandler(OnDataImportMenuCommand),
                                          new CommandID(guidCustomDiagramMenuCmdSet, cmdidDataImportpMenuCommand));
            commands.Add(menuCommand);

            // add handler for the DataExport command


            // return the resulting list
            return(commands);
        }
Exemple #27
0
        protected override void OnBeforeShowContextMenu()
        {
            // Creating commands for adding scalar and complex properties to complex types (one for each complex type from the model).
            // Since the scalar types can change dependent on the schemaVersion and since complex types can be added or deleted
            // we need to compute these commands each time a context menu is requested

            // only need to do this if selected is ExplorerComplexType
            var selectedElement = CurrentExplorerInfo._explorerFrame.GetSelectedExplorerEFElement();

            if (selectedElement is ExplorerComplexType)
            {
                var service = EditingContext.GetEFArtifactService();
                Debug.Assert(service != null && service.Artifact != null, "service and service.Artifact must both be non-null");
                if (service != null &&
                    service.Artifact != null)
                {
                    // Creating commands for adding scalar properties to complex types (one for each primitive type)
                    var i = 0;
                    foreach (var type in ModelHelper.AllPrimitiveTypesSorted(service.Artifact.SchemaVersion))
                    {
                        var cmdId = new CommandID(
                            PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddScalarPropertyBase + i);
                        var cmd = MenuCommandService.FindCommand(cmdId);
                        if (cmd == null)
                        {
                            cmd = new DynamicStatusMenuCommand(OnStatusAddComplexTypeProperty, OnMenuAddComplexTypeProperty, cmdId);
                            cmd.Properties[PackageConstants.guidEscherCmdSet] = type;
                            MenuCommandService.AddCommand(cmd);
                        }
                        else
                        {
                            cmd.Properties[PackageConstants.guidEscherCmdSet] = type;
                        }
                        i++;
                    }

                    // set up commands for complex types
                    var conceptualModel = service.Artifact.ConceptualModel();
                    Debug.Assert(conceptualModel != null, "service.Artifact.ConceptualModel() should not be null");
                    if (conceptualModel != null)
                    {
                        var complexTypes = new List <ComplexType>(conceptualModel.ComplexTypes());
                        complexTypes.Sort(EFElement.EFElementDisplayNameComparison);

                        i = 0;
                        foreach (var complexType in complexTypes)
                        {
                            // don't add an item for a ComplexType that is same as currently selected one
                            if (selectedElement.ModelItem == complexType)
                            {
                                continue;
                            }

                            // if we find an old command with the same cmdId remove it and replace
                            // with the new one to force VS to refresh the text
                            var cmdId = new CommandID(
                                PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddComplexPropertyBase + i);
                            var cmd = MenuCommandService.FindCommand(cmdId);
                            if (cmd != null)
                            {
                                MenuCommandService.RemoveCommand(cmd);
                            }
                            cmd = new DynamicStatusMenuCommand(OnStatusAddComplexTypeProperty, OnMenuAddComplexTypeProperty, cmdId);
                            cmd.Properties[PackageConstants.guidEscherCmdSet] = complexType;
                            MenuCommandService.AddCommand(cmd);

                            i++;
                            if (i >= AddComplexPropertyCommandMaxCount)
                            {
                                // break after adding 10 ComplexTypes
                                break;
                            }
                        }

                        // if some of the complex types were removed, we need to remove unnecessary commands
                        var cmd2 =
                            MenuCommandService.FindCommand(
                                new CommandID(PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddComplexPropertyBase + i));
                        while (i < AddComplexPropertyCommandMaxCount &&
                               cmd2 != null)
                        {
                            MenuCommandService.RemoveCommand(cmd2);
                            i++;
                            cmd2 =
                                MenuCommandService.FindCommand(
                                    new CommandID(
                                        PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddComplexPropertyBase + i));
                        }
                    }
                }
            }
        }