Example #1
0
        /// <summary>
        /// Create a new trigger.
        /// </summary>
        public override void Execute()
        {
            Project project = App.Instance.SalesForceApp.CurrentProject;

            if (project != null)
            {
                NewTriggerWindow dlg = new NewTriggerWindow();
                dlg.Title = "Create Trigger";

                using (App.Wait("Getting Objects"))
                    dlg.TriggerObjects = project.Client.Data.DescribeGlobal();

                if (App.ShowDialog(dlg))
                {
                    if (String.IsNullOrWhiteSpace(dlg.TriggerName))
                    {
                        throw new Exception("A trigger name is required.");
                    }
                    if (dlg.TriggerObject == null)
                    {
                        throw new Exception("You must select an object for the trigger.");
                    }
                    if (dlg.TriggerEvents == TriggerEvents.None)
                    {
                        throw new Exception("You must select at least one trigger event.");
                    }

                    using (App.Wait("Creating Trigger"))
                    {
                        SourceFile file = project.Client.Meta.CreateTrigger(
                            dlg.TriggerName,
                            (dlg.TriggerObject as SObjectTypePartial).Name,
                            dlg.TriggerEvents,
                            EditorSettings.ApexSettings.CreateHeader());

                        ApexTriggerFolderNode folder = App.Instance.Navigation.GetNode <ApexTriggerFolderNode>();
                        if (folder != null)
                        {
                            folder.AddApexTrigger(file);
                        }

                        App.Instance.Content.OpenDocument(new TriggerEditorDocument(project, file));
                    }
                }
            }
        }
        /// <summary>
        /// Toggle the checkout system on/off.
        /// </summary>
        /// <param name="sender">Object that raised the event.</param>
        /// <param name="e">Event arguments.</param>
        private void ToggleCheckOutSystem(object sender, EventArgs e)
        {
            Project project = App.Instance.SalesForceApp.CurrentProject;

            if (project != null)
            {
                string text = project.Client.Checkout.IsEnabled() ?
                              "Disabling the check out system will delete a previously created custom object and impact all Walli users of the organization.  Are you sure you want to proceed?" :
                              "Enabling the check out system requires a new custom object be created and will impact all Walli users of the organization.  Are you sure you want to proceed?";

                if (App.MessageUser(text,
                                    "Check out system",
                                    System.Windows.MessageBoxImage.Warning,
                                    new string[] { "Yes", "No" }) == "Yes")
                {
                    using (App.Wait("Updating check out system"))
                    {
                        project.Client.Checkout.Enable(!project.Client.Checkout.IsEnabled());
                        App.Instance.UpdateWorkspaces();

                        // refresh open folders
                        IFunction refreshFunction   = App.Instance.GetFunction <RefreshFolderFunction>();
                        INode     currentActiveNode = App.Instance.Navigation.ActiveNode;

                        ApexClassFolderNode classFolderNode = App.Instance.Navigation.GetNode <ApexClassFolderNode>();
                        if (classFolderNode != null)
                        {
                            App.Instance.Navigation.ActiveNode = classFolderNode;
                            refreshFunction.Execute();
                        }

                        ApexTriggerFolderNode triggerFolderNode = App.Instance.Navigation.GetNode <ApexTriggerFolderNode>();
                        if (triggerFolderNode != null)
                        {
                            App.Instance.Navigation.ActiveNode = triggerFolderNode;
                            refreshFunction.Execute();
                        }

                        ApexPageFolderNode pageFolderNode = App.Instance.Navigation.GetNode <ApexPageFolderNode>();
                        if (pageFolderNode != null)
                        {
                            App.Instance.Navigation.ActiveNode = pageFolderNode;
                            refreshFunction.Execute();
                        }

                        ApexComponentFolderNode componentFolderNode = App.Instance.Navigation.GetNode <ApexComponentFolderNode>();
                        if (componentFolderNode != null)
                        {
                            App.Instance.Navigation.ActiveNode = componentFolderNode;
                            refreshFunction.Execute();
                        }

                        App.Instance.Navigation.ActiveNode = currentActiveNode;
                    }

                    App.MessageUser("The check out system has been changed.  All users that currently have an open project in Walli for this organization will need to close those projects and then reopen them to see the change take effect.",
                                    "Check out system changed",
                                    System.Windows.MessageBoxImage.Information,
                                    new string[] { "OK" });
                }

                SourceControlSetupWindow dlg = sender as SourceControlSetupWindow;
                if (dlg != null)
                {
                    dlg.IsCheckoutEnabled = project.Client.Checkout.IsEnabled();
                }
            }
        }