Ejemplo n.º 1
0
        // TODO: do this after calling plastic workspace
        internal static void Enable()
        {
            if (sPlasticAPI == null)
            {
                sPlasticAPI = new PlasticAPI();
            }

            WorkspaceInfo wkInfo = FindWorkspace.InfoForApplicationPath(
                Application.dataPath,
                sPlasticAPI);

            if (wkInfo == null)
            {
                return;
            }

            sOperations = new AssetMenuRoutingOperations();

            sAssetStatusCache = new AssetStatusCache(
                wkInfo,
                sPlasticAPI.IsGluonWorkspace(wkInfo),
                RepaintProjectWindow);
            sAssetSelection    = new InspectorAssetSelection(UpdateFilterMenuItems);
            sFilterMenuBuilder = new AssetFilesFilterPatternsMenuBuilder(
                sOperations,
                IGNORE_MENU_ITEMS_PRIORITY,
                HIDDEN_MENU_ITEMS_PRIORITY);

            AddMenuItems();
        }
Ejemplo n.º 2
0
        // TODO: do this after calling plastic workspace
        internal static void Enable()
        {
            if (sPlasticAPI == null)
            {
                sPlasticAPI = new PlasticAPI();
            }

            WorkspaceInfo wkInfo = FindWorkspace.InfoForApplicationPath(
                Application.dataPath,
                sPlasticAPI);

            if (wkInfo == null)
            {
                return;
            }

            sOperations       = new AssetMenuRoutingOperations();
            sAssetStatusCache = new AssetStatusCache(
                wkInfo,
                sPlasticAPI.IsGluonWorkspace(wkInfo),
                RepaintProjectWindow);
            sAssetSelection = new InspectorAssetSelection();

            AddMenuItems();
        }
Ejemplo n.º 3
0
        static bool ShouldProjectBeMigrated(
            string projectPath,
            string projectGuid)
        {
            if (SessionState.GetBool(
                    CloudProjectDownloader.SHOULD_PROJECT_BE_DOWNLOADED_KEY, false))
            {
                return false;
            }

            string collabPath = GetCollabSnapshotFile(
                projectPath, projectGuid);

            if (!File.Exists(collabPath))
            {
                return false;
            }

            if (FindWorkspace.HasWorkspace(Application.dataPath))
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 4
0
    void UpdateProgress()
    {
        if (mProgress == 0)
        {
            return;
        }

        mProgressBar.style.display = DisplayStyle.Flex;

        if (mProgress == 1)
        {
            mProgressBar.value   = 20f;
            mProgressBar.title   = mProgressBar.value.ToString() + "%";
            mTurnedOffLabel.text = PlasticLocalization.GetString(
                PlasticLocalization.Name.TurnOffPlasticSCMClosingWindow);
            mPlasticWindow = Resources.FindObjectsOfTypeAll <PlasticWindow>().First();
            mPlasticWindow.Close();
            mProgress = 2;
            return;
        }
        if (mProgress == 2)
        {
            mProgressBar.value   = 50f;
            mProgressBar.title   = mProgressBar.value.ToString() + "%";
            mTurnedOffLabel.text = PlasticLocalization.GetString(
                PlasticLocalization.Name.TurnOffPlasticSCMCleaning);
            SetupCloudProjectId.SetCloudProjectId("");
            mProgress = 3;
            return;
        }
        if (mProgress == 3)
        {
            mProgressBar.value   = 75f;
            mProgressBar.title   = mProgressBar.value.ToString() + "%";
            mTurnedOffLabel.text = PlasticLocalization.GetString(
                PlasticLocalization.Name.TurnOffPlasticSCMDeleting);
            WorkspaceInfo workspaceInfo =
                FindWorkspace.InfoForApplicationPath(
                    Application.dataPath,
                    PlasticApp.PlasticAPI);
            Plastic.API.RemoveWorkspace(workspaceInfo);
            DrawInspectorOperations.Disable();
            DrawSceneOperations.Disable();
            mProgress = 4;
            return;
        }
        if (mProgress == 4)
        {
            mProgressBar.value   = 100f;
            mProgressBar.title   = mProgressBar.value.ToString() + "%";
            mTurnedOffLabel.text = PlasticLocalization.GetString(
                PlasticLocalization.Name.Done);
            mProgress = 9999;
            return;
        }
    }
Ejemplo n.º 5
0
        static bool Provider_preCheckoutCallback(
            AssetList list,
            ref string changesetID,
            ref string changesetDescription)
        {
            if (!sIsEnabled)
            {
                return(true);
            }

            if (!FindWorkspace.HasWorkspace(Application.dataPath))
            {
                Disable();
                return(true);
            }

            if (sWorkspaceWindow == null)
            {
                EditorWindow.GetWindow <PlasticWindow>();
            }

            List <string> selectedPaths = GetSelectedPaths.ForOperation(
                list,
                PlasticPlugin.AssetStatusCache,
                AssetMenuOperations.Checkout);

            if (sIsGluonMode)
            {
                GluonCheckoutOperation.Checkout(
                    sViewHost,
                    sProgressControls,
                    sGuiMessage,
                    selectedPaths.ToArray(),
                    false,
                    RefreshAsset.VersionControlCache);

                return(true);
            }

            CheckoutOperation.Checkout(
                sWorkspaceWindow,
                null,
                sProgressControls,
                selectedPaths,
                sNewIncomingChangesUpdater,
                RefreshAsset.VersionControlCache);

            return(true);
        }
Ejemplo n.º 6
0
        static void Checkin()
        {
            WorkspaceInfo wkInfo = FindWorkspace.InfoForApplicationPath(
                Application.dataPath,
                PlasticApp.PlasticAPI);

            if (wkInfo != null)
            {
                TrackFeatureUseEvent.For(
                    PlasticGui.Plastic.API.GetRepositorySpec(wkInfo),
                    TrackFeatureUseEvent.Features.ContextMenuCheckinOption);
            }

            ((IAssetMenuOperations)sOperations).Checkin();
        }
Ejemplo n.º 7
0
        static bool ShouldProjectBeMigrated()
        {
            if (SessionState.GetBool(
                    CloudProjectDownloader.SHOULD_PROJECT_BE_DOWNLOADED_KEY, false))
            {
                return(false);
            }

            if (!CollabPlugin.IsEnabled())
            {
                return(false);
            }

            if (FindWorkspace.HasWorkspace(Application.dataPath))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        static void MergeToMain()
        {
            try
            {
                WorkspaceInfo mWkInfo = FindWorkspace.InfoForApplicationPath(Application.dataPath, Plastic.API);

                if (mWkInfo == null)
                {
                    return;
                }

                RepositorySpec repSpec = Plastic.API.GetRepositorySpec(mWkInfo);
                RepositoryInfo repInfo = Plastic.API.GetRepositoryInfo(repSpec);

                BranchInfo workingBranchInfo = Plastic.API.GetWorkingBranch(mWkInfo);
                BranchInfo mainBranchInfo    = Plastic.API.GetMainBranch(repSpec);

                if (workingBranchInfo.BranchId == mainBranchInfo.BranchId)
                {
                    return;
                }

                SpecGenerator specGenerator   = new SpecGenerator(repInfo);
                BranchSpec    sourceSpec      = specGenerator.GenBranchSpec(false, workingBranchInfo.BranchName);
                BranchSpec    destinationSpec = specGenerator.GenBranchSpec(false, mainBranchInfo.BranchName);

                MergeSource mergeSource = MergeSourceBuilder.BuildMergeSource(repInfo,
                                                                              null, sourceSpec, destinationSpec, new MergeParameters());
                BuildMerge.ApplyMergeForMerge(mWkInfo, null).MergeTo(mergeSource, mMergeComments);
            }
            finally
            {
                string plasticIniFilePah = Path.Combine(Application.dataPath, "../plastic.ini");
                File.Delete(plasticIniFilePah);
            }
        }
        void DownloadRepository(object state)
        {
            DownloadRepositoryParameters parameters = (DownloadRepositoryParameters)state;

            try
            {
                if (FindWorkspace.HasWorkspace(parameters.ProjectPath))
                {
                    // each domain reload, the package is reloaded.
                    // way need to check if we already downloaded it
                    return;
                }

                mDisplayProgress = true;

                IPlasticWebRestApi restApi           = new PlasticWebRestApi();
                string             defaultCloudAlias = restApi.GetDefaultCloudAlias();

                RepositorySpec repSpec = BuildRepSpec(
                    parameters.CloudRepository,
                    parameters.CloudOrganization,
                    defaultCloudAlias);

                // we just download a cloud project,
                // so let's assume we're going to use Cloud Edition
                SetupUnityEditionToken.CreateCloudEditionTokenIfNeeded();

                if (!ClientConfig.IsConfigured())
                {
                    AutoConfigClientConf.FromUnityAccessToken(
                        parameters.AccessToken,
                        repSpec.Server,
                        parameters.ProjectPath);
                }

                TokenExchangeResponse tokenExchangeResponse = WebRestApiClient.
                                                              PlasticScm.TokenExchange(parameters.AccessToken);

                if (tokenExchangeResponse.Error != null)
                {
                    mOperationFailed = true;

                    UnityEngine.Debug.LogErrorFormat(
                        PlasticLocalization.GetString(PlasticLocalization.Name.ErrorDownloadingCloudProject),
                        string.Format("Unable to get TokenExchangeResponse: {0} [code {1}]",
                                      tokenExchangeResponse.Error.Message,
                                      tokenExchangeResponse.Error.ErrorCode));
                    return;
                }

                CloudEditionWelcomeWindow.JoinCloudServer(
                    repSpec.Server,
                    tokenExchangeResponse.User,
                    tokenExchangeResponse.AccessToken);

                ClientConfigData clientConfigData = ClientConfig.Get().GetClientConfigData();
                clientConfigData.WorkspaceServer = repSpec.Server;
                ClientConfig.Get().Save(clientConfigData);

                WorkspaceInfo wkInfo = CreateWorkspace(
                    repSpec, parameters.ProjectPath);

                mLog.DebugFormat("Created workspace {0} on {1}",
                                 wkInfo.Name,
                                 wkInfo.ClientPath);

                PlasticGui.Plastic.API.Update(
                    wkInfo.ClientPath,
                    UpdateFlags.None,
                    null,
                    mUpdateNotifier);
            }
            catch (Exception ex)
            {
                LogException(ex);

                UnityEngine.Debug.LogErrorFormat(
                    PlasticLocalization.GetString(PlasticLocalization.Name.ErrorDownloadingCloudProject),
                    ex.Message);

                mOperationFailed = true;
            }
            finally
            {
                mOperationFinished = true;
            }
        }
Ejemplo n.º 10
0
        void DownloadRepository(object state)
        {
            DownloadRepositoryParameters parameters = (DownloadRepositoryParameters)state;

            try
            {
                if (FindWorkspace.HasWorkspace(parameters.ProjectPath))
                {
                    // each domain reload, the package is reloaded.
                    // way need to check if we already downloaded it
                    return;
                }

                mDisplayProgress = true;

                IPlasticWebRestApi restApi           = new PlasticWebRestApi();
                string             defaultCloudAlias = restApi.GetDefaultCloudAlias();

                RepositorySpec repSpec = BuildRepSpec(
                    parameters.CloudRepository,
                    parameters.CloudOrganization,
                    defaultCloudAlias);

                TokenExchangeResponse tokenExchangeResponse =
                    AutoConfig.PlasticCredentials(
                        parameters.AccessToken,
                        repSpec.Server,
                        parameters.ProjectPath);

                if (tokenExchangeResponse.Error != null)
                {
                    mOperationFailed = true;

                    UnityEngine.Debug.LogErrorFormat(
                        PlasticLocalization.GetString(PlasticLocalization.Name.ErrorDownloadingCloudProject),
                        string.Format("Unable to get TokenExchangeResponse: {0} [code {1}]",
                                      tokenExchangeResponse.Error.Message,
                                      tokenExchangeResponse.Error.ErrorCode));
                    return;
                }

                WorkspaceInfo wkInfo = CreateWorkspace(
                    repSpec, parameters.ProjectPath);

                mLog.DebugFormat("Created workspace {0} on {1}",
                                 wkInfo.Name,
                                 wkInfo.ClientPath);

                PlasticGui.Plastic.API.Update(
                    wkInfo.ClientPath,
                    UpdateFlags.None,
                    null,
                    mUpdateNotifier);
            }
            catch (Exception ex)
            {
                LogException(ex);

                UnityEngine.Debug.LogErrorFormat(
                    PlasticLocalization.GetString(PlasticLocalization.Name.ErrorDownloadingCloudProject),
                    ex.Message);

                mOperationFailed = true;
            }
            finally
            {
                mOperationFinished = true;
            }
        }
Ejemplo n.º 11
0
        static void Editor_finishedDefaultHeaderGUI(UnityEditor.Editor inspector)
        {
            if (!sIsEnabled)
            {
                return;
            }

            if (!FindWorkspace.HasWorkspace(Application.dataPath))
            {
                Disable();
                return;
            }

            sAssetSelection.SetActiveInspector(inspector);

            AssetList assetList = ((AssetOperations.IAssetSelection)
                                   sAssetSelection).GetSelectedAssets();

            if (assetList.Count == 0 ||
                string.IsNullOrEmpty(assetList[0].path))
            {
                return;
            }

            string selectionFullPath = Path.GetFullPath(assetList[0].path);

            AssetsOverlays.AssetStatus assetStatus = (assetList.Count > 1) ?
                                                     AssetsOverlays.AssetStatus.None :
                                                     PlasticPlugin.AssetStatusCache.GetStatusForPath(selectionFullPath);

            LockStatusData lockStatusData = PlasticPlugin.AssetStatusCache.GetLockStatusDataForPath(
                selectionFullPath);

            SelectedAssetGroupInfo selectedGroupInfo = SelectedAssetGroupInfo.
                                                       BuildFromAssetList(assetList, PlasticPlugin.AssetStatusCache);

            AssetMenuOperations assetOperations =
                AssetMenuUpdater.GetAvailableMenuOperations(selectedGroupInfo);

            bool guiEnabledBck = GUI.enabled;

            GUI.enabled = true;
            try
            {
                DrawBackRectangle(guiEnabledBck);

                GUILayout.BeginHorizontal();

                DrawStatusLabel(assetStatus, lockStatusData);

                GUILayout.FlexibleSpace();

                DrawButtons(assetList, assetOperations);

                GUILayout.EndHorizontal();
            }
            finally
            {
                GUI.enabled = guiEnabledBck;
            }
        }