Skip to content

Commit a1ef372

Browse files
committed
use icons to display workspace phase
Signed-off-by: Andre Dietisheim <[email protected]>
1 parent 1cd2ceb commit a1ef372

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

src/main/kotlin/com/redhat/devtools/gateway/DevSpacesIcons.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 Red Hat, Inc.
2+
* Copyright (c) 2025 Red Hat, Inc.
33
* This program and the accompanying materials are made
44
* available under the terms of the Eclipse Public License 2.0
55
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -12,7 +12,19 @@
1212
package com.redhat.devtools.gateway
1313

1414
import com.intellij.openapi.util.IconLoader
15+
import javax.swing.Icon
1516

1617
object DevSpacesIcons {
17-
val LOGO = IconLoader.getIcon("dev-spaces-logo.svg", javaClass)
18+
val LOGO = IconLoader.getIcon("/icons/dev-spaces-logo.svg", javaClass)
19+
val STARTED = IconLoader.getIcon("/icons/started.svg", javaClass)
20+
val STOPPED = IconLoader.getIcon("/icons/stopped.svg", javaClass)
21+
22+
fun getWorkspacePhaseIcon(phase: String): Icon? {
23+
return when (phase) {
24+
"Running" -> DevSpacesIcons.STARTED
25+
"Stopped" -> DevSpacesIcons.STOPPED
26+
else -> null
27+
}
28+
}
29+
1830
}

src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.intellij.util.ui.JBUI
2525
import com.redhat.devtools.gateway.DevSpacesBundle
2626
import com.redhat.devtools.gateway.DevSpacesConnection
2727
import com.redhat.devtools.gateway.DevSpacesContext
28+
import com.redhat.devtools.gateway.DevSpacesIcons
2829
import com.redhat.devtools.gateway.openshift.DevWorkspace
2930
import com.redhat.devtools.gateway.openshift.DevWorkspaces
3031
import com.redhat.devtools.gateway.openshift.Projects
@@ -250,15 +251,15 @@ class DevSpacesWorkspacesStepView(private var devSpacesContext: DevSpacesContext
250251
isSelected: Boolean,
251252
cellHasFocus: Boolean
252253
): Component {
253-
return JBLabel(
254-
String.format(
255-
"[%s] %s %s",
256-
devWorkspace.phase,
257-
if (!multipleNamespaces) "" else (devWorkspace.namespace + " /"),
258-
devWorkspace.name
259-
)
260-
).also {
261-
it.font = JBFont.h4().asPlain()
254+
val icon = DevSpacesIcons.getWorkspacePhaseIcon(devWorkspace.phase)
255+
return JBLabel().apply {
256+
font = JBFont.h4().asPlain()
257+
border = JBUI.Borders.emptyLeft(6)
258+
icon?.let {
259+
setIcon(it)
260+
horizontalTextPosition = JBLabel.TRAILING
261+
}
262+
text = "${if (!multipleNamespaces) "" else (devWorkspace.namespace + " /")} ${devWorkspace.name}"
262263
}
263264
}
264265
}
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)