Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAP CX Logging | Added the active HAC connection in the logging menu #1281

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Added logging support for enum, record and interface types [#1273](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1273)
- Removed logger actions from the Actions tab in the Search Everywhere popup [#1275](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1275)
- Added ALL and OFF modes for logging [#1277](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1277)
- Added the active HAC connection in the logging menu [#1281](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1281)

### `Other` enhancements
- Do not check for Ultimate plugins when using the Community edition during project import [#1276](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1276)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,32 @@

<idea-plugin>
<actions>
<group id="sap.cx.logging.actions">
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.OffLoggerAction" />
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.AllLoggerAction" />
<separator/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.TraceLoggerAction" />
<group id="sap.cx.logging.actions" popup="true">
<separator text="Active Connection"/>
<group id="sap.cx.logging.actions.connection" popup="true"
class="com.intellij.idea.plugin.hybris.tools.logging.actions.ActiveHacConnectionAction" searchable="false"/>

<separator text="Log Levels"/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.OffLoggerAction"/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.AllLoggerAction"/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.TraceLoggerAction"/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.DebugLoggerAction"/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.InfoLoggerAction"/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.WarnLoggerAction"/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.ErrorLoggerAction"/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.FatalLoggerAction"/>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.SevereLoggerAction"/>
</group>
<group id="sap.cx.logging.actions.connection.actions">
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.AddHacConnectionAction">
<add-to-group group-id="sap.cx.logging.actions.connection" anchor="first"/>
</action>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.EditActiveHacConnectionAction">
<add-to-group group-id="sap.cx.logging.actions.connection"/>
</action>
<action class="com.intellij.idea.plugin.hybris.tools.logging.actions.ConfigureHacConnectionAction">
<add-to-group group-id="sap.cx.logging.actions.connection"/>
</action>
</group>
</actions>
</idea-plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.intellij.util.xmlb.annotations.Transient
class RemoteConnectionSettings : BaseState(), Comparable<RemoteConnectionSettings> {

var uuid by string(null)

@Transient
var credentials: Credentials? = null
var displayName by string(null)
Expand Down Expand Up @@ -81,6 +82,11 @@ class RemoteConnectionSettings : BaseState(), Comparable<RemoteConnectionSetting
&& accessor.name != "password"
&& accessor.name != "scope"

fun connectionName() = displayName ?: generatedURL

fun shortenConnectionName() = (displayName ?: generatedURL)
.let { if (it.length > 20) it.take(20) + ".." else it }

override fun compareTo(other: RemoteConnectionSettings) = uuid
?.compareTo(other.uuid ?: "")
?: -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ import com.intellij.codeInsight.codeVision.ui.model.ClickableTextCodeVisionEntry
import com.intellij.codeInsight.daemon.impl.JavaCodeVisionProviderBase
import com.intellij.codeInsight.hints.InlayHintsUtils
import com.intellij.codeInsight.hints.settings.language.isInlaySettingsEditor
import com.intellij.ide.DataManager
import com.intellij.idea.plugin.hybris.common.HybrisConstants
import com.intellij.idea.plugin.hybris.common.utils.HybrisIcons
import com.intellij.idea.plugin.hybris.settings.components.ProjectSettingsComponent
import com.intellij.openapi.actionSystem.ActionGroup
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.CustomizedDataContext
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.actionSystem.impl.SimpleDataContext
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.openapi.util.TextRange
import com.intellij.psi.*
Expand All @@ -44,6 +42,10 @@ import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.childrenOfType
import com.intellij.psi.util.endOffset
import com.intellij.ui.awt.RelativePoint
import com.intellij.openapi.ui.popup.util.BaseListPopupStep
import com.intellij.openapi.ui.popup.ListPopupStep
import com.intellij.openapi.ui.popup.ListSeparator
import com.intellij.openapi.ui.popup.PopupStep
import java.awt.Point
import java.awt.event.MouseEvent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,26 @@ package com.intellij.idea.plugin.hybris.tools.logging.actions
import com.intellij.idea.plugin.hybris.common.HybrisConstants
import com.intellij.idea.plugin.hybris.common.utils.HybrisIcons
import com.intellij.idea.plugin.hybris.notifications.Notifications
import com.intellij.idea.plugin.hybris.settings.options.ProjectIntegrationsSettingsConfigurableProvider
import com.intellij.idea.plugin.hybris.tools.remote.RemoteConnectionType
import com.intellij.idea.plugin.hybris.tools.remote.RemoteConnectionUtil
import com.intellij.idea.plugin.hybris.tools.remote.http.AbstractHybrisHacHttpClient
import com.intellij.idea.plugin.hybris.tools.remote.http.HybrisHacHttpClient
import com.intellij.idea.plugin.hybris.toolwindow.RemoteHacConnectionDialog
import com.intellij.idea.plugin.hybris.util.PackageUtils
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.Project
import java.awt.Component
import java.awt.event.InputEvent
import javax.swing.Icon

abstract class AbstractLoggerAction(private val logLevel: String, val icon: Icon) : AnAction(logLevel, "", icon) {
Expand Down Expand Up @@ -79,7 +85,7 @@ abstract class AbstractLoggerAction(private val logLevel: String, val icon: Icon
"""
<p>Level : $logLevel</p>
<p>Logger : $abbreviationLogIdentifier</p>
<p>${server.displayName ?: server.generatedURL}</p>"""
<p>${server.shortenConnectionName()}</p>"""

)
} else {
Expand All @@ -90,7 +96,7 @@ abstract class AbstractLoggerAction(private val logLevel: String, val icon: Icon
"""
<p>Level : $logLevel</p>
<p>Logger : $abbreviationLogIdentifier</p>
<p>${server.displayName ?: server.generatedURL}</p>"""
<p>${server.shortenConnectionName()}</p>"""
)
}
} finally {
Expand Down Expand Up @@ -132,4 +138,77 @@ class InfoLoggerAction : AbstractLoggerAction("INFO", HybrisIcons.Log.Level.INFO
class WarnLoggerAction : AbstractLoggerAction("WARN", HybrisIcons.Log.Level.WARN)
class ErrorLoggerAction : AbstractLoggerAction("ERROR", HybrisIcons.Log.Level.ERROR)
class FatalLoggerAction : AbstractLoggerAction("FATAL", HybrisIcons.Log.Level.FATAL)
class SevereLoggerAction : AbstractLoggerAction("SEVERE", HybrisIcons.Log.Level.SEVERE)
class SevereLoggerAction : AbstractLoggerAction("SEVERE", HybrisIcons.Log.Level.SEVERE)

abstract class AbstractHacConnectionAction(private val actionName: String, val icon: Icon) : AnAction(actionName, "", icon) {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun update(e: AnActionEvent) {
super.update(e)

val presentation = e.presentation

presentation.text = actionName
presentation.icon = icon

presentation.isEnabledAndVisible = true
}
}

class AddHacConnectionAction : AbstractHacConnectionAction("Create new connection", HybrisIcons.Connection.ADD) {

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val inputEvent: InputEvent? = e.inputEvent
val eventSource = inputEvent?.source
val component = (eventSource as? Component)
?: return

val settings = RemoteConnectionUtil.createDefaultRemoteConnectionSettings(project, RemoteConnectionType.Hybris)
if (RemoteHacConnectionDialog(project, component, settings).showAndGet()) {
RemoteConnectionUtil.addRemoteConnection(project, settings)
}
}
}

class EditActiveHacConnectionAction : AbstractHacConnectionAction("Edit active connection", HybrisIcons.Connection.EDIT) {

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val inputEvent: InputEvent? = e.inputEvent
val eventSource = inputEvent?.source
val component = (eventSource as? Component)
?: return

val settings = RemoteConnectionUtil.getActiveRemoteConnectionSettings(project, RemoteConnectionType.Hybris)
RemoteHacConnectionDialog(project, component, settings).showAndGet()
}
}

class ConfigureHacConnectionAction : AbstractHacConnectionAction("Connection settings", HybrisIcons.SETTINGS) {

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return

ShowSettingsUtil.getInstance()
.showSettingsDialog(project, ProjectIntegrationsSettingsConfigurableProvider.SettingsConfigurable::class.java)
}
}

class ActiveHacConnectionAction : DefaultActionGroup() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun update(e: AnActionEvent) {
super.update(e)

val project = e.project ?: return
val presentation = e.presentation

val hacSettings = RemoteConnectionUtil.getActiveRemoteConnectionSettings(project, RemoteConnectionType.Hybris)
presentation.text = hacSettings.shortenConnectionName()
presentation.icon = HybrisIcons.Y.REMOTE_GREEN
presentation.description = hacSettings.connectionName()

presentation.isEnabledAndVisible = true
}
}
Loading