diff --git a/CHANGELOG.md b/CHANGELOG.md index ffbbb526..ecbbb036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ ## Unreleased +### Added +- ability to open a template in the Dashboard + +### Changed +- renamed the plugin from `Coder Gateway` to `Gateway` + ## 2.1.3 - 2022-12-09 ### Added diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt index 167f8f06..9dd29e0a 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt @@ -68,6 +68,11 @@ import kotlinx.coroutines.withContext import org.zeroturnaround.exec.ProcessExecutor import java.awt.Component import java.awt.Dimension +import java.awt.event.MouseEvent +import java.awt.event.MouseListener +import java.awt.event.MouseMotionListener +import java.awt.font.TextAttribute +import java.awt.font.TextAttribute.UNDERLINE_ON import javax.swing.Icon import javax.swing.JTable import javax.swing.JTextField @@ -80,6 +85,8 @@ private const val CODER_URL_KEY = "coder-url" private const val SESSION_TOKEN = "session-token" +private const val MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW = "MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW" + class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : CoderWorkspacesWizardStep, Disposable { private val cs = CoroutineScope(Dispatchers.Main) private var localWizardModel = CoderWorkspacesWizardModel() @@ -123,6 +130,49 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : } updateWorkspaceActions() } + + addMouseListener(object : MouseListener { + override fun mouseClicked(e: MouseEvent?) { + if (e?.source is TableView<*>) { + val tblView = e.source as TableView + val col = tblView.selectedColumn + val workspace = tblView.selectedObject + + if (col == 2 && workspace != null) { + BrowserUtil.browse(coderClient.coderURL.toURI().resolve("/templates/${workspace.templateName}")) + } + } + } + + override fun mousePressed(e: MouseEvent?) { + } + + override fun mouseReleased(e: MouseEvent?) { + } + + override fun mouseEntered(e: MouseEvent?) { + } + + override fun mouseExited(e: MouseEvent?) { + } + }) + addMouseMotionListener(object : MouseMotionListener { + override fun mouseMoved(e: MouseEvent?) { + if (e?.source is TableView<*>) { + val tblView = e.source as TableView + val row = tblView.rowAtPoint(e.point) + if (tblView.columnAtPoint(e.point) == 2 && row in 0 until tblView.listTableModel.rowCount) { + tblView.putClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW, row) + } else { + tblView.putClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW, -1) + } + } + + } + + override fun mouseDragged(e: MouseEvent?) { + } + }) } private val goToDashboardAction = GoToDashboardAction() @@ -569,9 +619,10 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : override fun isCenterAlignment() = true override fun getTableCellRendererComponent(table: JTable?, value: Any?, selected: Boolean, focus: Boolean, row: Int, column: Int): Component { - return super.getTableCellRendererComponent(table, value, selected, focus, row, column).apply { - border = JBUI.Borders.empty(10, 10) + super.getTableCellRendererComponent(table, value, selected, focus, row, column).apply { + border = JBUI.Borders.empty(10) } + return this } } } @@ -590,6 +641,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : text = value } font = JBFont.h3().asBold() + border = JBUI.Borders.empty() return this } } @@ -602,13 +654,27 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : } override fun getRenderer(item: WorkspaceAgentModel?): TableCellRenderer { + val simpleH3 = JBFont.h3() + + val h3AttributesWithUnderlining = simpleH3.attributes as MutableMap + h3AttributesWithUnderlining[TextAttribute.UNDERLINE] = UNDERLINE_ON + val underlinedH3 = JBFont.h3().deriveFont(h3AttributesWithUnderlining) return object : DefaultTableCellRenderer() { override fun getTableCellRendererComponent(table: JTable, value: Any, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int): Component { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column) if (value is String) { text = value } - font = JBFont.h3() + border = JBUI.Borders.empty() + + if (table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW) != null) { + val mouseOverRow = table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW) as Int + if (mouseOverRow >= 0 && mouseOverRow == row) { + font = underlinedH3 + return this + } + } + font = simpleH3 return this } } @@ -628,6 +694,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : text = value } font = JBFont.h3() + border = JBUI.Borders.empty() return this } } @@ -647,6 +714,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : text = value } font = JBFont.h3() + border = JBUI.Borders.empty() foreground = (table.model as ListTableModel).getRowValue(row).statusColor() return this } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index a020df3b..cd99b7e8 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ com.coder.gateway - Coder Gateway + Coder Coder pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy