@@ -33,126 +33,137 @@ class AppSettingsComponent : com.intellij.openapi.Disposable {
3333// }
3434// })
3535
36- @Suppress(" unused" )
37- @Name(" Human Language" )
38- val humanLanguage = JBTextField ()
39-
40- @Suppress(" unused" )
41- @Name(" Listening Port" )
42- val listeningPort = JBTextField ()
43-
44- @Suppress(" unused" )
45- @Name(" Listening Endpoint" )
46- val listeningEndpoint = JBTextField ()
47-
48- @Suppress(" unused" )
49- @Name(" Suppress Errors" )
50- val suppressErrors = JBCheckBox ()
51-
52- @Suppress(" unused" )
53- @Name(" Model" )
54- val smartModel = ComboBox <String >()
55-
56- @Suppress(" unused" )
57- @Name(" Model" )
58- val fastModel = ComboBox <String >()
59-
60- @Suppress(" unused" )
61- @Name(" Enable API Log" )
62- val apiLog = JBCheckBox ()
63-
64- @Suppress(" unused" )
65- val openApiLog = JButton (object : AbstractAction (" Open API Log" ) {
66- override fun actionPerformed (e : ActionEvent ) {
67- AppSettingsState .auxiliaryLog?.let {
68- if (it.exists()) {
69- val project = ApplicationManager .getApplication().runReadAction<Project > {
70- ProjectManager .getInstance().openProjects.firstOrNull()
71- }
72- ApplicationManager .getApplication().invokeLater {
73- val virtualFile = LocalFileSystem .getInstance().refreshAndFindFileByIoFile(it)
74- val openFileDescriptor = OpenFileDescriptor (project, virtualFile!! , virtualFile.length.toInt())
75- FileEditorManager .getInstance(project!! ).openTextEditor(openFileDescriptor, true )?.document?.setReadOnly(
76- true
77- )
78- }
36+ @Suppress(" unused" )
37+ @Name(" Human Language" )
38+ val humanLanguage = JBTextField ()
39+
40+ @Suppress(" unused" )
41+ @Name(" Listening Port" )
42+ val listeningPort = JBTextField ()
43+
44+ @Suppress(" unused" )
45+ @Name(" Listening Endpoint" )
46+ val listeningEndpoint = JBTextField ()
47+
48+ @Suppress(" unused" )
49+ @Name(" Suppress Errors" )
50+ val suppressErrors = JBCheckBox ()
51+
52+ @Suppress(" unused" )
53+ @Name(" Model" )
54+ val smartModel = ComboBox <String >()
55+
56+ @Suppress(" unused" )
57+ @Name(" Model" )
58+ val fastModel = ComboBox <String >()
59+
60+ @Suppress(" unused" )
61+ @Name(" Enable API Log" )
62+ val apiLog = JBCheckBox ()
63+
64+ @Suppress(" unused" )
65+ val openApiLog = JButton (object : AbstractAction (" Open API Log" ) {
66+ override fun actionPerformed (e : ActionEvent ) {
67+ AppSettingsState .auxiliaryLog?.let {
68+ if (it.exists()) {
69+ val project = ApplicationManager .getApplication().runReadAction<Project > {
70+ ProjectManager .getInstance().openProjects.firstOrNull()
71+ }
72+ ApplicationManager .getApplication().invokeLater {
73+ val virtualFile = LocalFileSystem .getInstance().refreshAndFindFileByIoFile(it)
74+ val openFileDescriptor = OpenFileDescriptor (project, virtualFile!! , virtualFile.length.toInt())
75+ FileEditorManager .getInstance(project!! )
76+ .openTextEditor(openFileDescriptor, true )?.document?.setReadOnly(
77+ true
78+ )
79+ }
80+ }
81+ }
7982 }
80- }
81- }
82- })
83+ })
84+
85+
86+ @Suppress(" unused" )
87+ val clearApiLog = JButton (object : AbstractAction (" Clear API Log" ) {
88+ override fun actionPerformed (e : ActionEvent ) {
89+ val openAIClient = IdeaOpenAIClient .instance
90+ openAIClient.logStreams.retainAll { it.close(); false }
91+ AppSettingsState .auxiliaryLog?.let {
92+ if (it.exists()) {
93+ it.delete()
94+ }
95+ openAIClient.logStreams.add(FileOutputStream (it, true ).buffered())
96+ }
97+ }
98+ })
8399
84100
85- @Suppress(" unused" )
86- val clearApiLog = JButton (object : AbstractAction (" Clear API Log" ) {
87- override fun actionPerformed (e : ActionEvent ) {
88- val openAIClient = IdeaOpenAIClient .instance
89- openAIClient.logStreams.retainAll { it.close(); false }
90- AppSettingsState .auxiliaryLog?.let {
91- if (it.exists()) {
92- it.delete()
93- }
94- openAIClient.logStreams.add(FileOutputStream (it, true ).buffered())
95- }
101+ @Suppress(" unused" )
102+ @Name(" Developer Tools" )
103+ val devActions = JBCheckBox ()
104+
105+ @Suppress(" unused" )
106+ @Name(" Edit API Requests" )
107+ val editRequests = JBCheckBox ()
108+
109+ @Suppress(" unused" )
110+ @Name(" Plugin Home" )
111+ val pluginHome = JBTextField ()
112+
113+ @Suppress(" unused" )
114+ val choosePluginHome = com.intellij.openapi.ui.TextFieldWithBrowseButton (pluginHome).apply {
115+ addBrowseFolderListener(
116+ " Select Plugin Home Directory" ,
117+ null ,
118+ null ,
119+ FileChooserDescriptorFactory .createSingleFolderDescriptor()
120+ )
96121 }
97- })
98-
99-
100- @Suppress(" unused" )
101- @Name(" Developer Tools" )
102- val devActions = JBCheckBox ()
103-
104- @Suppress(" unused" )
105- @Name(" Edit API Requests" )
106- val editRequests = JBCheckBox ()
107-
108- @Suppress(" unused" )
109- @Name(" Plugin Home" )
110- val pluginHome = JBTextField ()
111-
112- @Suppress(" unused" )
113- val choosePluginHome = com.intellij.openapi.ui.TextFieldWithBrowseButton (pluginHome).apply {
114- addBrowseFolderListener(" Select Plugin Home Directory" , null , null , FileChooserDescriptorFactory .createSingleFolderDescriptor())
115- }
116-
117- @Suppress(" unused" )
118- @Name(" Temperature" )
119- val temperature = JBTextField ()
120-
121- @Name(" APIs" )
122- val apis = JBTable (DefaultTableModel (arrayOf(" Provider" , " Key" , " Base URL" ), 0 )).apply {
123- columnModel.getColumn(0 ).preferredWidth = 100
124- columnModel.getColumn(1 ).preferredWidth = 200
125- columnModel.getColumn(2 ).preferredWidth = 200
126- val keyColumnIndex = 1
127- getColumnModel().getColumn(keyColumnIndex).cellRenderer = object : DefaultTableCellRenderer () {
128- override fun setValue (value : Any? ) {
129- text =
130- if (value is String && value.isNotEmpty()) value.map { ' *' }.joinToString(" " ) else value?.toString() ? : " "
131- }
122+
123+ @Suppress(" unused" )
124+ @Name(" Show Welcome Screen" )
125+ val showWelcomeScreen = JBCheckBox (" Show Welcome Screen" , true )
126+
127+ @Suppress(" unused" )
128+ @Name(" Temperature" )
129+ val temperature = JBTextField ()
130+
131+ @Name(" APIs" )
132+ val apis = JBTable (DefaultTableModel (arrayOf(" Provider" , " Key" , " Base URL" ), 0 )).apply {
133+ columnModel.getColumn(0 ).preferredWidth = 100
134+ columnModel.getColumn(1 ).preferredWidth = 200
135+ columnModel.getColumn(2 ).preferredWidth = 200
136+ val keyColumnIndex = 1
137+ getColumnModel().getColumn(keyColumnIndex).cellRenderer = object : DefaultTableCellRenderer () {
138+ override fun setValue (value : Any? ) {
139+ text =
140+ if (value is String && value.isNotEmpty()) value.map { ' *' }.joinToString(" " ) else value?.toString()
141+ ? : " "
142+ }
143+ }
132144 }
133- }
134145
135- @Name(" Editor Actions" )
136- var usage = UsageTable (ApplicationServices .usageManager)
146+ @Name(" Editor Actions" )
147+ var usage = UsageTable (ApplicationServices .usageManager)
137148
138- init {
149+ init {
139150// tokenCounter.isEditable = false
140151// this.modelName.addItem(ChatModels.GPT35Turbo.modelName)
141152// this.modelName.addItem(ChatModels.GPT4.modelName)
142153// this.modelName.addItem(ChatModels.GPT4Turbo.modelName)
143- ChatModels .values().forEach {
154+ ChatModels .values().forEach {
144155// this.modelName.addItem(it.key)
145- this .smartModel.addItem(it.value.modelName)
146- this .fastModel.addItem(it.value.modelName)
147- }
156+ this .smartModel.addItem(it.value.modelName)
157+ this .fastModel.addItem(it.value.modelName)
158+ }
148159// this.modelName.isEditable = true
149- this .smartModel.isEditable = true
150- this .fastModel.isEditable = true
151- }
160+ this .smartModel.isEditable = true
161+ this .fastModel.isEditable = true
162+ }
152163
153- companion object {
154- }
164+ companion object {
165+ }
155166
156- override fun dispose () {
157- }
167+ override fun dispose () {
168+ }
158169}
0 commit comments