first commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
namespace Unity.PlasticSCM.Editor.UI.StatusBar
|
||||
{
|
||||
internal class IncomingChangesNotification
|
||||
{
|
||||
internal string InfoText;
|
||||
internal string ActionText;
|
||||
internal string TooltipText;
|
||||
internal bool HasUpdateAction;
|
||||
internal PlasticNotification.Status Status;
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
InfoText = string.Empty;
|
||||
ActionText = string.Empty;
|
||||
TooltipText = string.Empty;
|
||||
HasUpdateAction = false;
|
||||
Status = PlasticNotification.Status.None;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e5597d68d235fd409841ed3c1321df8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,189 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui.WebApi.Responses;
|
||||
using PlasticGui.WorkspaceWindow.NotificationBar;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.StatusBar
|
||||
{
|
||||
class NotificationBar : INotificationBar
|
||||
{
|
||||
internal bool HasNotification { get; private set; }
|
||||
internal bool IsVisible { get; private set; }
|
||||
|
||||
internal NotificationBar()
|
||||
{
|
||||
mSubscriptionPanel = new ActionPanel();
|
||||
mContactPanel = new ActionPanel();
|
||||
|
||||
IsVisible = EditorPrefs.GetBool(
|
||||
UnityConstants.SHOW_NOTIFICATION_KEY_NAME,
|
||||
true);
|
||||
}
|
||||
|
||||
internal void SetVisibility(bool isVisible)
|
||||
{
|
||||
IsVisible = isVisible;
|
||||
|
||||
EditorPrefs.SetBool(
|
||||
UnityConstants.SHOW_NOTIFICATION_KEY_NAME,
|
||||
isVisible);
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.BeginHorizontal(UnityStyles.StatusBar.NotificationPanel);
|
||||
|
||||
if (mSubscriptionPanel.HasNotification)
|
||||
mSubscriptionPanel.OnGUI();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (mContactPanel.HasNotification)
|
||||
mContactPanel.OnGUI();
|
||||
|
||||
DrawCloseButton(this);
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
void INotificationBar.SetActions(
|
||||
CloudServerInfo cloudServerInfo,
|
||||
CloudOrganizationHelpActionsResponse.Action subscriptionAction,
|
||||
CloudOrganizationHelpActionsResponse.Action contactAction)
|
||||
{
|
||||
mSubscriptionPanel.SetAction(cloudServerInfo, subscriptionAction, false);
|
||||
mContactPanel.SetAction(cloudServerInfo, contactAction, true);
|
||||
|
||||
HasNotification = mSubscriptionPanel.HasNotification || mContactPanel.HasNotification;
|
||||
}
|
||||
|
||||
void INotificationBar.CleanActions()
|
||||
{
|
||||
HasNotification = false;
|
||||
|
||||
mSubscriptionPanel.SetAction(null, null, false);
|
||||
mContactPanel.SetAction(null, null, false);
|
||||
}
|
||||
|
||||
static void DrawCloseButton(NotificationBar notificationBar)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button(
|
||||
new GUIContent(Images.GetCloseIcon()),
|
||||
UnityStyles.StatusBar.NotificationPanelCloseButton))
|
||||
{
|
||||
notificationBar.SetVisibility(false);
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
class ActionPanel
|
||||
{
|
||||
internal bool HasNotification { get; private set; }
|
||||
|
||||
internal void SetAction(
|
||||
CloudServerInfo cloudServerInfo,
|
||||
CloudOrganizationHelpActionsResponse.Action action,
|
||||
bool isContactSupportAction)
|
||||
{
|
||||
if (action == null)
|
||||
{
|
||||
HasNotification = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mCloudServerInfo = cloudServerInfo;
|
||||
mActionButton = action.Button;
|
||||
mIsContactSupportAction = isContactSupportAction;
|
||||
|
||||
HasNotification = true;
|
||||
mLabelText = action.Message;
|
||||
SetButton(action.Button);
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
DrawLabel(mLabelText);
|
||||
|
||||
if (!mIsButtonVisible)
|
||||
return;
|
||||
|
||||
DrawButton(
|
||||
mCloudServerInfo, mActionButton.Url,
|
||||
mIsContactSupportAction, mButtonText);
|
||||
}
|
||||
|
||||
void SetButton(
|
||||
CloudOrganizationHelpActionsResponse.ActionButton actionButton)
|
||||
{
|
||||
if (actionButton == null)
|
||||
{
|
||||
mButtonText = string.Empty;
|
||||
mIsButtonVisible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mButtonText = actionButton.Caption;
|
||||
mIsButtonVisible = true;
|
||||
}
|
||||
|
||||
static void DrawLabel(string text)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.Label(
|
||||
text,
|
||||
UnityStyles.StatusBar.Label);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static void DrawButton(
|
||||
CloudServerInfo cloudServerInfo,
|
||||
string actionButtonUrl,
|
||||
bool isContactSupportAction,
|
||||
string buttonText)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button(
|
||||
buttonText,
|
||||
UnityStyles.StatusBar.LinkLabel))
|
||||
{
|
||||
LaunchNotificationAction.For(
|
||||
cloudServerInfo,
|
||||
actionButtonUrl,
|
||||
isContactSupportAction);
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
bool mIsButtonVisible;
|
||||
string mButtonText;
|
||||
string mLabelText;
|
||||
|
||||
bool mIsContactSupportAction;
|
||||
CloudOrganizationHelpActionsResponse.ActionButton mActionButton;
|
||||
CloudServerInfo mCloudServerInfo;
|
||||
}
|
||||
|
||||
ActionPanel mSubscriptionPanel;
|
||||
ActionPanel mContactPanel;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8fb5a27b8554a74b8c566355a3c50f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,284 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using PlasticGui.Gluon;
|
||||
using PlasticGui.WorkspaceWindow.Topbar;
|
||||
using PlasticGui.WorkspaceWindow.PendingChanges;
|
||||
|
||||
using GluonShowIncomingChanges = PlasticGui.Gluon.WorkspaceWindow.ShowIncomingChanges;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.StatusBar
|
||||
{
|
||||
interface IIncomingChangesNotifier
|
||||
{
|
||||
bool HasNotification { get; }
|
||||
IncomingChangesNotification Notification { get; }
|
||||
}
|
||||
|
||||
internal class StatusBar
|
||||
{
|
||||
internal NotificationBar NotificationBar { get; private set; }
|
||||
|
||||
internal StatusBar()
|
||||
{
|
||||
mCooldownNotificationClearAction = new CooldownWindowDelayer(
|
||||
DelayedClearNotification,
|
||||
UnityConstants.NOTIFICATION_CLEAR_INTERVAL);
|
||||
|
||||
NotificationBar = new NotificationBar();
|
||||
}
|
||||
|
||||
internal void Notify(string message, MessageType type, Texture2D image)
|
||||
{
|
||||
mNotification = new Notification(message, type, image);
|
||||
mCooldownNotificationClearAction.Ping();
|
||||
}
|
||||
|
||||
internal void OnGUI(
|
||||
WorkspaceInfo wkInfo,
|
||||
WorkspaceWindow workspaceWindow,
|
||||
IMergeViewLauncher mergeViewLauncher,
|
||||
IGluonViewSwitcher gluonViewSwitcher,
|
||||
IIncomingChangesNotifier incomingChangesNotifier,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (NotificationBar.HasNotification &&
|
||||
NotificationBar.IsVisible)
|
||||
{
|
||||
BeginDrawBar();
|
||||
NotificationBar.OnGUI();
|
||||
EndDrawBar();
|
||||
}
|
||||
|
||||
BeginDrawBar();
|
||||
|
||||
if (NotificationBar.HasNotification)
|
||||
{
|
||||
DrawNotificationAvailablePanel(NotificationBar);
|
||||
}
|
||||
|
||||
if (incomingChangesNotifier.HasNotification)
|
||||
{
|
||||
DrawIncomingChangesNotification(
|
||||
wkInfo,
|
||||
workspaceWindow,
|
||||
mergeViewLauncher,
|
||||
gluonViewSwitcher,
|
||||
incomingChangesNotifier.Notification,
|
||||
isGluonMode);
|
||||
}
|
||||
|
||||
if (mNotification != null)
|
||||
DrawNotification(mNotification);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
DrawWorkspaceStatus(workspaceWindow);
|
||||
|
||||
EndDrawBar();
|
||||
}
|
||||
|
||||
void DelayedClearNotification()
|
||||
{
|
||||
mNotification = null;
|
||||
}
|
||||
|
||||
static void DrawNotificationAvailablePanel(
|
||||
NotificationBar notificationBar)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button(PlasticLocalization.GetString(
|
||||
notificationBar.IsVisible ?
|
||||
PlasticLocalization.Name.HideNotification :
|
||||
PlasticLocalization.Name.ShowNotification)))
|
||||
{
|
||||
notificationBar.SetVisibility(!notificationBar.IsVisible);
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static void DrawIncomingChangesNotification(
|
||||
WorkspaceInfo wkInfo,
|
||||
WorkspaceWindow workspaceWindow,
|
||||
IMergeViewLauncher mergeViewLauncher,
|
||||
IGluonViewSwitcher gluonViewSwitcher,
|
||||
IncomingChangesNotification notification,
|
||||
bool isGluonMode)
|
||||
{
|
||||
Texture2D icon = notification.Status == PlasticNotification.Status.Conflicts ?
|
||||
Images.GetConflictedIcon() :
|
||||
Images.GetOutOfSyncIcon();
|
||||
|
||||
DrawIcon(icon);
|
||||
|
||||
DrawNotificationLabel(notification.InfoText);
|
||||
|
||||
if (DrawButton(notification.ActionText, notification.TooltipText))
|
||||
{
|
||||
if (notification.HasUpdateAction)
|
||||
{
|
||||
workspaceWindow.UpdateWorkspace();
|
||||
return;
|
||||
}
|
||||
|
||||
ShowIncomingChangesForMode(
|
||||
wkInfo,
|
||||
mergeViewLauncher,
|
||||
gluonViewSwitcher,
|
||||
isGluonMode);
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawNotification(Notification notification)
|
||||
{
|
||||
DrawIcon(notification.Image);
|
||||
DrawNotificationLabel(notification.Message);
|
||||
}
|
||||
|
||||
static void DrawWorkspaceStatus(WorkspaceWindow workspaceWindow)
|
||||
{
|
||||
DrawIcon(Images.GetBranchIcon());
|
||||
|
||||
if (workspaceWindow.WorkspaceStatus == null)
|
||||
return;
|
||||
|
||||
DrawLabel(string.Format(
|
||||
"{0}@{1}@{2}",
|
||||
workspaceWindow.WorkspaceStatus.ObjectSpec,
|
||||
workspaceWindow.WorkspaceStatus.RepositoryName,
|
||||
workspaceWindow.ServerDisplayName));
|
||||
}
|
||||
|
||||
static void DrawIcon(Texture2D icon)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.Label(
|
||||
icon,
|
||||
UnityStyles.StatusBar.Icon,
|
||||
GUILayout.Height(UnityConstants.STATUS_BAR_ICON_SIZE),
|
||||
GUILayout.Width(UnityConstants.STATUS_BAR_ICON_SIZE));
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static void DrawLabel(string label)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.Label(
|
||||
label,
|
||||
UnityStyles.StatusBar.Label);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static void DrawNotificationLabel(string label)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.Label(
|
||||
label,
|
||||
UnityStyles.StatusBar.NotificationLabel);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static bool DrawButton(string label, string tooltip)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
bool buttonClicked = GUILayout.Button(
|
||||
new GUIContent(label, tooltip),
|
||||
UnityStyles.StatusBar.Button);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
|
||||
return buttonClicked;
|
||||
}
|
||||
|
||||
static void ShowIncomingChangesForMode(
|
||||
WorkspaceInfo workspaceInfo,
|
||||
IMergeViewLauncher mergeViewLauncher,
|
||||
IGluonViewSwitcher gluonSwitcher,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (isGluonMode)
|
||||
{
|
||||
GluonShowIncomingChanges.FromNotificationBar(
|
||||
workspaceInfo, gluonSwitcher);
|
||||
return;
|
||||
}
|
||||
|
||||
ShowIncomingChanges.FromNotificationBar(
|
||||
workspaceInfo, mergeViewLauncher);
|
||||
}
|
||||
|
||||
static void BeginDrawBar()
|
||||
{
|
||||
EditorGUILayout.BeginVertical(
|
||||
GetBarStyle(),
|
||||
GUILayout.Height(UnityConstants.STATUS_BAR_HEIGHT));
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
}
|
||||
|
||||
static void EndDrawBar()
|
||||
{
|
||||
EditorGUILayout.EndHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static GUIStyle GetBarStyle()
|
||||
{
|
||||
if (sBarTexture == null)
|
||||
sBarTexture = new Texture2D(1, 1);
|
||||
|
||||
if (sBarStyle == null)
|
||||
sBarStyle = new GUIStyle();
|
||||
|
||||
sBarTexture.SetPixel(0, 0, UnityStyles.Colors.BackgroundBar);
|
||||
sBarTexture.Apply();
|
||||
sBarStyle.normal.background = sBarTexture;
|
||||
|
||||
return sBarStyle;
|
||||
}
|
||||
|
||||
class Notification
|
||||
{
|
||||
internal string Message { get; private set; }
|
||||
internal MessageType MessageType { get; private set; }
|
||||
internal Texture2D Image { get; private set; }
|
||||
|
||||
internal Notification(string message, MessageType messageType, Texture2D image)
|
||||
{
|
||||
Message = message;
|
||||
MessageType = messageType;
|
||||
Image = image;
|
||||
}
|
||||
}
|
||||
|
||||
Notification mNotification;
|
||||
|
||||
readonly CooldownWindowDelayer mCooldownNotificationClearAction;
|
||||
|
||||
static Texture2D sBarTexture;
|
||||
static GUIStyle sBarStyle;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dae17e8419667e46a2a476dd2cd18e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user