Skip to content

Commit 3181b06

Browse files
committed
app names constants
1 parent acdaf40 commit 3181b06

File tree

17 files changed

+52
-59
lines changed

17 files changed

+52
-59
lines changed

ide-common/src/main/kotlin/org/digma/intellij/plugin/docker/LocalInstallationFacade.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ class LocalInstallationFacade {
131131
return operationInProgress.get() == OP.INSTALL
132132
}
133133

134+
fun isAnyOperationRunning(): Boolean {
135+
return operationInProgress.get() != null
136+
}
137+
134138

135139
fun isLocalEngineInstalled(): Boolean {
136140
if (operationInProgress.get() == OP.INSTALL) {

src/main/java/org/digma/intellij/plugin/dashboard/DashboardConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
public interface DashboardConstants {
44

5+
String DASHBOARD_APP_NAME = "Dashboard";
56
String DASHBOARD_DOMAIN_NAME = "dashboard";
67
String DASHBOARD_SCHEMA = "http";
78
String DASHBOARD_RESOURCE_FOLDER_NAME = "dashboard";

src/main/java/org/digma/intellij/plugin/dashboard/DashboardFileEditor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import javax.swing.*;
1414
import java.beans.PropertyChangeListener;
1515

16+
import static org.digma.intellij.plugin.dashboard.DashboardConstants.DASHBOARD_APP_NAME;
1617
import static org.digma.intellij.plugin.ui.jcef.JBcefBrowserPropertiesKt.JCEF_DASHBOARD_FILE_PROPERTY_NAME;
1718

1819
public class DashboardFileEditor extends UserDataHolderBase implements FileEditor {
@@ -28,15 +29,15 @@ public DashboardFileEditor(Project project, DashboardVirtualFile file) {
2829
this.file = file;
2930
jCefComponent = createJcefComponent(project, file);
3031
if (jCefComponent != null) {
31-
ApplicationManager.getApplication().getService(ReloadObserver.class).register(project, "Dashboard." + file.getName(), jCefComponent.getComponent(), this);
32+
ApplicationManager.getApplication().getService(ReloadObserver.class).register(project, DASHBOARD_APP_NAME + "." + file.getName(), jCefComponent.getComponent(), this);
3233
}
3334
}
3435

3536
@Nullable
3637
private JCefComponent createJcefComponent(Project project, DashboardVirtualFile file) {
3738

3839
if (JBCefApp.isSupported()) {
39-
return new JCefComponent.JCefComponentBuilder(project, "Dashboard", this,
40+
return new JCefComponent.JCefComponentBuilder(project, DASHBOARD_APP_NAME, this,
4041
DashboardConstants.DASHBOARD_URL,
4142
new DashboardMessageRouterHandler(project))
4243
.withArg(JCEF_DASHBOARD_FILE_PROPERTY_NAME, file)

src/main/java/org/digma/intellij/plugin/documentation/DocumentationConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
public interface DocumentationConstants {
44

5+
String DOCUMENTATION_APP_NAME = "Documentation";
56
String DOCUMENTATION_DOMAIN_NAME = "documentation";
67
String DOCUMENTATION_SCHEMA = "http";
78
String DOCUMENTATION_RESOURCE_FOLDER_NAME = "documentation";

src/main/java/org/digma/intellij/plugin/documentation/DocumentationFileEditor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import javax.swing.*;
1414
import java.beans.PropertyChangeListener;
1515

16+
import static org.digma.intellij.plugin.documentation.DocumentationConstants.DOCUMENTATION_APP_NAME;
1617
import static org.digma.intellij.plugin.ui.jcef.JBcefBrowserPropertiesKt.JCEF_DOCUMENTATION_FILE_PROPERTY_NAME;
1718

1819
public class DocumentationFileEditor extends UserDataHolderBase implements FileEditor {
@@ -28,18 +29,18 @@ public DocumentationFileEditor(Project project, DocumentationVirtualFile file) {
2829
this.file = file;
2930
jCefComponent = createJcefComponent(project, file);
3031
if (jCefComponent != null) {
31-
ApplicationManager.getApplication().getService(ReloadObserver.class).register(project, "Documentation." + file.getName(), jCefComponent.getComponent(), this);
32+
ApplicationManager.getApplication().getService(ReloadObserver.class).register(project, DOCUMENTATION_APP_NAME + "." + file.getName(), jCefComponent.getComponent(), this);
3233
}
3334
}
3435

3536
@Nullable
3637
private JCefComponent createJcefComponent(Project project, DocumentationVirtualFile file) {
3738

3839
if (JBCefApp.isSupported()) {
39-
return new JCefComponent.JCefComponentBuilder(project, "Documentation", this,
40+
return new JCefComponent.JCefComponentBuilder(project, DOCUMENTATION_APP_NAME, this,
4041
DocumentationConstants.DOCUMENTATION_URL,
4142
new DocumentationMessageRouterHandler(project))
42-
.withArg(JCEF_DOCUMENTATION_FILE_PROPERTY_NAME,file)
43+
.withArg(JCEF_DOCUMENTATION_FILE_PROPERTY_NAME, file)
4344
.withDownloadAdapter(new DownloadHandlerAdapter())
4445
.build();
4546

src/main/java/org/digma/intellij/plugin/jaegerui/JaegerUIConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
public interface JaegerUIConstants {
44

5+
String JAEGER_UI_APP_NAME = "JaegerUI";
56
String JAEGER_UI_DOMAIN_NAME = "jaegerui";
67
String JAEGER_UI_SCHEMA = "http";
78
String JAEGER_UI_RESOURCE_FOLDER_NAME = "jaeger-ui";

src/main/java/org/digma/intellij/plugin/jaegerui/JaegerUIFileEditor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import javax.swing.*;
1414
import java.beans.PropertyChangeListener;
1515

16+
import static org.digma.intellij.plugin.jaegerui.JaegerUIConstants.JAEGER_UI_APP_NAME;
1617
import static org.digma.intellij.plugin.ui.jcef.JBcefBrowserPropertiesKt.JCEF_JAEGER_UI_FILE_PROPERTY_NAME;
1718

1819
public class JaegerUIFileEditor extends UserDataHolderBase implements FileEditor {
@@ -28,15 +29,15 @@ public JaegerUIFileEditor(Project project, JaegerUIVirtualFile file) {
2829
this.file = file;
2930
jCefComponent = createJcefComponent(project, file);
3031
if (jCefComponent != null) {
31-
ApplicationManager.getApplication().getService(ReloadObserver.class).register(project, "JaegerUI." + file.getName(), jCefComponent.getComponent(), this);
32+
ApplicationManager.getApplication().getService(ReloadObserver.class).register(project, JAEGER_UI_APP_NAME + "." + file.getName(), jCefComponent.getComponent(), this);
3233
}
3334
}
3435

3536
@Nullable
3637
private JCefComponent createJcefComponent(Project project, JaegerUIVirtualFile file) {
3738

3839
if (JBCefApp.isSupported()) {
39-
return new JCefComponent.JCefComponentBuilder(project, "JaegerUI", this,
40+
return new JCefComponent.JCefComponentBuilder(project, JAEGER_UI_APP_NAME, this,
4041
JaegerUIConstants.JAEGER_UI_URL,
4142
new JaegerUIMessageRouterHandler(project))
4243
.withArg(JCEF_JAEGER_UI_FILE_PROPERTY_NAME, file)

src/main/kotlin/org/digma/intellij/plugin/ui/jcef/JCefComponent.kt

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ import org.digma.intellij.plugin.ui.jcef.state.StateChangedEvent
4848
import org.digma.intellij.plugin.ui.settings.ApplicationUISettingsChangeNotifier
4949
import org.digma.intellij.plugin.ui.settings.SettingsChangeListener
5050
import org.digma.intellij.plugin.ui.settings.Theme
51+
import org.digma.intellij.plugin.ui.wizard.INSTALLATION_WIZARD_APP_NAME
5152
import java.lang.ref.WeakReference
5253
import java.util.Objects
5354
import java.util.WeakHashMap
5455
import java.util.concurrent.atomic.AtomicBoolean
5556
import java.util.concurrent.locks.ReentrantLock
56-
import java.util.function.Supplier
5757
import javax.swing.JComponent
5858

5959

@@ -65,8 +65,6 @@ private constructor(
6565
val jbCefBrowser: JBCefBrowser
6666
) : Disposable {
6767

68-
private var isLocalEngineOperationRunningProvider: Supplier<Boolean>? = null
69-
7068
private val logger: Logger = Logger.getInstance(JCefComponent::class.java)
7169

7270
init {
@@ -165,17 +163,24 @@ private constructor(
165163
project.messageBus.connect(parentDisposable).subscribe(
166164
AnalyticsServiceConnectionEvent.ANALYTICS_SERVICE_CONNECTION_EVENT_TOPIC, object : AnalyticsServiceConnectionEvent {
167165

166+
167+
168+
private fun shouldUpdateEngineStatus(): Boolean {
169+
//in installation wizard there is no need to update the status on connection lost if there is any engine operation
170+
// running (like install,stop,start,remove) because it may confuse the UI.
171+
//the installation wizard app will be updated when the operation is completed.
172+
//for other apps it is ok to update the status.
173+
return !(name == INSTALLATION_WIZARD_APP_NAME && service<LocalInstallationFacade>().isAnyOperationRunning())
174+
}
175+
176+
168177
override fun connectionLost() {
169178
//delay before reporting digma status to let all containers go down
170179
connectionEventAlarm.cancelAllRequests()
171180
connectionEventAlarm.addRequest({
172181
try {
173182

174-
//if there is local engine operation running, do not update the status.
175-
//isLocalEngineOperationRunningProvider is provided only by installation wizard, it's not relevant for other apps.
176-
//while the installation wizard is installing or stopping or starting the engine, it's better not to update the ui
177-
// on connection lost
178-
if (isLocalEngineOperationRunningProvider == null || isLocalEngineOperationRunningProvider?.get() == false) {
183+
if (shouldUpdateEngineStatus()) {
179184
val status = service<LocalInstallationFacade>().getCurrentDigmaInstallationStatusOnConnectionLost()
180185
updateDigmaEngineStatus(jbCefBrowser.cefBrowser, status)
181186
}
@@ -194,11 +199,7 @@ private constructor(
194199
try {
195200
sendBackendAboutInfo(jbCefBrowser.cefBrowser, project)
196201

197-
//if there is local engine operation running, do not update the status.
198-
//isLocalEngineOperationRunningProvider is provided only by installation wizard, it's not relevant for other apps.
199-
//while the installation wizard is installing or stopping or starting the engine, it's better not to update the ui
200-
// on connection gained
201-
if (isLocalEngineOperationRunningProvider == null || isLocalEngineOperationRunningProvider?.get() == false) {
202+
if (shouldUpdateEngineStatus()) {
202203
val status = service<LocalInstallationFacade>().getCurrentDigmaInstallationStatusOnConnectionGained()
203204
updateDigmaEngineStatus(jbCefBrowser.cefBrowser, status)
204205
}
@@ -390,10 +391,6 @@ private constructor(
390391
return jbCefBrowser.component
391392
}
392393

393-
fun setLocalEngineOperationRunningProvider(supplier: Supplier<Boolean>) {
394-
this.isLocalEngineOperationRunningProvider = supplier
395-
}
396-
397394

398395
//must provide a parentDisposable that is not the project.
399396
//instances of JCefComponentBuilder need to be local to a function, so they can be garbage collected

src/main/kotlin/org/digma/intellij/plugin/ui/mainapp/MainAppConstants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.digma.intellij.plugin.ui.mainapp
22

3+
const val MAIN_APP_APP_NAME = "Main"
34
const val MAIN_APP_DOMAIN_NAME = "main"
45
const val MAIN_APP_SCHEMA = "https"
56
const val MAIN_APP_RESOURCE_FOLDER_NAME = "main" //folder in ui zip bundle

src/main/kotlin/org/digma/intellij/plugin/ui/mainapp/MainAppPanel.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import com.intellij.ui.jcef.JBCefApp
77
import com.intellij.util.ui.JBUI
88
import org.digma.intellij.plugin.reload.ReloadObserver
99
import org.digma.intellij.plugin.reload.ReloadService
10+
import org.digma.intellij.plugin.reload.ReloadableJCefContainer
1011
import org.digma.intellij.plugin.ui.insights.InsightsService
1112
import org.digma.intellij.plugin.ui.jcef.DownloadHandlerAdapter
1213
import org.digma.intellij.plugin.ui.jcef.JCefComponent
1314
import org.digma.intellij.plugin.ui.list.listBackground
1415
import org.digma.intellij.plugin.ui.navigation.CodeButtonCaretContextService
1516
import org.digma.intellij.plugin.ui.navigation.NavigationService
1617
import org.digma.intellij.plugin.ui.panels.DisposablePanel
17-
import org.digma.intellij.plugin.reload.ReloadableJCefContainer
1818
import org.digma.intellij.plugin.ui.tests.TestsUpdater
1919
import java.awt.BorderLayout
2020
import java.awt.Insets
@@ -31,7 +31,7 @@ class MainAppPanel(private val project: Project) : DisposablePanel(), Reloadable
3131
jCefComponent = build()
3232
jCefComponent?.let {
3333
service<ReloadService>().register(this, parentDisposable)
34-
service<ReloadObserver>().register(project, "MainApp", it.getComponent(), parentDisposable)
34+
service<ReloadObserver>().register(project, MAIN_APP_APP_NAME, it.getComponent(), parentDisposable)
3535
}
3636
Disposer.register(MainAppService.getInstance(project)) {
3737
dispose()
@@ -69,7 +69,7 @@ class MainAppPanel(private val project: Project) : DisposablePanel(), Reloadable
6969
jCefComponent = build()
7070
jCefComponent?.let {
7171
service<ReloadService>().register(this, parentDisposable)
72-
service<ReloadObserver>().register(project, "MainApp", it.getComponent(), parentDisposable)
72+
service<ReloadObserver>().register(project, MAIN_APP_APP_NAME, it.getComponent(), parentDisposable)
7373
}
7474
}
7575

@@ -81,7 +81,7 @@ class MainAppPanel(private val project: Project) : DisposablePanel(), Reloadable
8181
private fun createJcefComponent(): JCefComponent? {
8282
return if (JBCefApp.isSupported()) {
8383
JCefComponent.JCefComponentBuilder(
84-
project, "Main", parentDisposable,
84+
project, MAIN_APP_APP_NAME, parentDisposable,
8585
MAIN_APP_URL,
8686
MainAppMessageRouterHandler(project)
8787
)

0 commit comments

Comments
 (0)