public static void RemoveUSSFromAsset(BuilderPaneWindow paneWindow, BuilderSelection selection, VisualElement clickedElement)
        {
            // We need to save all files before we remove the USS references.
            // If we don't do this, changes in the removed USS will be lost.
            var shouldContinue = s_CheckForUnsavedChanges(paneWindow);

            if (!shouldContinue)
            {
                return;
            }

            var selectedElements = selection.selection;

            if (!selectedElements.Contains(clickedElement))
            {
                // Removed just clicked element
                var clickedStyleSheetIndex = (int)clickedElement.GetProperty(BuilderConstants.ElementLinkedStyleSheetIndexVEPropertyName);
                BuilderAssetUtilities.RemoveStyleSheetFromAsset(paneWindow.document, clickedStyleSheetIndex);
            }
            else
            {
                // Removed selected elements
                var styleSheetIndexes = selectedElements.Where(x => BuilderSharedStyles.IsStyleSheetElement(x) &&
                                                               string.IsNullOrEmpty(x.GetProperty(BuilderConstants.ExplorerItemLinkedUXMLFileName) as string))
                                        .Select(x => (int)x.GetProperty(BuilderConstants.ElementLinkedStyleSheetIndexVEPropertyName))
                                        .OrderByDescending(x => x)
                                        .ToArray();

                BuilderAssetUtilities.RemoveStyleSheetsFromAsset(paneWindow.document, styleSheetIndexes);
            }

            paneWindow.OnEnableAfterAllSerialization();
        }
        void SaveDocument(string uxmlPath, string ussPath)
        {
            var viewportWindow = m_PaneWindow as IBuilderViewportWindow;

            if (viewportWindow == null)
            {
                return;
            }

            // Set asset.
            var needFullRefresh = document.SaveNewDocument(
                uxmlPath, ussPath, viewportWindow.documentRootElement, m_IsDialogSaveAs);

            // Update any uses out there of the currently edited and saved USS.
            RetainedMode.FlagStyleSheetChange();

            // Save last save path.
            m_LastSavePath = Path.GetDirectoryName(uxmlPath);

            // Set doc field value.
            SetViewportSubTitle();

            m_SaveDialog.Hide();

            if (needFullRefresh)
            {
                m_PaneWindow.OnEnableAfterAllSerialization();
            }
            else
            {
                m_Selection.NotifyOfHierarchyChange(document);
            }
        }
        public static bool AddUSSToAsset(BuilderPaneWindow paneWindow, string ussPath)
        {
            bool added = BuilderAssetUtilities.AddStyleSheetToAsset(paneWindow.document, ussPath);

            if (added)
            {
                paneWindow.OnEnableAfterAllSerialization();
            }

            return(added);
        }
Beispiel #4
0
        public static void RemoveUSSFromAsset(BuilderPaneWindow paneWindow, int selectedStyleSheetIndex)
        {
            // We need to save all files before we remove the USS.
            // If we don't do this, changes in the removed USS will be lost.
            var shouldContinue = s_CheckForUnsavedChanges(paneWindow);

            if (!shouldContinue)
            {
                return;
            }

            BuilderAssetUtilities.RemoveStyleSheetFromAsset(paneWindow.document, selectedStyleSheetIndex);
            paneWindow.OnEnableAfterAllSerialization();
        }
        internal void SaveDocument(bool isSaveAs)
        {
            var viewportWindow = m_PaneWindow as IBuilderViewportWindow;

            if (viewportWindow == null)
            {
                return;
            }

            m_Explorer.elementHierarchyView.RegisterTreeState();

            // Set asset.
            var userConfirmed = document.SaveNewDocument(viewportWindow.documentRootElement, isSaveAs, out var needFullRefresh);

            if (!userConfirmed)
            {
                return;
            }

            // Update any uses out there of the currently edited and saved USS.
            RetainedMode.FlagStyleSheetChange();

            // Save last save path.
            m_LastSavePath = Path.GetDirectoryName(document.uxmlPath);

            // Set doc field value.
            UpdateHasUnsavedChanges();

            // Only updating UI to remove "*" from file names.
            m_Selection.ResetUnsavedChanges();

            if (needFullRefresh)
            {
                m_PaneWindow.OnEnableAfterAllSerialization();
            }
            else
            {
                m_Selection.NotifyOfHierarchyChange(document);
            }
        }
Beispiel #6
0
 void OnUndoRedo()
 {
     m_PaneWindow.OnEnableAfterAllSerialization();
 }
Beispiel #7
0
 public static void AddUSSToAsset(BuilderPaneWindow paneWindow, string ussPath)
 {
     BuilderAssetUtilities.AddStyleSheetToAsset(paneWindow.document, ussPath);
     paneWindow.OnEnableAfterAllSerialization();
 }