public void Open(Lifetime lifetime, IShellLocks shellLocks, ChangeManager changeManager, ISolution solution, DocumentManager documentManager, IActionManager actionManager, ICommandProcessor commandProcessor, TextControlChangeUnitFactory changeUnitFactory, JetPopupMenus jetPopupMenus) { Debug.Assert(!IsOpened); _solution = solution; DocumentManager = documentManager; _jetPopupMenus = jetPopupMenus; changeManager.Changed2.Advise(lifetime, Handler); lifetime.AddAction(Close); var expandAction = actionManager.Defs.TryGetActionDefById(GotoDeclarationAction.ACTION_ID); if (expandAction != null) { var postfixHandler = new GotoDeclarationHandler(lifetime, shellLocks, commandProcessor, changeUnitFactory, this); lifetime.AddBracket( FOpening: () => actionManager.Handlers.AddHandler(expandAction, postfixHandler), FClosing: () => actionManager.Handlers.RemoveHandler(expandAction, postfixHandler)); } var findUsagesAction = actionManager.Defs.GetActionDef<FindUsagesAction>(); var findUsagesHandler = new FindUsagesHandler(lifetime, shellLocks, commandProcessor, changeUnitFactory, this); lifetime.AddBracket( FOpening: () => actionManager.Handlers.AddHandler(findUsagesAction, findUsagesHandler), FClosing: () => actionManager.Handlers.RemoveHandler(findUsagesAction, findUsagesHandler)); }
protected BasePopupWindow(LifetimeDefinition lifetimeDefinition, IPopupWindowContext context, PopupWindowMutex mutex, HideFlags hideFlags) { this.lifetimeDefinition = lifetimeDefinition; lifetime = lifetimeDefinition.Lifetime; Context = context; Mutex = mutex; HideMethod = FormHideMethod.Visibility; this.hideFlags = hideFlags; lifetime.AddAction(() => { if (!Visible) { CloseWindowCore(); return; } EventHandler handle = null; handle = (sender, args) => { CloseWindowCore(); Closed -= handle; }; Closed += handle; HideWindow(); }); }
public SolutionStateNotifier([NotNull] Lifetime lifetime, [NotNull] ISolution solution, [NotNull] ISolutionLoadTasksScheduler scheduler, [NotNull] SolutionStateTracker solutionStateTracker) { if (lifetime == null) { throw new ArgumentNullException("lifetime"); } if (solution == null) { throw new ArgumentNullException("solution"); } if (scheduler == null) { throw new ArgumentNullException("scheduler"); } if (solutionStateTracker == null) { throw new ArgumentNullException("solutionStateTracker"); } scheduler.EnqueueTask(new SolutionLoadTask("SolutionStateTracker", SolutionLoadTaskKinds.Done, () => solutionStateTracker.HandleSolutionOpened(solution))); lifetime.AddAction(solutionStateTracker.HandleSolutionClosed); }
internal T4PsiModule([NotNull] Lifetime lifetime, [NotNull] IPsiModules psiModules, [NotNull] DocumentManager documentManager, [NotNull] ChangeManager changeManager, [NotNull] IAssemblyFactory assemblyFactory, [NotNull] IShellLocks shellLocks, [NotNull] IProjectFile projectFile, [NotNull] T4FileDataCache fileDataCache, [NotNull] T4Environment t4Environment, [NotNull] OutputAssemblies outputAssemblies) { _lifetime = lifetime; lifetime.AddAction(Dispose); _psiModules = psiModules; _assemblyFactory = assemblyFactory; _changeManager = changeManager; _shellLocks = shellLocks; _projectFile = projectFile; IProject project = projectFile.GetProject(); Assertion.AssertNotNull(project, "project != null"); _project = project; _solution = project.GetSolution(); changeManager.RegisterChangeProvider(lifetime, this); changeManager.AddDependency(lifetime, psiModules, this); _t4Environment = t4Environment; _outputAssemblies = outputAssemblies; _resolveProject = new T4ResolveProject(lifetime, _solution, _shellLocks, t4Environment.PlatformID, project); _sourceFile = CreateSourceFile(projectFile, documentManager); _isValid = true; fileDataCache.FileDataChanged.Advise(lifetime, OnDataFileChanged); AddBaseReferences(); }
public CommandMap(Lifetime lifetime, IInjector injector) { _map = new Dictionary <Type, Container>(); _lifetime = lifetime; _injector = new Injector(injector); _lifetime.AddAction(((IDisposable)_injector).Dispose); }
public void Open(Lifetime lifetime, IShellLocks shellLocks, ChangeManager changeManager, ISolution solution, DocumentManager documentManager, IActionManager actionManager, ICommandProcessor commandProcessor, TextControlChangeUnitFactory changeUnitFactory, JetPopupMenus jetPopupMenus) { Debug.Assert(!IsOpened); _solution = solution; DocumentManager = documentManager; _jetPopupMenus = jetPopupMenus; changeManager.Changed2.Advise(lifetime, Handler); lifetime.AddAction(Close); var expandAction = actionManager.Defs.TryGetActionDefById(GotoDeclarationAction.ACTION_ID); if (expandAction != null) { var postfixHandler = new GotoDeclarationHandler(lifetime, shellLocks, commandProcessor, changeUnitFactory, this); lifetime.AddBracket( FOpening: () => actionManager.Handlers.AddHandler(expandAction, postfixHandler), FClosing: () => actionManager.Handlers.RemoveHandler(expandAction, postfixHandler)); } var findUsagesAction = actionManager.Defs.GetActionDef <FindUsagesAction>(); var findUsagesHandler = new FindUsagesHandler(lifetime, shellLocks, commandProcessor, changeUnitFactory, this); lifetime.AddBracket( FOpening: () => actionManager.Handlers.AddHandler(findUsagesAction, findUsagesHandler), FClosing: () => actionManager.Handlers.RemoveHandler(findUsagesAction, findUsagesHandler)); }
public CheckTimer(Lifetime lifetime) { OnCheckPass = new Signal <bool>(lifetime, "CheckTimer.OnTimer"); var timer = new Timer(TimerCallback, null, 0, 100); lifetime.AddAction(() => timer.Dispose()); }
public SolutionStateNotifier([NotNull] Lifetime lifetime, [NotNull] ISolution solution, [NotNull] ISolutionLoadTasksScheduler scheduler, [NotNull] SolutionStateTracker solutionStateTracker, [NotNull] IPsiServices psiServices) { if (lifetime == null) { throw new ArgumentNullException("lifetime"); } if (solution == null) { throw new ArgumentNullException("solution"); } if (scheduler == null) { throw new ArgumentNullException("scheduler"); } if (solutionStateTracker == null) { throw new ArgumentNullException("solutionStateTracker"); } scheduler.EnqueueTask(new SolutionLoadTask("SolutionStateTracker", SolutionLoadTaskKinds.SolutionContainer, () => solutionStateTracker.HandleSolutionContainerCreated(solution))); scheduler.EnqueueTask(new SolutionLoadTask("SolutionStateTracker", SolutionLoadTaskKinds.Done, () => solutionStateTracker.HandleSolutionOpened(solution))); scheduler.EnqueueTask(new SolutionLoadTask("SolutionStateTracker", SolutionLoadTaskKinds.AfterDone, () => psiServices.CachesState.IsIdle.WhenTrueOnce(lifetime, () => solutionStateTracker.HandlePsiLoaded(solution)))); lifetime.AddAction(solutionStateTracker.HandleSolutionClosed); }
public IDEStateEventGenerator(IRSEnv env, IMessageBus messageBus, Lifetime lifetime, IDateUtils dateUtils, IEventLogger logger, IThreading threading) : base(env, messageBus, dateUtils, threading) { _env = env; _logger = logger; FireIDEStateEvent(IDELifecyclePhase.Startup); lifetime.AddAction(FireShutdownEvent); }
public GotoWordController( [NotNull] Lifetime lifetime, [NotNull] IShellLocks locks, [NotNull] IProjectModelElement projectElement, [CanBeNull] ITextControl textControl) : base(lifetime, new GotoByNameModel(lifetime), locks) { myLocks = locks; myTextControl = textControl; myProjectElement = projectElement; var projectFile = projectElement as IProjectFile; if (projectFile != null) { myCurrentFile = projectFile.ToSourceFile(); } lifetime.AddAction(DropHighlightings); SelectedItem = new Property <object>(lifetime, "SelectedItem"); SelectedItem.Change.Advise(lifetime, x => { if (x.HasNew) { var localOccurrence = x.New as LocalOccurrence; if (localOccurrence != null) { if (textControl != null) { //var textControlPosRange = textControl.Scrolling.ViewportRange.Value; //GC.KeepAlive(textControlPosRange); myLocks.QueueReadLock("Aa", () => { // todo: merge with highlighting updater? var target = textControl.Coords.FromDocLineColumn( new DocumentCoords((Int32 <DocLine>)(Math.Max(localOccurrence.LineNumber - 2, 0)), (Int32 <DocColumn>) 0)); textControl.Scrolling.ScrollTo(target, TextControlScrollType.TopOfView); }); if (myLocal != null) { UpdateLocalHighlightings(textControl.Document, myLocal); } } } } }); InitializeModel(lifetime, Model); }
public TaskViewModel(ITaskRepository repository, Lifetime lifetime, IIconsSettingsRepository settingsRepository, TaskEventGenerator generator = null) { if (generator != null) { TaskChange += generator.FireTaskEvent; } _settingsRepository = settingsRepository; IconsSettings = _settingsRepository.Settings; IconsSettings.PropertyChanged += OnSettingsChanged; Lifetime = lifetime; Lifetime.AddAction(OnLifetimeTerminate); _repository = repository; _repository.PropertyChanged += OnRepositoryChanged; OnRepositoryChanged(null, null); SetActiveTask(); }
public SettingsView(Lifetime lifetime, OptionsSettingsSmartContext settings) { Id = Pid; InitializeComponent(); _lifetime = lifetime; _settings = settings; settings.SetBinding(lifetime, (ExceptionalSettings x) => x.DelegateInvocationsMayThrowExceptions, DelegateInvocationsMayThrowExceptions, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.IsDocumentationOfExceptionSubtypeSufficientForThrowStatements, IsDocumentationOfExceptionSubtypeSufficientForThrowStatements, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions, IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.InspectPublicMethods, InspectPublicMethods, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.InspectInternalMethods, InspectInternalMethods, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.InspectProtectedMethods, InspectProtectedMethods, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.InspectPrivateMethods, InspectPrivateMethods, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.OptionalExceptions2, OptionalExceptions, TextBox.TextProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.UseDefaultOptionalExceptions2, UseOptionalExceptionsDefaults, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.OptionalMethodExceptions2, OptionalMethodExceptions, TextBox.TextProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.UseDefaultOptionalMethodExceptions2, UseOptionalMethodExceptionsDefaults, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.AccessorOverrides2, AccessorOverrides, TextBox.TextProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.UseDefaultAccessorOverrides2, UseDefaultAccessorOverrides, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); //settings.Changed.Advise(lifetime, delegate { Dispatcher.BeginInvoke((Action)(UpdateTextFields)); }); lifetime.AddAction(delegate { // TODO: Force rescan of all documents if settings have changed }); }
public LocalOccurrencesHighlighter([NotNull] Lifetime lifetime, [NotNull] IShellLocks shellLocks, [NotNull] ITextControl textControl, [NotNull] IDocumentMarkupManager markupManager) { myLifetime = lifetime; myShellLocks = shellLocks; myMarkupManager = markupManager; myTextControl = textControl; mySequentialOccurrences = new SequentialLifetimes(lifetime); mySequentialFocused = new SequentialLifetimes(lifetime); myTextControlViewportRect = textControl.Scrolling.ViewportRect.Value; mySyncRoot = new object(); myLifetime.AddAction(DropHighlightings); }
public SettingsView(Lifetime lifetime, OptionsSettingsSmartContext settings) { InitializeComponent(); _lifetime = lifetime; _settings = settings; settings.SetBinding(lifetime, (ExceptionalSettings x) => x.DelegateInvocationsMayThrowExceptions, DelegateInvocationsMayThrowExceptions, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.IsDocumentationOfExceptionSubtypeSufficientForThrowStatements, IsDocumentationOfExceptionSubtypeSufficientForThrowStatements, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions, IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.InspectPublicMethods, InspectPublicMethods, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.InspectInternalMethods, InspectInternalMethods, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.InspectProtectedMethods, InspectProtectedMethods, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.InspectPrivateMethods, InspectPrivateMethods, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.OptionalExceptions2, OptionalExceptions, TextBox.TextProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.UseDefaultOptionalExceptions2, UseOptionalExceptionsDefaults, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.OptionalMethodExceptions2, OptionalMethodExceptions, TextBox.TextProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.UseDefaultOptionalMethodExceptions2, UseOptionalMethodExceptionsDefaults, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.AccessorOverrides2, AccessorOverrides, TextBox.TextProperty); settings.SetBinding(lifetime, (ExceptionalSettings x) => x.UseDefaultAccessorOverrides2, UseDefaultAccessorOverrides, CheckBoxDisabledNoCheck2.IsCheckedLogicallyDependencyProperty); //settings.Changed.Advise(lifetime, delegate { Dispatcher.BeginInvoke((Action)(UpdateTextFields)); }); lifetime.AddAction(delegate { // TODO: Force rescan of all documents if settings have changed }); }
public void Play(Lifetime lifetime, string animation) { // Stop the current, potentially looping animation, and any other // (potentially looping) animations in the queue before playing ours StopAllAnimations(); var request = Character.Play(animation); RegisterRequest(request); lifetime.AddAction(() => { var requestStatus = (RequestStatus)request.Status; if (requestStatus == RequestStatus.Pending || requestStatus == RequestStatus.InProgress) { Stop(request); Play("Idle1_1"); } }); }
public Agent(Lifetime lifetime, AgentManager agentManager) { character = JetBrains.Util.Lazy.Lazy.Of(() => { agentManager.Initialise(); var agentCharacter = agentManager.GetAgent("Clippit"); agentCharacter.AgentClicked.FlowInto(lifetime, AgentClicked); agentCharacter.ButtonClicked.FlowInto(lifetime, ButtonClicked); agentCharacter.BalloonOptionClicked.FlowInto(lifetime, BalloonOptionClicked); lifetime.AddAction(() => agentManager.UnloadAgent(agentCharacter)); return(agentCharacter); }); AgentClicked = new SimpleSignal(lifetime, "Agent::AgentClicked"); ButtonClicked = new Signal <string>(lifetime, "Agent::ButtonClicked"); BalloonOptionClicked = new Signal <object>(lifetime, "Agent::BalloonOptionClicked"); }
public TripleGoToEverythingActionHandler([NotNull] IActionManager actionManager, Lifetime lifetime) { myActionManager = actionManager; const string gotoTypeActionId = "GotoType"; #if RESHARPER8 || RESHARPER81 var gotoTypeAction = actionManager.TryGetAction(gotoTypeActionId) as IUpdatableAction; if (gotoTypeAction != null) { gotoTypeAction.AddHandler(lifetime, this); } #elif RESHARPER9 var gotoTypeAction = actionManager.Defs.TryGetActionDefById(gotoTypeActionId); if (gotoTypeAction != null) { lifetime.AddAction(() => actionManager.Handlers.RemoveHandler(gotoTypeAction, this)); actionManager.Handlers.AddHandler(gotoTypeAction, this); } #endif }
private void EnableShortcuts(Lifetime enabledLifetime) { var popupWindowLifetimeDefinition = Lifetimes.Define(enabledLifetime, "PresentationAssistant::PopupWindow"); var window = new PresentationAssistantWindow(); window.Owner = mainWindow.MainWpfWindow.Value; theming.PopulateResourceDictionary(popupWindowLifetimeDefinition.Lifetime, window.Resources); var popupWindow = new FadingWpfPopupWindow(popupWindowLifetimeDefinition, context, context.Mutex, popupWindowManager, window, opacity: 0.8); var visibilityLifetimes = new SequentialLifetimes(popupWindowLifetimeDefinition.Lifetime); showAction = shortcut => { window.SetShortcut(shortcut); popupWindow.ShowWindow(); visibilityLifetimes.DefineNext((visibleLifetimeDefinition, visibleLifetime) => { // Hide the window after a timespan, and queue it on the visible sequential lifetime so // that the timer is cancelled when we want to show a new shortcut. Don't hide the window // by attaching it to the sequential lifetime, as that will cause the window to hide when // we need to show a new shortcut. But, make sure we do terminate the lifetime so that // the topmost timer hack is stopped when this window is not visible threading.TimedActions.Queue(visibleLifetime, "PresentationAssistantWindow::HideWindow", () => popupWindow.HideWindow(), VisibleTimeSpan, TimedActionsHost.Recurrence.OneTime, Rgc.Invariant); }); }; enabledLifetime.AddAction(() => { showAction = _ => { }; }); }
protected void AttachEvents(PopupWindowManager popupWindowManager) { lifetime.AddAction(DetachEvents); var context = Context; if (context != null) { lifetime.AddBracket(() => Layouter = context.CreateLayouter(lifetime), () => Layouter = null); Layouter?.Layout.Change.Advise_HasNew(lifetime, OnLayouterResultChanged); context.AnyOtherAction += OnContextOwnerAnyActionPerformed; context.Scroll += OnContextOwnerScroll; context.SelectionChanged += OnContextOwnerSelectionChanged; context.Deactivated += OnContextOwnerDeactivated; context.EscapePressed += OnContextOwnerEscapePressed; } AttachWindowEvents(); popupWindowManager?.PopupWindows.Add(lifetime, this); }
public void Patch([NotNull] Lifetime lifetime, [NotNull] IActionBar actionBar) { if (actionBar.ActionGroup.ActionId == TodoExplorerActionBarActionGroup.ID) { _separator = actionBar.InjectSeparator(int.MaxValue); _label = actionBar.InjectLabel(int.MaxValue, "Updating...", lifetime); _label.NotNull().MouseDoubleClick += Label_MouseDoubleClick; lifetime.AddAction(() => { _label.NotNull().MouseDoubleClick -= Label_MouseDoubleClick; _label = null; _separator = null; }); #if !RS20172 _separator = actionBar.InjectSeparator(int.MaxValue); #endif _shellLocks.Tasks.Queue(lifetime, () => UpdateRequestSignal.Fire(), TaskPriority.BelowNormal); } }
internal T4PsiModule([NotNull] Lifetime lifetime, [NotNull] PsiModuleManager psiModuleManager, [NotNull] DocumentManager documentManager, [NotNull] ChangeManager changeManager, [NotNull] IAssemblyFactory assemblyFactory, [NotNull] IShellLocks shellLocks, [NotNull] IProjectFile projectFile, [NotNull] T4FileDataCache fileDataCache, [NotNull] T4Environment t4Environment, [NotNull] OutputAssembliesCache outputAssembliesCache) { _lifetime = lifetime; lifetime.AddAction(Dispose); _psiModuleManager = psiModuleManager; _documentManager = documentManager; _assemblyFactory = assemblyFactory; _changeManager = changeManager; changeManager.RegisterChangeProvider(lifetime, this); changeManager.AddDependency(lifetime, psiModuleManager, this); _shellLocks = shellLocks; _projectFile = projectFile; _project = projectFile.GetProject(); Assertion.AssertNotNull(_project, "_project != null"); _solution = _project.GetSolution(); _t4Environment = t4Environment; _outputAssembliesCache = outputAssembliesCache; _resolveProject = new T4ResolveProject(_solution, _shellLocks, t4Environment.PlatformID, _project); _sourceFile = new PsiProjectFile( this, _projectFile, (pf, sf) => new DefaultPsiProjectFileProperties(pf, sf), JetFunc <IProjectFile, IPsiSourceFile> .True, _documentManager); _isValid = true; fileDataCache.FileDataChanged.Advise(lifetime, OnDataFileChanged); AddBaseReferences(); }
public DelegatingFileSystemShim(Lifetime lifetime) { myFileSystem = Shim.FileSystem; Shim.FileSystem = this; lifetime.AddAction(() => Shim.FileSystem = myFileSystem); }
private void UnsubscribeOnTerminate() { _myLifetime.AddAction(() => _textControlManager.TextControls.CollectionChanged -= AdviceOnNewControls); }