From 88580d7d0dd0bb755bf943af166a06e2980bedcf Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Fri, 16 Dec 2022 19:29:35 +0200 Subject: [PATCH 1/3] redesign: table rows without cell borders --- .../coder/gateway/views/steps/CoderWorkspacesStepView.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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..63aa39db 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt @@ -569,9 +569,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 { + super.getTableCellRendererComponent(table, value, selected, focus, row, column).apply { border = JBUI.Borders.empty(10, 10) } + return this } } } @@ -590,6 +591,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : text = value } font = JBFont.h3().asBold() + border = JBUI.Borders.empty() return this } } @@ -609,6 +611,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : text = value } font = JBFont.h3() + border = JBUI.Borders.empty() return this } } @@ -628,6 +631,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : text = value } font = JBFont.h3() + border = JBUI.Borders.empty() return this } } @@ -647,6 +651,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 } From f5d84361524b7023635963c7a83a0ce4da3343a7 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Mon, 19 Dec 2022 22:31:30 +0200 Subject: [PATCH 2/3] impl: ability to open templates in the dashboard - allows user to click anywhere on the Coder Template column and open up the template in the dashboard --- CHANGELOG.md | 3 + .../views/steps/CoderWorkspacesStepView.kt | 67 ++++++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffbbb526..92e096ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ ## Unreleased +### Added +- ability to open a template in the Dashboard + ## 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 63aa39db..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() @@ -570,7 +620,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : override fun getTableCellRendererComponent(table: JTable?, value: Any?, selected: Boolean, focus: Boolean, row: Int, column: Int): Component { super.getTableCellRendererComponent(table, value, selected, focus, row, column).apply { - border = JBUI.Borders.empty(10, 10) + border = JBUI.Borders.empty(10) } return this } @@ -604,14 +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 } } From e5e095b61b4aff735ae456ab045a8207a63d3db5 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Mon, 19 Dec 2022 22:36:48 +0200 Subject: [PATCH 3/3] rename: plugin name from Coder Gateway to Coder --- CHANGELOG.md | 3 +++ src/main/resources/META-INF/plugin.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e096ee..ecbbb036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ ### 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/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