Exemplo n.º 1
0
        private void ShowContextMenuForElement(string changePath, string assetPath)
        {
            GenericMenu menu = new GenericMenu();

            if (commit.Parents.Count() == 1)
            {
                menu.AddItem(new GUIContent("Difference with previous commit"), false, () =>
                {
                    Commit parent = commit.Parents.Single();
                    gitManager.ShowDiff(changePath, commit, parent, externalManager);
                });
            }
            else
            {
                menu.AddDisabledItem(new GUIContent(new GUIContent("Difference with previous commit")));
            }
            menu.AddItem(new GUIContent("Difference with HEAD"), false, () =>
            {
                gitManager.ShowDiff(changePath, commit, gitManager.Repository.Head.Tip, externalManager);
            });
            menu.AddItem(new GUIContent("Select In Project"), false, () =>
            {
                var asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object));
                if (asset != null)
                {
                    Selection.activeObject = asset;
                }
            });
            menu.ShowAsContext();
        }
Exemplo n.º 2
0
        public override void OnGUI(Rect rect)
        {
            EditorGUILayout.Space();
            float msgHeight = commitMessageStyle.CalcHeight(new GUIContent(commit.Message), rect.width);

            EditorGUILayout.LabelField(new GUIContent(commit.Message), commitMessageStyle, GUILayout.Height(msgHeight));
            scroll = EditorGUILayout.BeginScrollView(scroll);
            EditorGUILayout.Space();
            if (changes != null)
            {
                foreach (var change in changes)
                {
                    //EditorGUILayout.BeginHorizontal();
                    //GUILayout.Label(change.Status.ToString(), "AssetLabel");
                    EditorGUILayout.BeginHorizontal("ProjectBrowserHeaderBgTop");
                    GUILayout.Label(new GUIContent(GitManager.GetDiffTypeIcon(change.Status, true)), GUILayout.Width(16));
                    GUILayout.Label(new GUIContent("(" + change.Status + ")"), "AboutWIndowLicenseLabel");
                    GUILayout.Space(8);
                    foreach (var chunk in change.Path.Split('\\'))
                    {
                        GUILayout.Label(new GUIContent(chunk), "GUIEditor.BreadcrumbMid");
                    }
                    //GUILayout.Label(new GUIContent(" (" + change.Status + ") " + change.Path));
                    EditorGUILayout.EndHorizontal();
                    Rect r = GUILayoutUtility.GetLastRect();
                    if (Event.current.type == EventType.ContextClick)
                    {
                        GenericMenu menu = new GenericMenu();
                        if (commit.Parents.Count() == 1)
                        {
                            menu.AddItem(new GUIContent("Difference with previous commit"), false, () =>
                            {
                                Commit parent = commit.Parents.Single();
                                GitManager.ShowDiff(change.Path, parent, commit);
                            });
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent(new GUIContent("Difference with previous commit")));
                        }
                        menu.AddItem(new GUIContent("Difference with HEAD"), false, () =>
                        {
                            GitManager.ShowDiff(change.Path, commit, GitManager.Repository.Head.Tip);
                        });
                        menu.ShowAsContext();
                    }
                    //EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                DrawTreeEntry(commitTree, 0);
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 3
0
 private void SeeDifferenceSelectedCallback(object path)
 {
     GitManager.ShowDiff((string)path);
 }
Exemplo n.º 4
0
 private static void SeeDifference()
 {
     GitManager.ShowDiff(AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]));
 }
        public override void OnGUI(Rect rect)
        {
            EditorGUILayout.Space();
            float msgHeight = commitMessageStyle.CalcHeight(GitGUI.GetTempContent(commit.Message), rect.width);

            scroll = EditorGUILayout.BeginScrollView(scroll);
            EditorGUILayout.LabelField(GitGUI.GetTempContent(commit.Message), commitMessageStyle, GUILayout.Height(msgHeight));
            if (changes != null)
            {
                foreach (var change in changes)
                {
                    //EditorGUILayout.BeginHorizontal();
                    //GUILayout.Label(change.Status.ToString(), "AssetLabel");
                    EditorGUILayout.BeginHorizontal("ProjectBrowserHeaderBgTop");
                    GUILayout.Label(new GUIContent(GitOverlay.GetDiffTypeIcon(change.Status, true))
                    {
                        tooltip = change.Status.ToString()
                    }, GUILayout.Width(16));
                    GUILayout.Space(8);
                    string[] pathChunks = change.Path.Split('\\');
                    for (int i = 0; i < pathChunks.Length; i++)
                    {
                        string chunk = pathChunks[i];
                        if (GUILayout.Button(GitGUI.GetTempContent(chunk), "GUIEditor.BreadcrumbMid"))
                        {
                            string assetPath = string.Join("/", pathChunks, 0, i + 1);
                            if (assetPath.EndsWith(".meta"))
                            {
                                assetPath = AssetDatabase.GetAssetPathFromTextMetaFilePath(assetPath);
                            }
                            var asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object));
                            if (asset != null)
                            {
                                Selection.activeObject = asset;
                            }
                        }
                    }
                    //GUILayout.Label(new GUIContent(" (" + change.Status + ") " + change.Path));
                    EditorGUILayout.EndHorizontal();
                    Rect r = GUILayoutUtility.GetLastRect();
                    if (Event.current.type == EventType.ContextClick && r.Contains(Event.current.mousePosition))
                    {
                        string      path = change.Path;
                        GenericMenu menu = new GenericMenu();
                        if (commit.Parents.Count() == 1)
                        {
                            menu.AddItem(new GUIContent("Difference with previous commit"), false, () =>
                            {
                                Commit parent = commit.Parents.Single();
                                GitManager.ShowDiff(path, parent, commit);
                            });
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent(new GUIContent("Difference with previous commit")));
                        }
                        menu.AddItem(new GUIContent("Difference with HEAD"), false, () =>
                        {
                            GitManager.ShowDiff(path, commit, GitManager.Repository.Head.Tip);
                        });
                        menu.ShowAsContext();
                    }
                    //EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                DrawTreeEntry(commitTree, 0);
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 6
0
 private void SeeDifferenceObject(StatusListEntry entry)
 {
     gitManager.ShowDiff(entry.LocalPath, externalManager);
 }
Exemplo n.º 7
0
 private static void SeeDifferenceObject()
 {
     gitManager.ShowDiff(gitManager.ToLocalPath(AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0])), externalManager);
 }