Skip to content

Commit 947a90e

Browse files
committed
Toolbar functionality PoC
1 parent 4602ef1 commit 947a90e

File tree

8 files changed

+286
-107
lines changed

8 files changed

+286
-107
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ compose.desktop {
5555
"processing.contributions.source" to "https://contributions.processing.org/contribs",
5656
"processing.download.page" to "https://processing.org/download/",
5757
"processing.download.latest" to "https://processing.org/download/latest.txt",
58-
"processing.tutorials" to "https://processing.org/tutorials/",
58+
"processing.tutorials" to "https://processing.org/tutorials/"
5959
)
6060

6161
jvmArgs(*variables.entries.map { "-D${it.key}=${it.value}" }.toTypedArray())

app/src/processing/app/Base.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public class Base {
6767
*/
6868
static public boolean DEBUG = System.getenv().containsKey("DEBUG");
6969

70-
static public boolean GRADLE = true;
71-
7270
/** True if running via Commander. */
7371
static private boolean commandLine;
7472

app/src/processing/app/gradle/GradleService.kt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.sun.jdi.Bootstrap
66
import com.sun.jdi.VirtualMachine
77
import com.sun.jdi.connect.AttachingConnector
88
import kotlinx.coroutines.*
9-
import org.gradle.internal.logging.events.OutputEvent
109
import org.gradle.tooling.BuildLauncher
1110
import org.gradle.tooling.GradleConnector
1211
import org.gradle.tooling.ProjectConnection
@@ -26,11 +25,14 @@ import javax.swing.event.DocumentListener
2625
import kotlin.io.path.writeText
2726

2827
// TODO: Remove dependency on editor
28+
// TODO: Move to jobs system
29+
// TODO: Improve progress tracking
2930
class GradleService(val editor: Editor) {
31+
val active = mutableStateOf(true)
3032
val availableTasks = mutableStateListOf<String>()
3133
val finishedTasks = mutableStateListOf<String>()
3234
val running = mutableStateOf(false)
33-
var vm: VirtualMachine? = null
35+
var vm = mutableStateOf<VirtualMachine?>(null)
3436
val debugPort = (30000..60000).random()
3537
val problems = mutableStateListOf<ProblemEvent>()
3638

@@ -43,6 +45,14 @@ class GradleService(val editor: Editor) {
4345

4446
val folder: File get() = editor.sketch.folder
4547

48+
// Hooks for java to check if the Gradle service is running
49+
fun getEnabled(): Boolean {
50+
return active.value
51+
}
52+
fun setEnabled(active: Boolean) {
53+
this.active.value = active
54+
}
55+
4656
fun prepare(){
4757
Messages.log("Preparing sketch")
4858
if(preparing) return
@@ -164,9 +174,9 @@ class GradleService(val editor: Editor) {
164174
?: return@ProgressListener
165175
val args = connector.defaultArguments()
166176
args["port"]?.setValue(debugPort.toString())
167-
val vm = connector.attach(args)
168-
this@GradleService.vm = vm
169-
Messages.log("Attached to VM: ${vm.name()}")
177+
val sketch = connector.attach(args)
178+
vm.value = sketch
179+
Messages.log("Attached to VM: ${sketch.name()}")
170180
})
171181
return this
172182
}
@@ -182,7 +192,7 @@ class GradleService(val editor: Editor) {
182192
finishedTasks.add(name)
183193
}
184194
if(event is DefaultSingleProblemEvent){
185-
Messages.log("")
195+
problems.add(event)
186196
}
187197
})
188198
return this

0 commit comments

Comments
 (0)