Skip to content

Commit 8aa3417

Browse files
authored
Merge pull request #127 from coder/template-name-as-hyperlinl
Template name as hyperlinks
2 parents 57c16fe + e5e095b commit 8aa3417

File tree

3 files changed

+78
-4
lines changed

3 files changed

+78
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
## Unreleased
66

7+
### Added
8+
- ability to open a template in the Dashboard
9+
10+
### Changed
11+
- renamed the plugin from `Coder Gateway` to `Gateway`
12+
713
## 2.1.3 - 2022-12-09
814

915
### Added

src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ import kotlinx.coroutines.withContext
6868
import org.zeroturnaround.exec.ProcessExecutor
6969
import java.awt.Component
7070
import java.awt.Dimension
71+
import java.awt.event.MouseEvent
72+
import java.awt.event.MouseListener
73+
import java.awt.event.MouseMotionListener
74+
import java.awt.font.TextAttribute
75+
import java.awt.font.TextAttribute.UNDERLINE_ON
7176
import javax.swing.Icon
7277
import javax.swing.JTable
7378
import javax.swing.JTextField
@@ -80,6 +85,8 @@ private const val CODER_URL_KEY = "coder-url"
8085

8186
private const val SESSION_TOKEN = "session-token"
8287

88+
private const val MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW = "MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW"
89+
8390
class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : CoderWorkspacesWizardStep, Disposable {
8491
private val cs = CoroutineScope(Dispatchers.Main)
8592
private var localWizardModel = CoderWorkspacesWizardModel()
@@ -123,6 +130,49 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
123130
}
124131
updateWorkspaceActions()
125132
}
133+
134+
addMouseListener(object : MouseListener {
135+
override fun mouseClicked(e: MouseEvent?) {
136+
if (e?.source is TableView<*>) {
137+
val tblView = e.source as TableView<WorkspaceAgentModel>
138+
val col = tblView.selectedColumn
139+
val workspace = tblView.selectedObject
140+
141+
if (col == 2 && workspace != null) {
142+
BrowserUtil.browse(coderClient.coderURL.toURI().resolve("/templates/${workspace.templateName}"))
143+
}
144+
}
145+
}
146+
147+
override fun mousePressed(e: MouseEvent?) {
148+
}
149+
150+
override fun mouseReleased(e: MouseEvent?) {
151+
}
152+
153+
override fun mouseEntered(e: MouseEvent?) {
154+
}
155+
156+
override fun mouseExited(e: MouseEvent?) {
157+
}
158+
})
159+
addMouseMotionListener(object : MouseMotionListener {
160+
override fun mouseMoved(e: MouseEvent?) {
161+
if (e?.source is TableView<*>) {
162+
val tblView = e.source as TableView<WorkspaceAgentModel>
163+
val row = tblView.rowAtPoint(e.point)
164+
if (tblView.columnAtPoint(e.point) == 2 && row in 0 until tblView.listTableModel.rowCount) {
165+
tblView.putClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW, row)
166+
} else {
167+
tblView.putClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW, -1)
168+
}
169+
}
170+
171+
}
172+
173+
override fun mouseDragged(e: MouseEvent?) {
174+
}
175+
})
126176
}
127177

128178
private val goToDashboardAction = GoToDashboardAction()
@@ -569,9 +619,10 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
569619
override fun isCenterAlignment() = true
570620

571621
override fun getTableCellRendererComponent(table: JTable?, value: Any?, selected: Boolean, focus: Boolean, row: Int, column: Int): Component {
572-
return super.getTableCellRendererComponent(table, value, selected, focus, row, column).apply {
573-
border = JBUI.Borders.empty(10, 10)
622+
super.getTableCellRendererComponent(table, value, selected, focus, row, column).apply {
623+
border = JBUI.Borders.empty(10)
574624
}
625+
return this
575626
}
576627
}
577628
}
@@ -590,6 +641,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
590641
text = value
591642
}
592643
font = JBFont.h3().asBold()
644+
border = JBUI.Borders.empty()
593645
return this
594646
}
595647
}
@@ -602,13 +654,27 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
602654
}
603655

604656
override fun getRenderer(item: WorkspaceAgentModel?): TableCellRenderer {
657+
val simpleH3 = JBFont.h3()
658+
659+
val h3AttributesWithUnderlining = simpleH3.attributes as MutableMap<TextAttribute, Any>
660+
h3AttributesWithUnderlining[TextAttribute.UNDERLINE] = UNDERLINE_ON
661+
val underlinedH3 = JBFont.h3().deriveFont(h3AttributesWithUnderlining)
605662
return object : DefaultTableCellRenderer() {
606663
override fun getTableCellRendererComponent(table: JTable, value: Any, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int): Component {
607664
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column)
608665
if (value is String) {
609666
text = value
610667
}
611-
font = JBFont.h3()
668+
border = JBUI.Borders.empty()
669+
670+
if (table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW) != null) {
671+
val mouseOverRow = table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW) as Int
672+
if (mouseOverRow >= 0 && mouseOverRow == row) {
673+
font = underlinedH3
674+
return this
675+
}
676+
}
677+
font = simpleH3
612678
return this
613679
}
614680
}
@@ -628,6 +694,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
628694
text = value
629695
}
630696
font = JBFont.h3()
697+
border = JBUI.Borders.empty()
631698
return this
632699
}
633700
}
@@ -647,6 +714,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
647714
text = value
648715
}
649716
font = JBFont.h3()
717+
border = JBUI.Borders.empty()
650718
foreground = (table.model as ListTableModel<WorkspaceAgentModel>).getRowValue(row).statusColor()
651719
return this
652720
}

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
22
<idea-plugin>
33
<id>com.coder.gateway</id>
4-
<name>Coder Gateway</name>
4+
<name>Coder</name>
55
<vendor>Coder</vendor>
66

77
<!-- Product and plugin compatibility requirements -->

0 commit comments

Comments
 (0)
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