public static ILuaCompiler Create() { try { if (s_luaVersionService == null) { s_luaVersionService = SledServiceInstance.TryGet <ISledLuaLuaVersionService>(); } if (s_luaVersionService == null) { return(new Sce.Lua.Utilities.Lua51.x86.LuaCompiler()); } switch (s_luaVersionService.CurrentLuaVersion) { case LuaVersion.Lua51: return(new Sce.Lua.Utilities.Lua51.x86.LuaCompiler()); case LuaVersion.Lua52: return(new Sce.Lua.Utilities.Lua52.x86.LuaCompiler()); default: throw new NullReferenceException("Unknown Lua version!"); } } catch (Exception ex) { SledOutDevice.OutLine( SledMessageType.Error, "{0}: Exception creating Lua compiler: {1}", typeof(SledLuaCompilerServiceFactory), ex.Message); return(null); } }
public void Initialize() { BuildControl(); var mainForm = SledServiceInstance.TryGet <MainForm>(); mainForm.Shown += MainFormShown; SkinService.ApplyActiveSkin(SledTtyMessageColorer.Instance); SkinService.SkinChangedOrApplied += SkinServiceSkinChangedOrApplied; }
/// <summary> /// Create project watch from Lua variable /// </summary> /// <param name="luaVar"></param> /// <returns></returns> public static SledLuaProjectFilesWatchType CreateFromLuaVar(ISledLuaVarBaseType luaVar) { var projectFilesWatch = new DomNode(SledLuaSchema.SledLuaProjectFilesWatchType.Type) .As <SledLuaProjectFilesWatchType>(); var luaLanguagePlugin = SledServiceInstance.TryGet <SledLuaLanguagePlugin>(); projectFilesWatch.Name = luaVar.DisplayName; projectFilesWatch.LanguagePlugin = luaLanguagePlugin; projectFilesWatch.Scope = luaVar.Scope; projectFilesWatch.Context = SledLuaVarLookUpContextType.WatchProject; projectFilesWatch.LookUp = SledLuaVarLookUpType.FromLuaVar(luaVar, projectFilesWatch.Context); return(projectFilesWatch); }
/// <summary> /// Create project watch from custom values /// </summary> /// <param name="alias"></param> /// <param name="scope"></param> /// <param name="namesAndTypes"></param> /// <param name="guid"></param> /// <returns></returns> public static SledLuaProjectFilesWatchType CreateFromCustom(string alias, SledLuaVarScopeType scope, IList <SledLuaVarNameTypePairType> namesAndTypes, Guid guid) { var projectFilesWatch = new DomNode(SledLuaSchema.SledLuaProjectFilesWatchType.Type) .As <SledLuaProjectFilesWatchType>(); var luaLanguagePlugin = SledServiceInstance.TryGet <SledLuaLanguagePlugin>(); projectFilesWatch.Name = alias; projectFilesWatch.LanguagePlugin = luaLanguagePlugin; projectFilesWatch.Scope = scope; projectFilesWatch.Context = SledLuaVarLookUpContextType.WatchCustom; projectFilesWatch.Guid = guid; projectFilesWatch.LookUp = SledLuaVarLookUpType.FromCustomValues(scope, SledLuaVarLookUpContextType.WatchCustom, namesAndTypes); return(projectFilesWatch); }
private static bool CanGetSourceControlToCheckOut(SledDocument sd) { if (sd == null) { return(false); } var sourceControlService = SledServiceInstance.TryGet <SledSourceControlService>(); if (sourceControlService == null) { return(false); } var context = new SledDocumentSourceControlContext(sd); return (sourceControlService.CanDoCommand(SledSourceControlCommand.CheckOut, context) && sourceControlService.DoCommand(SledSourceControlCommand.CheckOut, context)); }
/// <summary> /// Fills in or modifies the given display info for the item</summary> /// <param name="item">Item</param> /// <param name="info">Display info to update</param> public new void GetInfo(object item, ItemInfo info) { info.Label = Name; info.IsLeaf = false; info.AllowLabelEdit = false; info.Description = "Project: " + Name; info.ImageIndex = info.GetImageIndex(Atf.Resources.FolderImage); // Set source control status { if (s_sourceControlService == null) { s_sourceControlService = SledServiceInstance.TryGet <ISledSourceControlService>(); } if (s_sourceControlService == null) { return; } if (!s_sourceControlService.CanUseSourceControl) { return; } var sourceControlStatus = s_sourceControlService.GetStatus(this); switch (sourceControlStatus) { case SourceControlStatus.CheckedOut: info.StateImageIndex = info.GetImageIndex(Atf.Resources.DocumentCheckOutImage); break; default: info.StateImageIndex = Atf.Controls.TreeListView.InvalidImageIndex; break; } } }
/// <summary> /// Open the project file and remove any duplicates /// </summary> /// <param name="szAbsPath"></param> public static void CleanupProjectFileDuplicates(string szAbsPath) { if (!File.Exists(szAbsPath)) { return; } if (SledUtil.IsFileReadOnly(szAbsPath)) { return; } try { var schemaLoader = SledServiceInstance.TryGet <SledSharedSchemaLoader>(); if (schemaLoader == null) { return; } var uri = new Uri(szAbsPath); var reader = new SledSpfReader(schemaLoader); var root = reader.Read(uri, false); if (root == null) { return; } var lstProjFiles = new List <SledProjectFilesFileType>(); // Gather up all project files in the project SledDomUtil.GatherAllAs(root, lstProjFiles); if (lstProjFiles.Count <= 1) { return; } var uniquePaths = new Dictionary <string, SledProjectFilesFileType>(StringComparer.CurrentCultureIgnoreCase); var lstDuplicates = new List <SledProjectFilesFileType>(); foreach (var projFile in lstProjFiles) { if (uniquePaths.ContainsKey(projFile.Path)) { lstDuplicates.Add(projFile); } else { uniquePaths.Add(projFile.Path, projFile); } } if (lstDuplicates.Count <= 0) { return; } foreach (var projFile in lstDuplicates) { projFile.DomNode.RemoveFromParent(); } var writer = new SledSpfWriter(schemaLoader.TypeCollection); // Write changes back to disk writer.Write(root, uri, false); } catch (Exception ex) { SledOutDevice.OutLine( SledMessageType.Error, SledUtil.TransSub(Localization.SledProjectFilesErrorRemovingDuplicates, ex.Message, szAbsPath)); } }
/// <summary> /// Try and obtain project information from a project file on disk /// </summary> /// <param name="absPath"></param> /// <param name="name"></param> /// <param name="projectDir"></param> /// <param name="assetDir"></param> /// <param name="guid"></param> /// <param name="files"></param> /// <returns></returns> public static bool TryGetProjectDetails( string absPath, out string name, out string projectDir, out string assetDir, out Guid guid, out List <string> files) { name = null; projectDir = null; assetDir = null; guid = Guid.Empty; files = null; try { // ATF 3's DOM makes this so much easier now! var schemaLoader = SledServiceInstance.TryGet <SledSharedSchemaLoader>(); if (schemaLoader == null) { return(false); } var uri = new Uri(absPath); var reader = new SledSpfReader(schemaLoader); var root = reader.Read(uri, false); if (root == null) { return(false); } var project = root.As <SledProjectFilesType>(); project.Uri = uri; // Pull out project details name = project.Name; guid = project.Guid; assetDir = project.AssetDirectory; projectDir = Path.GetDirectoryName(absPath); var lstProjFiles = new List <SledProjectFilesFileType>(); SledDomUtil.GatherAllAs(root, lstProjFiles); var assetDirTemp = assetDir; files = (from projFile in lstProjFiles let absFilePath = SledUtil.GetAbsolutePath( projFile.Path, assetDirTemp) select absFilePath).ToList(); return(true); } catch (Exception ex) { SledOutDevice.OutLine( SledMessageType.Error, "Exception encountered obtaining project " + "details. Project file: \"{0}\". Exception: {1}", absPath, ex.Message); return(false); } }
static void Main(string[] arg) { Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture; // For testing localization //Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ja"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); ShowBitNess(); ISledCrashReporter crashReporter = null; ISledUsageStatistics usageStatistics = null; try { // Try and create crash reporter crashReporter = SledLibCrashReportNetWrapper.TryCreateCrashReporter(); // Try and create usage statistics usageStatistics = SledLibCrashReportNetWrapper.TryCreateUsageStatistics(); // Create 'master' catalog to hold all // other catalogs we might create var aggregateCatalog = new AggregateCatalog(); // Add 'standard/default' parts to 'master' catalog aggregateCatalog.Catalogs.Add( new TypeCatalog( /* ATF related services */ typeof(SettingsService), typeof(StatusService), typeof(CommandService), typeof(ControlHostService), typeof(UnhandledExceptionService), typeof(UserFeedbackService), typeof(OutputService), typeof(Outputs), typeof(FileDialogService), typeof(DocumentRegistry), typeof(ContextRegistry), typeof(StandardFileExitCommand), typeof(RecentDocumentCommands), typeof(StandardEditCommands), typeof(StandardEditHistoryCommands), typeof(TabbedControlSelector), typeof(DefaultTabCommands), typeof(WindowLayoutService), typeof(WindowLayoutServiceCommands), typeof(SkinService), /* SLED related services */ typeof(SledOutDevice), typeof(SledAboutService), typeof(SledAboutDocumentService), typeof(SledGotoService), typeof(SledTitleBarTextService), typeof(SledDocumentService), typeof(SledProjectService), typeof(SledProjectWatcherService), typeof(SledModifiedProjectFormService), typeof(SledProjectFileGathererService), typeof(SledLanguageParserService), typeof(SledProjectFilesTreeEditor), typeof(SledProjectFilesDiskViewEditor), typeof(SledProjectFileFinderService), typeof(SledProjectFilesUtilityService), typeof(SledProjectFileAdderService), typeof(SledBreakpointService), typeof(SledBreakpointEditor), typeof(SledNetworkPluginService), typeof(SledLanguagePluginService), typeof(SledTargetService), typeof(SledFindAndReplaceService), typeof(SledFindAndReplaceService.SledFindResultsEditor1), typeof(SledFindAndReplaceService.SledFindResultsEditor2), typeof(SledDebugService), typeof(SledDebugScriptCacheService), typeof(SledDebugBreakpointService), typeof(SledDebugFileService), typeof(SledDebugHeartbeatService), typeof(SledDebugNegotiationTimeoutService), typeof(SledDebugFlashWindowService), typeof(SledFileWatcherService), typeof(SledModifiedFilesFormService), typeof(SledFileExtensionService), typeof(SledSyntaxCheckerService), typeof(SledSyntaxErrorsEditor), typeof(SledTtyService), typeof(SledDebugFreezeService), typeof(SledSourceControlService), typeof(SledSharedSchemaLoader) )); // Create directory information service var directoryInfoService = new SledDirectoryInfoService(); // Create dynamic plugin service var dynamicPluginService = new SledDynamicPluginService(); // Grab all dynamically loaded plugins // from the "SLED\Plugins" directory var dynamicAssemblies = dynamicPluginService.GetDynamicAssemblies(directoryInfoService); // Add dynamically obtained assemblies to // the master catalog AddAssembliesToMasterCatalog(aggregateCatalog, dynamicAssemblies); // Add 'master' catalog to container using (var container = new CompositionContainer(aggregateCatalog)) { // Create tool strip container using (var toolStripContainer = new ToolStripContainer()) { toolStripContainer.Dock = DockStyle.Fill; // Grab SledShared.dll for resource loading var assem = Assembly.GetAssembly(typeof(SledShared)); // Create main form & set up some properties var mainForm = new MainForm(toolStripContainer) { AllowDrop = true, Text = Resources.Resource.SLED, Icon = GdiUtil.GetIcon( assem, SledShared.IconPathBase + ".Sled.ico") }; // Load all the icons and images SLED will need SledShared.RegisterImages(); directoryInfoService.MainForm = mainForm; // Create batch and add any manual parts var batch = new CompositionBatch(); batch.AddPart(mainForm); batch.AddPart(directoryInfoService); batch.AddPart(dynamicPluginService); SetupDebugEventFiringWatching(batch); container.Compose(batch); // Set this one time SledServiceReferenceCompositionContainer.SetCompositionContainer(container); // Initialize all IInitializable interfaces try { try { foreach (var initializable in container.GetExportedValues <IInitializable>()) { initializable.Initialize(); } } catch (CompositionException ex) { foreach (var error in ex.Errors) { MessageBox.Show(error.Description, MefCompositionExceptionText); } throw; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), ExceptionDetailsText); Environment.Exit(-1); } // Send usage data to the server now that everything is loaded if (usageStatistics != null) { usageStatistics.PhoneHome(); } SledOutDevice.OutBreak(); // Notify directoryInfoService.LoadingFinished(); // Let ATF's UnhandledExceptionService know about our ICrashLogger if (crashReporter != null) { var unhandledExceptionService = SledServiceInstance.TryGet <UnhandledExceptionService>(); if (unhandledExceptionService != null) { unhandledExceptionService.CrashLogger = crashReporter; } } // Show main form finally Application.Run(mainForm); } } } finally { // // Cleanup // if (crashReporter != null) { crashReporter.Dispose(); } if (usageStatistics != null) { usageStatistics.Dispose(); } } }
/// <summary> /// Fills in or modifies the given display info for the item</summary> /// <param name="item">Item</param> /// <param name="info">Display info to update</param> public void GetInfo(object item, ItemInfo info) { info.Label = Name; info.IsLeaf = (Functions.Count == 0); info.AllowLabelEdit = true; info.Description = Name; info.Properties = new[] { Path }; var bFileExists = File.Exists(Uri.LocalPath); var bReadOnly = SledUtil.IsFileReadOnly(Uri.LocalPath); // Mark files that don't exist if (!bFileExists) { info.FontStyle = FontStyle.Strikeout; info.AllowLabelEdit = false; } // Don't allow renaming of read-only files if (bReadOnly) { info.AllowLabelEdit = false; } // Default var imageName = Atf.Resources.DocumentImage; // Try to grab other if ((DocumentClient != null) && (DocumentClient.Info != null) && !string.IsNullOrEmpty(DocumentClient.Info.OpenIconName)) { imageName = DocumentClient.Info.OpenIconName; } // Set image info.ImageIndex = info.GetImageIndex(imageName); // Set source control status { if (s_sourceControlService == null) { s_sourceControlService = SledServiceInstance.TryGet <ISledSourceControlService>(); } if (s_sourceControlService == null) { return; } if (!s_sourceControlService.CanUseSourceControl) { return; } var sourceControlStatus = s_sourceControlService.GetStatus(this); switch (sourceControlStatus) { case SourceControlStatus.CheckedOut: info.StateImageIndex = info.GetImageIndex(Atf.Resources.DocumentCheckOutImage); break; default: info.StateImageIndex = Atf.Controls.TreeListView.InvalidImageIndex; break; } } }
public void Initialize() { m_broker = LuaTextEditorFactory.CreateOrGetBroker(); m_broker.UseNavigationBar = false; m_broker.CustomScriptRegistrationHandler = CustomScriptRegistrationHandler; m_broker.OpenAndSelectHandler = CustomOpenAndSelectHandler; m_broker.Status.Changed += BrokerStatusChanged; m_statusService = SledServiceInstance.TryGet <IStatusService>(); m_gotoService = SledServiceInstance.Get <ISledGotoService>(); var projectService = SledServiceInstance.Get <ISledProjectService>(); projectService.Created += ProjectServiceCreated; projectService.Opened += ProjectServiceOpened; projectService.FileOpened += ProjectServiceFileOpened; projectService.FileClosing += ProjectServiceFileClosing; projectService.Closed += ProjectServiceClosed; m_documentService = SledServiceInstance.Get <ISledDocumentService>(); // Register the toolbar menu var menuInfo = new MenuInfo(Menu.LuaIntellisense, "Lua Intelliense", "Lua Intelliense Menu"); m_commandService.RegisterMenu(menuInfo); // Register the commands m_commandService.RegisterCommand( Command.GotoDefinition, Menu.LuaIntellisense, null, "Goto &Definition", "Jumps to the definition of the selected variable", Atf.Input.Keys.Alt | Atf.Input.Keys.G, null, CommandVisibility.Menu, this); m_commandService.RegisterCommand( Command.GotoReference, Menu.LuaIntellisense, null, "Goto &References", "Jumps to the references of the selected variable", Atf.Input.Keys.Alt | Atf.Input.Keys.R, null, CommandVisibility.Menu, this); //m_commandService.RegisterCommand( // Command.RenameVariable, // Menu.LuaIntellisense, // Group.LuaIntellisense, // "Rename variable", // "Renames selected variable", // Atf.Input.Keys.Shift | Atf.Input.Keys.Alt | Atf.Input.Keys.R, // null, // CommandVisibility.Menu, // this); m_commandService.RegisterCommand( Command.MoveToPreviousPosition, Menu.LuaIntellisense, Group.LuaIntellisense, "&Previous visited location", "Moves the caret to the previous visited location", Atf.Input.Keys.Alt | Atf.Input.Keys.Left, null, CommandVisibility.Menu, this); m_commandService.RegisterCommand( Command.MoveToNextPosition, Menu.LuaIntellisense, Group.LuaIntellisense, "&Next visited location", "Moves the caret to the next visited location", Atf.Input.Keys.Alt | Atf.Input.Keys.Right, null, CommandVisibility.Menu, this); }
public IEnumerable <object> GetCommands(object context, object target) { m_selection.Clear(); var clicked = target.As <ISledLuaVarBaseType>(); if (clicked == null) { return(s_emptyCommands); } { var registry = SledServiceInstance.TryGet <IContextRegistry>(); if (registry != null) { // Check if a GUI editor is the active context var editor = registry.ActiveContext.As <SledTreeListViewEditor>(); if (editor != null) { // Add selection from editor to saved selection foreach (var item in editor.Selection) { if (item.Is <ISledLuaVarBaseType>()) { m_selection.Add(item.As <ISledLuaVarBaseType>()); } } } } } // Add clicked item to selection if (!m_selection.Contains(clicked)) { m_selection.Add(clicked); } // // Check what commands can be issued // var lstCommands = new List <object>(); // If only one item we can jump to it if (m_selection.Count == 1) { lstCommands.Add(Command.Goto); } var bWatchGui = clicked.DomNode.GetRoot().Type == SledLuaSchema.SledLuaVarWatchListType.Type; if (bWatchGui) { lstCommands.Add(Command.RemoveWatch); } else { // Check if there are any items in the // selection that aren't being watched var bAnyItemsNotWatched = m_selection.Any( luaVar => !m_luaWatchedVariableService.IsLuaVarWatched(luaVar)); if (bAnyItemsNotWatched) { lstCommands.Add(Command.AddWatch); } } lstCommands.Add(StandardCommand.EditCopy); lstCommands.Add(Command.CopyName); lstCommands.Add(Command.CopyValue); return(lstCommands); }