generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb35bc1
commit 514bd59
Showing
9 changed files
with
157 additions
and
96 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
ide-common/src/main/java/org/digma/intellij/plugin/analytics/TabsChanged.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.digma.intellij.plugin.analytics; | ||
|
||
import com.intellij.util.messages.Topic; | ||
|
||
public interface TabsChanged { | ||
|
||
@Topic.ProjectLevel | ||
Topic<TabsChanged> TABS_CHANGED_TOPIC = Topic.create("TABS_CHANGED_TOPIC", TabsChanged.class); | ||
|
||
void activeTabIndexChanged(int newTabIndex); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
ide-common/src/main/kotlin/org/digma/intellij/plugin/ui/service/TabsHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.digma.intellij.plugin.ui.service | ||
|
||
import com.intellij.openapi.diagnostic.Logger | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.ui.content.Content | ||
import org.digma.intellij.plugin.analytics.TabsChanged | ||
import org.digma.intellij.plugin.log.Log | ||
|
||
class TabsHelper(val project: Project) { | ||
private val logger: Logger = Logger.getInstance(TabsHelper::class.java) | ||
|
||
var currentTabIndex = 0 | ||
|
||
private var visibleTabBeforeErrorDetails: Int? = null | ||
private var errorDetailsOn = false | ||
|
||
companion object { | ||
const val INSIGHTS_TAB_NAME = "Insights" | ||
const val DEFAULT_ERRORS_TAB_NAME = "Errors" | ||
const val DETAILED_ERRORS_TAB_NAME = "Error Details" | ||
const val SUMMARY_TAB_NAME = "Summary" | ||
|
||
@JvmStatic | ||
fun getInstance(project: Project): TabsHelper { | ||
return project.getService(TabsHelper::class.java) | ||
} | ||
} | ||
|
||
fun isInsightsTab(content: Content?): Boolean { | ||
return content != null && content.tabName.equals(INSIGHTS_TAB_NAME, ignoreCase = true) | ||
} | ||
|
||
fun isErrorsTab(content: Content?): Boolean { | ||
return content != null && content.tabName.equals(DEFAULT_ERRORS_TAB_NAME, ignoreCase = true) | ||
} | ||
|
||
fun isSummaryTab(content: Content?): Boolean { | ||
return content != null && content.tabName.equals(SUMMARY_TAB_NAME, ignoreCase = true) | ||
} | ||
|
||
|
||
fun showingErrorDetails() { | ||
visibleTabBeforeErrorDetails = currentTabIndex | ||
} | ||
|
||
fun errorDetailsClosed() { | ||
visibleTabBeforeErrorDetails?.let { notifyTabChanged(it) } | ||
visibleTabBeforeErrorDetails = null | ||
} | ||
|
||
private fun notifyTabChanged(newTabIndex: Int) { | ||
Log.log(logger::info, "Firing TabChanged event for {}", newTabIndex) | ||
if (project.isDisposed) { | ||
return | ||
} | ||
val publisher = project.messageBus.syncPublisher(TabsChanged.TABS_CHANGED_TOPIC) | ||
publisher.activeTabIndexChanged(newTabIndex) | ||
} | ||
|
||
fun errorDetailsOn() { | ||
errorDetailsOn = true | ||
notifyTabChanged(1) | ||
} | ||
|
||
fun errorDetailsOff() { | ||
errorDetailsOn = false | ||
} | ||
|
||
fun isErrorDetailsOn(): Boolean { | ||
return errorDetailsOn | ||
} | ||
|
||
} |
67 changes: 0 additions & 67 deletions
67
ide-common/src/main/kotlin/org/digma/intellij/plugin/ui/service/ToolWindowTabsHelper.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/org/digma/intellij/plugin/tab/TabChangeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.digma.intellij.plugin.tab; | ||
|
||
import com.intellij.openapi.project.Project; | ||
import org.digma.intellij.plugin.analytics.TabsChanged; | ||
|
||
/** | ||
* The central handler of TabsChanged events. | ||
* it will perform the necessary actions that are common to all languages or IDEs. | ||
*/ | ||
public class TabChangeHandler implements TabsChanged { | ||
|
||
@Override | ||
public void activeTabIndexChanged(int newTabIndex) { | ||
//nothing to do here | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters