2424
2525/**
2626 * Controls the current view in digma tool window.
27- * there is a main content, wizard,troubleshooting ,notifications and no connection.
27+ * there is a main content, wizard,troubleshooting and no connection.
2828 * the main content has a no connection empty card and the main card.
2929 * the tool window should have only one content.
3030 * Not handling any exceptions in this class. if an exception is thrown we must know that because it's probably a serious bug.
@@ -60,9 +60,6 @@ public enum MainWindowCard {
6060 private final TroubleshootingComponents troubleshooting = new TroubleshootingComponents ();
6161 private Supplier <DisposablePanel > troubleshootingPanelBuilder ;
6262
63- private final NotificationsComponents notifications = new NotificationsComponents ();
64- private Supplier <DisposablePanel > allNotificationsPanelBuilder ;
65-
6663 private final AtomicBoolean isConnectionLost = new AtomicBoolean (false );
6764
6865
@@ -92,36 +89,30 @@ public void connectionGained() {
9289 (AggressiveUpdateStateChangedEvent ) this ::updateStateChanged );
9390
9491
95- project .getMessageBus ().connect ().subscribe (ApiClientChangedEvent .getAPI_CLIENT_CHANGED_TOPIC (),new ApiClientChangedEvent (){
96-
97- @ Override
98- public void apiClientChanged (@ NotNull String newUrl ) {
99- Backgroundable .ensurePooledThread (() -> {
100- //on new install the wizard opens and lets user install digma backend.
101- //if the user doesn't have docker and wants to change to centralized deployment,
102- // user will change the url in settings, the plugin will connect to the centralized deployment,
103- // but there will be no way out of the wizard because there is no close button and no finish button.
104- //so here we close the wizard in this scenario, the wizard will close and user will see the login screen.
105- //isFirstWizardLaunch will be true on new install, when the wizard opens first time,
106- // the flag will change only when INSTALLATION_WIZARD/FINISH message, so while the wizard is open
107- // isFirstWizardLaunch should be true.
108- //if user had a working local deployment and then decides to change to centralized, if the wizard is open
109- // in that stage the wizard should have a close button.
110- if (wizard .isOn () && PersistenceService .getInstance ().isFirstWizardLaunch ()){
111- if (isCentralized ()){
112- //do here everything that happens on INSTALLATION_WIZARD/FINISH message
113- PersistenceService .getInstance ().firstWizardLaunchDone ();
114- updateInstallationWizardFlag ();
115- EDT .ensureEDT (() -> {
116- ToolWindowShower .getInstance (project ).showToolWindow ();
117- project .getService (RecentActivityToolWindowShower .class ).showToolWindow ();
118- wizardFinished ();
119- });
120- }
121- }
122- });
92+ project .getMessageBus ().connect ().subscribe (ApiClientChangedEvent .getAPI_CLIENT_CHANGED_TOPIC (), (ApiClientChangedEvent ) newUrl -> Backgroundable .ensurePooledThread (() -> {
93+ //on new install the wizard opens and lets user install digma backend.
94+ //if the user doesn't have docker and wants to change to centralized deployment,
95+ // user will change the url in settings, the plugin will connect to the centralized deployment,
96+ // but there will be no way out of the wizard because there is no close button and no finish button.
97+ //so here we close the wizard in this scenario, the wizard will close and user will see the login screen.
98+ //isFirstWizardLaunch will be true on new install, when the wizard opens first time,
99+ // the flag will change only when INSTALLATION_WIZARD/FINISH message, so while the wizard is open
100+ // isFirstWizardLaunch should be true.
101+ //if user had a working local deployment and then decides to change to centralized, if the wizard is open
102+ // in that stage the wizard should have a close button.
103+ if (wizard .isOn () && PersistenceService .getInstance ().isFirstWizardLaunch ()){
104+ if (isCentralized ()){
105+ //do here everything that happens on INSTALLATION_WIZARD/FINISH message
106+ PersistenceService .getInstance ().firstWizardLaunchDone ();
107+ updateInstallationWizardFlag ();
108+ EDT .ensureEDT (() -> {
109+ ToolWindowShower .getInstance (project ).showToolWindow ();
110+ project .getService (RecentActivityToolWindowShower .class ).showToolWindow ();
111+ wizardFinished ();
112+ });
113+ }
123114 }
124- });
115+ })) ;
125116 }
126117
127118
@@ -154,8 +145,7 @@ public void initComponents(@NotNull ToolWindow toolWindow,
154145 @ NotNull Content mainContent ,
155146 @ NotNull JPanel mainCardsPanel ,
156147 @ NotNull Function <Boolean , DisposablePanel > wizardPanelBuilder ,
157- Supplier <DisposablePanel > troubleshootingPanelBuilder ,
158- Supplier <DisposablePanel > allNotificationsPanelBuilder ) {
148+ Supplier <DisposablePanel > troubleshootingPanelBuilder ) {
159149
160150 Log .log (LOGGER ::debug , "initComponents called" );
161151
@@ -171,8 +161,6 @@ public void initComponents(@NotNull ToolWindow toolWindow,
171161
172162 this .troubleshootingPanelBuilder = troubleshootingPanelBuilder ;
173163
174- this .allNotificationsPanelBuilder = allNotificationsPanelBuilder ;
175-
176164 //it may be that there was a connection lost event before the panels were ready.
177165 // in that case show connection lost panel
178166 if (isConnectionLost .get () || BackendConnectionMonitor .getInstance (project ).isConnectionError ()) {
@@ -257,9 +245,6 @@ public void showTroubleshooting() {
257245 if (troubleshootingPanel != null ) {
258246
259247 Content troubleshootingContent = ContentFactory .getInstance ().createContent (troubleshootingPanel , null , false );
260- // if (wizard.isOn()) {
261- // wizardFinished();
262- // }
263248
264249 toolWindow .getContentManager ().removeContent (mainContent , false );
265250 toolWindow .getContentManager ().addContent (troubleshootingContent );
@@ -293,58 +278,6 @@ public void troubleshootingFinished() {
293278 }
294279
295280
296- public void showAllNotifications () {
297- Log .log (LOGGER ::debug , "showAllNotifications called" );
298-
299- //in case showAllNotifications is called while notifications is already on
300- if (notifications .isOn ()) {
301- Log .log (LOGGER ::debug , project , "showAllNotifications was called but notifications on. nothing to do." );
302- return ;
303- }
304-
305- //build the notifications panel every time its necessary and dispose it when the notifications closed.
306- var notificationsPanel = allNotificationsPanelBuilder .get ();
307- if (notificationsPanel != null ) {
308- Content notificationsContent = ContentFactory .getInstance ().createContent (notificationsPanel , null , false );
309- toolWindow .getContentManager ().removeContent (mainContent , false );
310- toolWindow .getContentManager ().addContent (notificationsContent );
311- notifications .notificationsContent = notificationsContent ;
312- notifications .notificationsPanel = notificationsPanel ;
313- } else {
314- Log .log (LOGGER ::debug , project , "showAllNotifications was called but notificationsPanel is null. it may happen if the runtime JVM does not support JCEF" );
315- }
316- }
317-
318-
319- public void closeAllNotificationsIfShowing () {
320- if (notifications .isOn ()) {
321- closeAllNotifications ();
322- }
323- }
324-
325-
326- public void closeAllNotifications () {
327- Log .log (LOGGER ::debug , "closeAllNotifications called" );
328-
329- EDT .ensureEDT (() -> {
330- if (notifications .isOn ()) {
331- toolWindow .getContentManager ().removeContent (notifications .notificationsContent , true );
332- toolWindow .getContentManager ().addContent (mainContent );
333- //dispose the notifications panel which will dispose the jcef browser
334- notifications .notificationsPanel .dispose ();
335- notifications .notificationsContent = null ;
336- notifications .notificationsPanel = null ;
337-
338- } else {
339- Log .log (LOGGER ::debug , project , "closeAllNotifications was called but notifications is not on." );
340- }
341- });
342-
343- }
344-
345-
346-
347-
348281 /**
349282 * it may happen that user clicks a span link while the troubleshooting or wizard are on.
350283 * it can happen if user opens troubleshooting or the wizard and then clicks a link in recent activity,
@@ -366,7 +299,6 @@ public void closeCoveringViewsIfNecessary() {
366299 }
367300 wizardFinished ();
368301 troubleshootingFinished ();
369- closeAllNotificationsIfShowing ();
370302 }
371303
372304 public void showMainPanel () {
@@ -472,13 +404,5 @@ public boolean isOn() {
472404 }
473405 }
474406
475- private static class NotificationsComponents {
476- Content notificationsContent ;
477- DisposablePanel notificationsPanel ;
478-
479- public boolean isOn () {
480- return notificationsContent != null && notificationsPanel != null ;
481- }
482- }
483407
484408}
0 commit comments