コード例 #1
0
        static void ImportStringTable(MenuCommand command)
        {
            var table = command.context as StringTable;

            Assert.IsTrue(table != null, "Expected StringTable");

            var path = EditorUtility.OpenFilePanel($"Import CSV into {table.TableData}({table.LocaleIdentifier})", PreviousDirectory, "csv");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            EditorPrefs.SetString(kPrefFile, path);

            var collection = LocalizationEditorSettings.GetCollectionFromTable(table) as StringTableCollection;

            if (collection == null)
            {
                Debug.LogError("String Table must belong to a StringTableCollection.");
                return;
            }

            var cellMappings = new CsvColumns[] { new KeyIdColumns(), new LocaleColumns {
                                                      LocaleIdentifier = table.LocaleIdentifier
                                                  } };

            using (var stream = new StreamReader(path))
            {
                var reporter = TaskReporter.CreateDefaultReporter();
                reporter.Start("Importing " + path, string.Empty);
                Csv.ImportInto(stream, collection, cellMappings, true, reporter);
            }
        }
コード例 #2
0
 static void Import(string path, StringTableCollection collection, IList <CsvColumns> columns)
 {
     using (var stream = new StreamReader(path))
     {
         var reporter = TaskReporter.CreateDefaultReporter();
         reporter.Start("Importing " + path, string.Empty);
         Csv.ImportInto(stream, collection, columns, true, reporter);
     }
 }
コード例 #3
0
 static void Export(string path, StringTableCollection collection, IList <CsvColumns> columns)
 {
     using (var stream = new StreamWriter(path, false, Encoding.UTF8))
     {
         var reporter = TaskReporter.CreateDefaultReporter();
         reporter.Start("Exporting " + path, string.Empty);
         Csv.Export(stream, collection, columns, reporter);
     }
 }
コード例 #4
0
ファイル: MenuItems.cs プロジェクト: Habi-Thapa/csv
        public static void ImportXliffFile()
        {
            var file = EditorUtility.OpenFilePanel("Import XLIFF", "", "xlf");

            if (string.IsNullOrEmpty(file))
            {
                return;
            }

            Xliff.ImportFile(file, null, TaskReporter.CreateDefaultReporter());
        }
コード例 #5
0
ファイル: MenuItems.cs プロジェクト: Habi-Thapa/csv
        public static void ImportXliffDirectory()
        {
            var dir = EditorUtility.OpenFolderPanel("Import XLIFF from directory", EditorPrefs.GetString(kPrefXliffDirectory, ""), "");

            if (string.IsNullOrEmpty(dir))
            {
                return;
            }
            EditorPrefs.SetString(kPrefXliffDirectory, dir);

            Xliff.ImportDirectory(dir, null, TaskReporter.CreateDefaultReporter());
        }
コード例 #6
0
ファイル: IDEBuildLogger.cs プロジェクト: svick/visualfsharp
        /// <summary>
        /// Constructor.  Inititialize member data.
        /// </summary>
        internal IDEBuildLogger(IVsOutputWindowPane output, TaskProvider taskProvider, IVsHierarchy hierarchy)
        {
            if (taskProvider == null)
                throw new ArgumentNullException("taskProvider");
            if (hierarchy == null)
                throw new ArgumentNullException("hierarchy");

            this.taskProvider = taskProvider;
            this.taskReporter = null;
            this.outputWindowPane = output;
            this.hierarchy = hierarchy;
            IOleServiceProvider site;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hierarchy.GetSite(out site));
            this.serviceProvider = new ServiceProvider(site);
        }
コード例 #7
0
ファイル: MenuItems.cs プロジェクト: Habi-Thapa/csv
        public static void ImportIntoCollection(MenuCommand command)
        {
            var collection = command.context as StringTableCollection;

            Debug.Assert(collection != null, "Expected StringTableCollection");

            var file = EditorUtility.OpenFilePanel("Import XLIFF", EditorPrefs.GetString(kPrefXliffFile, ""), "xlf");

            if (string.IsNullOrEmpty(file))
            {
                return;
            }
            EditorPrefs.SetString(kPrefXliffFile, file);

            Xliff.ImportFileIntoCollection(collection, file, null, TaskReporter.CreateDefaultReporter());
        }
コード例 #8
0
        static void Export(IList <CsvColumns> cellMappings, StringTableCollection collection)
        {
            var path = EditorUtility.SaveFilePanel($"Export {collection.TableCollectionName} to CSV", PreviousDirectory, collection.TableCollectionName, "csv");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            EditorPrefs.SetString(kPrefFile, path);

            using (var stream = new StreamWriter(path, false, Encoding.UTF8))
            {
                var reporter = TaskReporter.CreateDefaultReporter();
                reporter.Start("Exporting " + path, string.Empty);
                Csv.Export(stream, collection, cellMappings, reporter);
            }
        }
コード例 #9
0
ファイル: IDEBuildLogger.cs プロジェクト: mrakgr/visualfsharp
        internal IDEBuildLogger(IVsOutputWindowPane output, TaskProvider taskProvider, IVsHierarchy hierarchy)
        {
            if (taskProvider == null)
            {
                throw new ArgumentNullException("taskProvider");
            }
            if (hierarchy == null)
            {
                throw new ArgumentNullException("hierarchy");
            }

            this.taskProvider     = taskProvider;
            this.taskReporter     = null;
            this.outputWindowPane = output;
            this.hierarchy        = hierarchy;
            IOleServiceProvider site;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hierarchy.GetSite(out site));
            this.serviceProvider = new ServiceProvider(site);
        }
コード例 #10
0
        public static void ImportCollection(MenuCommand command)
        {
            var collection = command.context as StringTableCollection;

            Assert.IsTrue(collection != null, "Expected StringTableCollection");

            var path = EditorUtility.OpenFilePanel($"Import CSV into {collection.TableCollectionName}", PreviousDirectory, "csv");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            EditorPrefs.SetString(kPrefFile, path);

            using (var stream = new StreamReader(path))
            {
                var reporter = TaskReporter.CreateDefaultReporter();
                reporter.Start("Importing " + path, string.Empty);
                Csv.ImportInto(stream, collection, true, reporter);
            }
        }
コード例 #11
0
ファイル: Source.cs プロジェクト: svick/visualfsharp
        /// <summary>
        /// If the file has been renamed then do some cleanup.
        /// </summary>
        public void CheckForRename()
        {
            var currentFilename = this.GetFilePath();
            if (this.originalFileName != currentFilename)
            {
                TaskReporter tr = this.GetTaskReporter();
                tr.ClearBackgroundTasksForFile(originalFileName);

                // Refresh the task list
                tr.OutputTaskList();

                this.originalFileName = null;

                if (this.taskProvider != null)
                {
                    this.taskProvider = null;
                }
                if (this.taskReporter != null)
                {
                    this.taskReporter.Dispose();
                    this.taskReporter = null;
                }

                this.RecordChangeToView();
            }
        }
コード例 #12
0
ファイル: Source.cs プロジェクト: svick/visualfsharp
        // Overriden in source.fs, it calls this base implementation
        public virtual void Dispose()
        {
#if LANGTRACE
            Trace.WriteLine("Source::Cleanup");
#endif
            this.disposed = true;
            try
            {
                if (this.textLinesEvents != null)
                {
                    this.textLinesEvents.Dispose();
                    this.textLinesEvents = null;
                }
            }
            finally
            {
                try
                {
                    if (this.userDataEvents != null)
                    {
                        this.userDataEvents.Dispose();
                        this.userDataEvents = null;
                    }
                }
                finally
                {
                    try
                    {
                        if (this.hiddenTextSession != null)
                        {
                            // We can't throw or exit here because we need to call Dispose on the
                            // other members that need to be disposed.
                            this.hiddenTextSession.UnadviseClient();
                            // This is causing a debug assert in vs\env\msenv\textmgr\vrlist.cpp
                            // at line 1997 in CVisibleRegionList::Terminate
                            //this.hiddenTextSession.Terminate();
                            this.hiddenTextSession = null;
                        }
                    }
                    finally
                    {
                        try
                        {
                            if (this.methodData != null)
                            {
                                this.methodData.Dispose();
                                this.methodData = null;
                            }
                        }
                        finally
                        {
                            try
                            {
                                if (this.completionSet != null)
                                {
                                    this.completionSet.Dispose();
                                    this.completionSet = null;
                                }
                            }
                            finally
                            {
                                try
                                {
                                    // clear out any remaining tasks for this doc in the task list
                                    // tp may not be the same as taskProvider

                                    // REVIEW: This should be: if (null != this.taskReporter)
                                    // Right now, MSBuild 4.0 can clear out build loggers responsibly, so this.taskReporter will always
                                    // be null when we get to this point, so we'll need to create a new taskReporter to clear out the
                                    // background tasks
                                    TaskReporter tr = this.GetTaskReporter();  // may be our own TR or one from ProjectSite of this file
                                    if (null != tr)
                                    {
                                        tr.ClearBackgroundTasksForFile(this.GetFilePath());
                                        // Refresh the task list
                                        tr.OutputTaskList();
                                    }
                                    if (null != this.taskReporter)      // dispose the one we own (do not dispose one shared by project site!)
                                    {
                                        this.taskReporter.Dispose();
                                        this.taskReporter = null;
                                        this.taskProvider = null;
                                    }
                                }
                                finally
                                {
                                    try
                                    {
                                        this.service = null;
                                        if (this.colorizer != null)
                                        {
                                            // The colorizer is owned by the core text editor, so we don't close it, the core text editor
                                            // does that for us when it is ready to do so.
                                            //colorizer.CloseColorizer();
                                            this.colorizer = null;
                                        }
                                    }
                                    finally
                                    {
                                        this.colorState = null;
                                        try
                                        {
                                            if (this.expansionProvider != null)
                                            {
                                                this.expansionProvider.Dispose();
                                                this.expansionProvider = null;
                                            }

                                        }
                                        finally
                                        {
                                            // Sometimes OnCloseSource is called when language service is changed, (for example
                                            // when you save the file with a different file extension) in which case we cannot 
                                            // null out the site because that will cause a crash inside msenv.dll.
                                            //            if (this.textLines != null) {
                                            //                ((IObjectWithSite)this.textLines).SetSite(null);
                                            //            }
                                            if (this.textLines != null)
                                            {
                                                this.textLines = null;
                                                Marshal.Release(pUnkTextLines);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #13
0
ファイル: Source.cs プロジェクト: svick/visualfsharp
 // Overriden in Source.fs, but it calls this base implementation
 internal virtual TaskReporter GetTaskReporter()
 {
     if (null == taskReporter)
     {
         string name = string.Format("Language service (Source.cs): {0}", this.GetFilePath());
         taskReporter = new TaskReporter(name);
         taskReporter.TaskListProvider = new TaskListProvider(GetTaskProvider());
     }
     return taskReporter;
 }
コード例 #14
0
        void DrawSyncControls(JsonExtensionPropertyDrawerData data, SerializedProperty property, ref Rect position)
        {
            // EditorGUI.PropertyField(position, data.m_RemoveMissingPulledKeys);
            // position.MoveToNextLine();

            // Disable if we have no destination sheet.
            var splitRow = position.SplitHorizontal();

            position.MoveToNextLine();

            if (data.PushTask != null && data.PushTask.IsCompleted)
            {
                // var target = property.GetActualObjectForSerializedProperty<GoogleSheetsExtension>(fieldInfo);
                // var collection = target.TargetCollection as StringTableCollection;
                // var currentPushRequest = s_PushRequests.FirstOrDefault(tc => ReferenceEquals(tc.collection, collection));
                // s_PushRequests.Remove(currentPushRequest);
                data.PushTask = null;
            }

            using (new EditorGUI.DisabledGroupScope(data.PushTask != null ||
                                                    string.IsNullOrEmpty(data.m_TableId.stringValue) ||
                                                    data.FieldsList.count == 0))
            {
                using (new EditorGUI.DisabledGroupScope(data.FieldsList.index < 0))
                {
                    if (GUI.Button(splitRow.left, Styles.pushSelected))
                    {
                        // var google = GetGoogleSheets(data);
                        // var target = property.GetActualObjectForSerializedProperty<GoogleSheetsExtension>(fieldInfo);
                        // var selectedCollection = GetSelectedColumns(data.columnsList.index, property);
                        // var collection = target.TargetCollection as StringTableCollection;
                        // data.pushTask = google.PushStringTableCollectionAsync(data.m_SheetId.intValue, collection, selectedCollection, TaskReporter.CreateDefaultReporter());
                        // s_PushRequests.Add((collection, data.pushTask));
                    }

                    if (GUI.Button(splitRow.right, Styles.pullSelected))
                    {
                        // var google = GetGoogleSheets(data);
                        // var target = property.GetActualObjectForSerializedProperty<GoogleSheetsExtension>(fieldInfo);
                        // var selectedCollection = GetSelectedColumns(data.columnsList.index, property);
                        // google.PullIntoStringTableCollection(data.m_SheetId.intValue, target.TargetCollection as StringTableCollection, selectedCollection, data.m_RemoveMissingPulledKeys.boolValue, TaskReporter.CreateDefaultReporter(), true);
                    }
                }

                splitRow = position.SplitHorizontal();
                position.MoveToNextLine();
                if (GUI.Button(splitRow.left, Styles.push))
                {
                    // var google = GetGoogleSheets(data);
                    // var target = property.GetActualObjectForSerializedProperty<GoogleSheetsExtension>(fieldInfo);
                    // var collection = target.TargetCollection as StringTableCollection;
                    // data.pushTask = google.PushStringTableCollectionAsync(data.m_SheetId.intValue, collection, target.Columns, TaskReporter.CreateDefaultReporter());
                    // s_PushRequests.Add((collection, data.pushTask));
                }

                if (GUI.Button(splitRow.right, Styles.pull))
                {
                    var google = GetTableContent(data);
                    var target = property.GetActualObjectForSerializedProperty <JsonExtension>(fieldInfo);
                    google.PullIntoStringTableCollection(target.TargetCollection as StringTableCollection, target.Fields,
                                                         data.m_RemoveMissingPulledKeys.boolValue, TaskReporter.CreateDefaultReporter(), true);
                }
            }
        }
コード例 #15
0
ファイル: MenuItems.cs プロジェクト: Habi-Thapa/csv
        static void ImportIntoTable(MenuCommand command)
        {
            var table = command.context as StringTable;

            Debug.Assert(table != null, "Expected StringTable");

            var file = EditorUtility.OpenFilePanel("Import XLIFF", EditorPrefs.GetString(kPrefXliffFile, ""), "xlf");

            if (string.IsNullOrEmpty(file))
            {
                return;
            }
            EditorPrefs.SetString(kPrefXliffFile, file);

            Xliff.ImportFileIntoTable(file, table, Xliff.ImportNotesBehavior.Replace, TaskReporter.CreateDefaultReporter());
        }