SetCompletionAction() private method

private SetCompletionAction ( CompletionAction action ) : void
action CompletionAction
return void
Example #1
0
        void OnUnaddedFilesGUI()
        {
            AssetList toAdd = new AssetList();
            string    files = "";

            foreach (Asset a in assetList)
            {
                if (!a.IsState(Asset.States.OutOfSync) && !a.IsState(Asset.States.Synced) && !a.IsState(Asset.States.AddedLocal))
                {
                    files += a.prettyPath + "\n";
                    toAdd.Add(a);
                }
            }

            GUILayout.Label("Files to add", EditorStyles.boldLabel);
            GUILayout.Label("Some additional files need to be added:");
            GUI.enabled = false;
            GUILayout.TextArea(files);
            GUI.enabled = true;
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Add files"))
            {
                taskAdd = Provider.Add(toAdd, false);
                taskAdd.SetCompletionAction(CompletionAction.OnAddedChangeWindow);
            }

            if (GUILayout.Button("Abort"))
            {
                ResetAndClose();
            }

            GUILayout.EndHorizontal();
        }
        // Handle drag events from the list
        void OnDrop(ChangeSet targetItem)
        {
            AssetList list     = pendingList.SelectedAssets;
            Task      moveTask = Provider.ChangeSetMove(list, targetItem);

            moveTask.SetCompletionAction(CompletionAction.UpdatePendingWindow);
        }
Example #3
0
        private void OnDrop(ChangeSet targetItem)
        {
            AssetList selectedAssets = this.pendingList.SelectedAssets;
            Task      task           = Provider.ChangeSetMove(selectedAssets, targetItem);

            task.SetCompletionAction(CompletionAction.UpdatePendingWindow);
        }
        // called to update the status
        void UpdateWindow()
        {
            if (!Provider.isActive)
            {
                pendingList.Clear();
                Repaint();
                return;
            }

            if (TimeElapsed() > refreshInterval)
            {
                if (Provider.onlineState == OnlineState.Online)
                {
                    Task changesTask = Provider.ChangeSets();
                    changesTask.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow);

                    Task incomingTask = Provider.Incoming();
                    incomingTask.SetCompletionAction(CompletionAction.OnIncomingPendingWindow);
                }

                lastRefresh = DateTime.Now;
            }
            else
            {
                scheduleRefresh = true;
            }
        }
Example #5
0
        private void UpdateWindow()
        {
            if (!Provider.isActive)
            {
                this.pendingList.Clear();
                base.Repaint();
                return;
            }
            Task task = Provider.ChangeSets();

            task.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow);
            Task task2 = Provider.Incoming();

            task2.SetCompletionAction(CompletionAction.OnIncomingPendingWindow);
        }
Example #6
0
 private void UpdateWindow()
 {
     if (!Provider.isActive)
     {
         this.pendingList.Clear();
         Provider.UpdateSettings();
         base.Repaint();
     }
     else if (Provider.onlineState == OnlineState.Online)
     {
         Task task = Provider.ChangeSets();
         task.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow);
         Task task2 = Provider.Incoming();
         task2.SetCompletionAction(CompletionAction.OnIncomingPendingWindow);
     }
 }
Example #7
0
 private void OnExpandIncoming(ChangeSet change, ListItem item)
 {
     if (Provider.isActive)
     {
         Task task = Provider.IncomingChangeSetAssets(change);
         task.userIdentifier = item.Identifier;
         task.SetCompletionAction(CompletionAction.OnChangeContentsPendingWindow);
         if (!item.HasChildren)
         {
             Asset    asset    = new Asset("Updating...");
             ListItem listItem = this.incomingList.Add(item, asset.prettyPath, asset);
             listItem.Dummy = true;
             this.incomingList.Refresh(false);
             base.Repaint();
         }
     }
 }
Example #8
0
        void Save(bool submit)
        {
            if (description.Trim() == c_defaultDescription)
            {
                Debug.LogError("Version control: Please enter a valid change description");
                return;
            }

            UnityEditor.AssetDatabase.SaveAssets();

            // Submit the change list. Last parameter is "save only" so invert the submit flag

            taskSubmit         = Provider.Submit(changeSet, assetList, description, !submit);
            submitResultCode   = kSubmitRunningResultCode;
            submitErrorMessage = null;
            taskSubmit.SetCompletionAction(CompletionAction.OnSubmittedChangeWindow); // TODO: make it CompletionAction.OnChangeSetsPendingWindow
        }
Example #9
0
        // called to update the status
        void UpdateWindow()
        {
            if (!Provider.isActive)
            {
                pendingList.Clear();
                Repaint();
                return;
            }

            if (Provider.onlineState == OnlineState.Online)
            {
                Task changesTask = Provider.ChangeSets();
                changesTask.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow);

                Task incomingTask = Provider.Incoming();
                incomingTask.SetCompletionAction(CompletionAction.OnIncomingPendingWindow);
            }
        }
        // called to update the status
        void UpdateWindow()
        {
            if (!Provider.isActive)
            {
                pendingList.Clear();
                Provider.UpdateSettings(); // Try to resend the settings if we by chance has become online again
                Repaint();
                return;
            }

            if (Provider.onlineState == OnlineState.Online)
            {
                Task changesTask = Provider.ChangeSets();
                changesTask.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow);

                Task incomingTask = Provider.Incoming();
                incomingTask.SetCompletionAction(CompletionAction.OnIncomingPendingWindow);
            }
        }
        void OnExpandIncoming(ChangeSet change, ListItem item)
        {
            if (!Provider.isActive)
            {
                return;
            }

            Task task = Provider.IncomingChangeSetAssets(change);

            task.userIdentifier = item.Identifier;
            task.SetCompletionAction(CompletionAction.OnChangeContentsPendingWindow);
            if (!item.HasChildren)
            {
                Asset    asset      = new Asset("Updating...");
                ListItem changeItem = incomingList.Add(item, asset.prettyPath, asset);
                changeItem.Dummy = true;
                incomingList.Refresh(false);  //true here would cause recursion
                Repaint();
            }
        }
Example #12
0
        private void OnExpand(ChangeSet change, ListItem item)
        {
            if (!Provider.isActive)
            {
                return;
            }
            Task task = Provider.ChangeSetStatus(change);

            task.userIdentifier = item.Identifier;
            task.SetCompletionAction(CompletionAction.OnChangeContentsPendingWindow);
            if (item.HasChildren)
            {
                return;
            }
            Asset asset = new Asset("Updating...");

            this.pendingList.Add(item, asset.prettyPath, asset).Dummy = true;
            this.pendingList.Refresh(false);
            this.Repaint();
        }
        // Editor window GUI paint
        void OnGUI()
        {
            InitStyles();

            if (!s_DidReload)
            {
                s_DidReload = true;
                UpdateWindow();
            }

            CreateResources();

            Event e             = Event.current;
            float toolBarHeight = EditorStyles.toolbar.fixedHeight;
            bool  refresh       = false;

            GUILayout.BeginArea(new Rect(0, 0, position.width, toolBarHeight));


            GUILayout.BeginHorizontal(EditorStyles.toolbar);

            EditorGUI.BeginChangeCheck();

            int incomingChangesetCount = incomingList.Root == null ? 0 : incomingList.Root.ChildCount;

            m_ShowIncoming = !GUILayout.Toggle(!m_ShowIncoming, "Outgoing", EditorStyles.toolbarButton);

            GUIContent cont = GUIContent.Temp("Incoming" + (incomingChangesetCount == 0 ? "" : " (" + incomingChangesetCount.ToString() + ")"));

            m_ShowIncoming = GUILayout.Toggle(m_ShowIncoming, cont, EditorStyles.toolbarButton);

            if (EditorGUI.EndChangeCheck())
            {
                refresh = true;
            }

            GUILayout.FlexibleSpace();

            // Global context custom commands goes here
            using (new EditorGUI.DisabledScope(Provider.activeTask != null))
            {
                foreach (CustomCommand c in Provider.customCommands)
                {
                    if (c.context == CommandContext.Global && GUILayout.Button(c.label, EditorStyles.toolbarButton))
                    {
                        c.StartTask();
                    }
                }
            }

            bool showDeleteEmptyChangesetsButton =
                Mathf.FloorToInt(position.width - s_ToolbarButtonsWidth - s_SettingsButtonWidth - s_DeleteChangesetsButtonWidth) > 0 &&
                HasEmptyPendingChangesets();

            if (showDeleteEmptyChangesetsButton && GUILayout.Button("Delete Empty Changesets", EditorStyles.toolbarButton))
            {
                DeleteEmptyPendingChangesets();
            }

            bool showSettingsButton = Mathf.FloorToInt(position.width - s_ToolbarButtonsWidth - s_SettingsButtonWidth) > 0;

            if (showSettingsButton && GUILayout.Button("Settings", EditorStyles.toolbarButton))
            {
                SettingsService.OpenProjectSettings("Project/Editor");
                EditorWindow.FocusWindowIfItsOpen <InspectorWindow>();
                GUIUtility.ExitGUI();
            }

            Color origColor = GUI.color;

            GUI.color = new Color(1, 1, 1, 1 * .5f);
            bool refreshButtonClicked = GUILayout.Button(refreshIcon, EditorStyles.toolbarButton);

            refresh   = refresh || refreshButtonClicked;
            GUI.color = origColor;

            if (refresh)
            {
                if (refreshButtonClicked)
                {
                    Provider.InvalidateCache();
                }
                UpdateWindow();
            }

            GUILayout.EndArea();

            Rect rect = new Rect(0, toolBarHeight, position.width, position.height - toolBarHeight - k_BottomBarHeight);

            bool repaint = false;

            GUILayout.EndHorizontal();

            // Disabled Window view
            if (!Provider.isActive)
            {
                Color tmpColor = GUI.color;
                GUI.color   = new Color(0.8f, 0.5f, 0.5f);
                rect.height = toolBarHeight;
                GUILayout.BeginArea(rect);

                GUILayout.BeginHorizontal(EditorStyles.toolbar);
                GUILayout.FlexibleSpace();
                string msg = "DISABLED";
                if (Provider.enabled)
                {
                    if (Provider.onlineState == OnlineState.Updating)
                    {
                        GUI.color = new Color(0.8f, 0.8f, 0.5f);
                        msg       = "CONNECTING...";
                    }
                    else
                    {
                        msg = "OFFLINE";
                    }
                }

                GUILayout.Label(msg, EditorStyles.miniLabel);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndArea();

                rect.y += rect.height;
                if (!string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.Label(rect, Provider.offlineReason);
                }

                GUI.color = tmpColor;
                repaint   = false;
            }
            else
            {
                if (m_ShowIncoming)
                {
                    repaint |= incomingList.OnGUI(rect, hasFocus);
                }
                else
                {
                    repaint |= pendingList.OnGUI(rect, hasFocus);
                }


                rect.y     += rect.height;
                rect.height = k_BottomBarHeight;

                // Draw separation line over the button
                GUI.Label(rect, GUIContent.none, s_Styles.bottomBarBg);

                var  content      = EditorGUIUtility.TrTextContent("Apply All Incoming Changes");
                var  buttonSize   = EditorStyles.miniButton.CalcSize(content);
                Rect progressRect = new Rect(rect.x, rect.y - 2, rect.width - buttonSize.x - 5f, rect.height);
                ProgressGUI(progressRect, Provider.activeTask, false);

                if (m_ShowIncoming)
                {
                    // Draw "apply incoming" button
                    var buttonRect = rect;
                    buttonRect.width  = buttonSize.x;
                    buttonRect.height = buttonSize.y;
                    buttonRect.y      = rect.y + 2f;
                    buttonRect.x      = position.width - buttonSize.x - 5f;

                    using (new EditorGUI.DisabledScope(incomingList.Size == 0))
                    {
                        if (GUI.Button(buttonRect, content, EditorStyles.miniButton))
                        {
                            Asset root = new Asset("");
                            Task  t    = Provider.GetLatest(new AssetList()
                            {
                                root
                            });
                            t.SetCompletionAction(CompletionAction.OnGotLatestPendingWindow);
                        }
                    }
                }
            }

            if (repaint)
            {
                Repaint();
            }
        }
Example #14
0
        private void OnGUI()
        {
            this.InitStyles();
            if (!WindowPending.s_DidReload)
            {
                WindowPending.s_DidReload = true;
                this.UpdateWindow();
            }
            this.CreateResources();
            Event current     = Event.current;
            float fixedHeight = EditorStyles.toolbar.fixedHeight;

            GUILayout.BeginArea(new Rect(0f, 0f, base.position.width, fixedHeight));
            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            int num = (this.incomingList.Root != null) ? this.incomingList.Root.ChildCount : 0;

            this.m_ShowIncoming = !GUILayout.Toggle(!this.m_ShowIncoming, "Outgoing", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            GUIContent content = GUIContent.Temp("Incoming" + ((num != 0) ? (" (" + num.ToString() + ")") : string.Empty));

            this.m_ShowIncoming = GUILayout.Toggle(this.m_ShowIncoming, content, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(Provider.activeTask != null);
            CustomCommand[] customCommands = Provider.customCommands;
            for (int i = 0; i < customCommands.Length; i++)
            {
                CustomCommand customCommand = customCommands[i];
                if (customCommand.context == CommandContext.Global && GUILayout.Button(customCommand.label, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    customCommand.StartTask();
                }
            }
            EditorGUI.EndDisabledGroup();
            bool flag = Mathf.FloorToInt(base.position.width - this.s_ToolbarButtonsWidth) > 0;

            if (flag && GUILayout.Button("Settings", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                EditorApplication.ExecuteMenuItem("Edit/Project Settings/Editor");
                EditorWindow.FocusWindowIfItsOpen <InspectorWindow>();
                GUIUtility.ExitGUI();
            }
            Color color = GUI.color;

            GUI.color = new Color(1f, 1f, 1f, 0.5f);
            bool flag2 = GUILayout.Button(this.refreshIcon, EditorStyles.toolbarButton, new GUILayoutOption[0]);

            GUI.color = color;
            if (current.isKey && GUIUtility.keyboardControl == 0 && current.type == EventType.KeyDown && current.keyCode == KeyCode.F5)
            {
                flag2 = true;
                current.Use();
            }
            if (flag2)
            {
                Provider.InvalidateCache();
                if (Provider.isActive && Provider.onlineState == OnlineState.Online)
                {
                    Task task = Provider.ChangeSets();
                    task.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow);
                    Task task2 = Provider.Incoming();
                    task2.SetCompletionAction(CompletionAction.OnIncomingPendingWindow);
                }
                else
                {
                    Provider.UpdateSettings();
                }
            }
            GUILayout.EndArea();
            Rect rect  = new Rect(0f, fixedHeight, base.position.width, base.position.height - fixedHeight - 17f);
            bool flag3 = false;

            GUILayout.EndHorizontal();
            if (!Provider.isActive)
            {
                Color color2 = GUI.color;
                GUI.color   = new Color(0.8f, 0.5f, 0.5f);
                rect.height = fixedHeight;
                GUILayout.BeginArea(rect);
                GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                string text = "DISABLED";
                if (Provider.enabled)
                {
                    if (Provider.onlineState == OnlineState.Updating)
                    {
                        GUI.color = new Color(0.8f, 0.8f, 0.5f);
                        text      = "CONNECTING...";
                    }
                    else
                    {
                        text = "OFFLINE";
                    }
                }
                GUILayout.Label(text, EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                rect.y += rect.height;
                if (!string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.Label(rect, Provider.offlineReason);
                }
                GUI.color = color2;
                flag3     = false;
            }
            else
            {
                if (this.m_ShowIncoming)
                {
                    flag3 |= this.incomingList.OnGUI(rect, base.hasFocus);
                }
                else
                {
                    flag3 |= this.pendingList.OnGUI(rect, base.hasFocus);
                }
                rect.y     += rect.height;
                rect.height = 17f;
                GUI.Label(rect, GUIContent.none, WindowPending.s_Styles.bottomBarBg);
                GUIContent content2 = new GUIContent("Apply All Incoming Changes");
                Vector2    vector   = EditorStyles.miniButton.CalcSize(content2);
                Rect       rect2    = new Rect(rect.x, rect.y - 2f, rect.width - vector.x - 5f, rect.height);
                WindowPending.ProgressGUI(rect2, Provider.activeTask, false);
                if (this.m_ShowIncoming)
                {
                    Rect position = rect;
                    position.width  = vector.x;
                    position.height = vector.y;
                    position.y      = rect.y + 2f;
                    position.x      = base.position.width - vector.x - 5f;
                    EditorGUI.BeginDisabledGroup(this.incomingList.Size == 0);
                    if (GUI.Button(position, content2, EditorStyles.miniButton))
                    {
                        Asset item   = new Asset(string.Empty);
                        Task  latest = Provider.GetLatest(new AssetList
                        {
                            item
                        });
                        latest.SetCompletionAction(CompletionAction.OnGotLatestPendingWindow);
                    }
                    EditorGUI.EndDisabledGroup();
                }
            }
            if (flag3)
            {
                base.Repaint();
            }
        }