@@ -108,16 +108,9 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
108
108
109
109
private var tfUrl: JTextField ? = null
110
110
private var cbExistingToken: JCheckBox ? = null
111
- private var listTableModelOfWorkspaces = ListTableModel <WorkspaceAgentModel >(
112
- WorkspaceIconColumnInfo (" " ),
113
- WorkspaceNameColumnInfo (" Name" ),
114
- WorkspaceTemplateNameColumnInfo (" Template" ),
115
- WorkspaceVersionColumnInfo (" Version" ),
116
- WorkspaceStatusColumnInfo (" Status" )
117
- )
118
111
119
112
private val notificationBanner = NotificationBanner ()
120
- private var tableOfWorkspaces = TableView (listTableModelOfWorkspaces ).apply {
113
+ private var tableOfWorkspaces = WorkspacesTable ( ).apply {
121
114
setEnableAntialiasing(true )
122
115
rowSelectionAllowed = true
123
116
columnSelectionAllowed = false
@@ -348,7 +341,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
348
341
}
349
342
350
343
override fun onInit (wizardModel : CoderWorkspacesWizardModel ) {
351
- listTableModelOfWorkspaces .items = emptyList()
344
+ tableOfWorkspaces.listTableModel .items = emptyList()
352
345
if (localWizardModel.coderURL.isNotBlank() && localWizardModel.token != null ) {
353
346
triggerWorkspacePolling(true )
354
347
} else {
@@ -454,7 +447,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
454
447
// Clear out old deployment details.
455
448
poller?.cancel()
456
449
tableOfWorkspaces.setEmptyState(" Connecting to $deploymentURL ..." )
457
- listTableModelOfWorkspaces .items = emptyList()
450
+ tableOfWorkspaces.listTableModel .items = emptyList()
458
451
459
452
// Authenticate and load in a background process with progress.
460
453
// TODO: Make this cancelable.
@@ -677,7 +670,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
677
670
}
678
671
withContext(Dispatchers .Main ) {
679
672
val selectedWorkspace = tableOfWorkspaces.selectedObject?.name
680
- listTableModelOfWorkspaces .items = ws.toList()
673
+ tableOfWorkspaces.listTableModel .items = ws.toList()
681
674
if (selectedWorkspace != null ) {
682
675
tableOfWorkspaces.selectItem(selectedWorkspace)
683
676
}
@@ -764,7 +757,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
764
757
else CoderCLIManager .getDataDir(),
765
758
settings.binarySource,
766
759
)
767
- cliManager.configSsh(listTableModelOfWorkspaces .items)
760
+ cliManager.configSsh(tableOfWorkspaces .items)
768
761
769
762
logger.info(" Opening IDE and Project Location window for ${workspace.name} " )
770
763
return true
@@ -776,6 +769,18 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
776
769
cs.cancel()
777
770
}
778
771
772
+ companion object {
773
+ val logger = Logger .getInstance(CoderWorkspacesStepView ::class .java.simpleName)
774
+ }
775
+ }
776
+
777
+ class WorkspacesTableModel : ListTableModel <WorkspaceAgentModel >(
778
+ WorkspaceIconColumnInfo (""),
779
+ WorkspaceNameColumnInfo ("Name "),
780
+ WorkspaceTemplateNameColumnInfo ("Template "),
781
+ WorkspaceVersionColumnInfo ("Version "),
782
+ WorkspaceStatusColumnInfo ("Status ")
783
+ ) {
779
784
private class WorkspaceIconColumnInfo (columnName : String ) : ColumnInfo<WorkspaceAgentModel, String>(columnName) {
780
785
override fun valueOf (workspace : WorkspaceAgentModel ? ): String? {
781
786
return workspace?.templateName
@@ -803,7 +808,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
803
808
}
804
809
}
805
810
806
- private inner class WorkspaceNameColumnInfo (columnName : String ) : ColumnInfo<WorkspaceAgentModel, String>(columnName) {
811
+ private class WorkspaceNameColumnInfo (columnName : String ) : ColumnInfo<WorkspaceAgentModel, String>(columnName) {
807
812
override fun valueOf (workspace : WorkspaceAgentModel ? ): String? {
808
813
return workspace?.name
809
814
}
@@ -822,15 +827,16 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
822
827
text = value
823
828
}
824
829
825
- font = RelativeFont .BOLD .derive(this @CoderWorkspacesStepView.tableOfWorkspaces .tableHeader.font)
830
+ font = RelativeFont .BOLD .derive(table .tableHeader.font)
826
831
border = JBUI .Borders .empty(0 , 8 )
827
832
return this
828
833
}
829
834
}
830
835
}
831
836
}
832
837
833
- private inner class WorkspaceTemplateNameColumnInfo (columnName : String ) : ColumnInfo<WorkspaceAgentModel, String>(columnName) {
838
+ private class WorkspaceTemplateNameColumnInfo (columnName : String ) :
839
+ ColumnInfo <WorkspaceAgentModel , String >(columnName) {
834
840
override fun valueOf (workspace : WorkspaceAgentModel ? ): String? {
835
841
return workspace?.templateName
836
842
}
@@ -842,11 +848,6 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
842
848
}
843
849
844
850
override fun getRenderer (item : WorkspaceAgentModel ? ): TableCellRenderer {
845
- val simpleH3 = this @CoderWorkspacesStepView.tableOfWorkspaces.tableHeader.font
846
-
847
- val h3AttributesWithUnderlining = simpleH3.attributes as MutableMap <TextAttribute , Any >
848
- h3AttributesWithUnderlining[TextAttribute .UNDERLINE ] = UNDERLINE_ON
849
- val underlinedH3 = JBFont .h3().deriveFont(h3AttributesWithUnderlining)
850
851
return object : DefaultTableCellRenderer () {
851
852
override fun getTableCellRendererComponent (table : JTable , value : Any , isSelected : Boolean , hasFocus : Boolean , row : Int , column : Int ): Component {
852
853
super .getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column)
@@ -855,10 +856,13 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
855
856
}
856
857
border = JBUI .Borders .empty(0 , 8 )
857
858
859
+ val simpleH3 = table.tableHeader.font
858
860
if (table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW ) != null ) {
859
861
val mouseOverRow = table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW ) as Int
860
862
if (mouseOverRow >= 0 && mouseOverRow == row) {
861
- font = underlinedH3
863
+ val h3AttributesWithUnderlining = simpleH3.attributes as MutableMap <TextAttribute , Any >
864
+ h3AttributesWithUnderlining[TextAttribute .UNDERLINE ] = UNDERLINE_ON
865
+ font = JBFont .h3().deriveFont(h3AttributesWithUnderlining)
862
866
return this
863
867
}
864
868
}
@@ -869,7 +873,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
869
873
}
870
874
}
871
875
872
- private inner class WorkspaceVersionColumnInfo (columnName : String ) : ColumnInfo<WorkspaceAgentModel, String>(columnName) {
876
+ private class WorkspaceVersionColumnInfo (columnName : String ) : ColumnInfo<WorkspaceAgentModel, String>(columnName) {
873
877
override fun valueOf (workspace : WorkspaceAgentModel ? ): String? {
874
878
return workspace?.status?.label
875
879
}
@@ -881,15 +885,15 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
881
885
if (value is String ) {
882
886
text = value
883
887
}
884
- font = this @CoderWorkspacesStepView.tableOfWorkspaces .tableHeader.font
888
+ font = table .tableHeader.font
885
889
border = JBUI .Borders .empty(0 , 8 )
886
890
return this
887
891
}
888
892
}
889
893
}
890
894
}
891
895
892
- private inner class WorkspaceStatusColumnInfo (columnName : String ) : ColumnInfo<WorkspaceAgentModel, String>(columnName) {
896
+ private class WorkspaceStatusColumnInfo (columnName : String ) : ColumnInfo<WorkspaceAgentModel, String>(columnName) {
893
897
override fun valueOf (workspace : WorkspaceAgentModel ? ): String? {
894
898
return workspace?.agentStatus?.label
895
899
}
@@ -902,29 +906,24 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
902
906
903
907
override fun getRenderer (item : WorkspaceAgentModel ? ): TableCellRenderer {
904
908
return object : DefaultTableCellRenderer () {
905
- override fun getTableCellRendererComponent (
906
- table : JTable ,
907
- value : Any ,
908
- isSelected : Boolean ,
909
- hasFocus : Boolean ,
910
- row : Int ,
911
- column : Int ,
912
- ): Component {
909
+ override fun getTableCellRendererComponent (table : JTable , value : Any , isSelected : Boolean , hasFocus : Boolean , row : Int , column : Int ): Component {
913
910
super .getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column)
914
911
if (value is String ) {
915
912
text = value
916
913
foreground = WorkspaceAndAgentStatus .from(value).statusColor()
917
914
toolTipText = WorkspaceAndAgentStatus .from(value).description
918
915
}
919
- font = this @CoderWorkspacesStepView.tableOfWorkspaces .tableHeader.font
916
+ font = table .tableHeader.font
920
917
border = JBUI .Borders .empty(0 , 8 )
921
918
return this
922
919
}
923
920
}
924
921
}
925
922
}
923
+ }
926
924
927
- private fun TableView<WorkspaceAgentModel>.selectItem (workspaceName : String? ) {
925
+ class WorkspacesTable : TableView <WorkspaceAgentModel >(WorkspacesTableModel ()) {
926
+ fun selectItem (workspaceName : String? ) {
928
927
if (workspaceName != null ) {
929
928
this .items.forEachIndexed { index, workspaceAgentModel ->
930
929
if (workspaceAgentModel.name == workspaceName) {
@@ -935,8 +934,4 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
935
934
}
936
935
}
937
936
}
938
-
939
- companion object {
940
- val logger = Logger .getInstance(CoderWorkspacesStepView ::class .java.simpleName)
941
- }
942
937
}
0 commit comments