Skip to content

Commit df1277e

Browse files
committed
Disabled modern UI for now. Added preference instead
1 parent c5c3b2f commit df1277e

File tree

10 files changed

+47
-16
lines changed

10 files changed

+47
-16
lines changed

app/src/main/resources/defaults.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ console.temp.days = 7
186186
console.scrollback.lines = 500
187187
console.scrollback.chars = 40000
188188

189+
# run java sketches with Gradle aka the Modern Build System
190+
run.use_gradle = false
191+
189192
# Any additional Java options when running.
190193
# If you change this and can't run things, it's your own durn fault.
191194
run.options =

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import processing.app.Base
1212
import processing.app.Language
1313
import processing.app.Messages
1414
import processing.app.Platform
15+
import processing.app.Preferences
1516
import processing.app.gradle.helpers.ActionGradleJob
1617
import processing.app.gradle.helpers.BackgroundGradleJob
1718
import processing.app.ui.Editor
@@ -26,7 +27,6 @@ import kotlin.io.path.writeText
2627
// TODO: PoC new debugger/tweak mode
2728
// TODO: Allow for plugins to skip gradle entirely / new modes
2829
// TODO: Improve background building
29-
// TODO: Rename to Service?
3030
// TODO: Track build speed (for analytics?)
3131

3232
// The gradle service runs the gradle tasks and manages the gradle connection
@@ -35,7 +35,7 @@ import kotlin.io.path.writeText
3535
// GradleJob manages the gradle build and connects the debugger
3636
class GradleService(val editor: Editor) {
3737
val folder: File get() = editor.sketch.folder
38-
val active = mutableStateOf(true)
38+
val active = mutableStateOf(Preferences.getBoolean("run.use_gradle"))
3939

4040
val jobs = mutableStateListOf<GradleJob>()
4141
val workingDir = kotlin.io.path.createTempDirectory()
@@ -45,7 +45,7 @@ class GradleService(val editor: Editor) {
4545

4646
private val scope = CoroutineScope(Dispatchers.IO)
4747

48-
// Hooks for java to check if the Gradle service is running
48+
// Hooks for java to check if the Gradle service is running since mutableStateOf is not accessible in java
4949
fun getEnabled(): Boolean {
5050
return active.value
5151
}
@@ -101,6 +101,7 @@ class GradleService(val editor: Editor) {
101101
}
102102
// TODO: Stop all jobs on dispose
103103
}
104+
// TODO: Add support for present
104105
fun run(){
105106
stopActions()
106107
editor.console.clear()
@@ -215,12 +216,13 @@ class GradleService(val editor: Editor) {
215216
return@let Base.DEBUG
216217
}
217218
if (generate) {
218-
Messages.log("build.gradle.kts not found or outdated in ${folder}, creating one")
219+
Messages.log("build.gradle.kts outdated or not found in ${folder}, creating one")
219220
val header = """
220221
// @processing-auto-generated mode=${editor.mode.title} version=${Base.getVersionName()}
221222
//
222223
""".trimIndent()
223224

225+
// TODO: add instructions keys
224226
val instructions = Language.text("gradle.instructions")
225227
.split("\n")
226228
.joinToString("\n") { "// $it" }

app/src/processing/app/gradle/ScreenshotService.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import kotlin.time.TimeSource
1515
// TODO: Add more feedback when things go wrong
1616
// TODO: Check if the sketch has a draw method
1717
// TODO: Communicate the screen over the debugging connection (to support remote clients)
18+
// TODO: Sharing buffers would not work with remote clients
19+
// TODO: Record / Capture on the client and then transfer the file over the debugging connection
20+
// TODO: Create a video capture method for every platform / target
1821
// TODO: Support recording videos
1922
class ScreenshotService {
2023
companion object{

app/src/processing/app/gradle/ui/Toolbar.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Toolbar(val editor: Editor?) {
5151
val panel = ComposePanel().apply {
5252
setContent {
5353
val displayNew = editor.service.active.value
54-
if (displayNew) {
54+
if (displayNew && false) {
5555
bar.display()
5656
return@setContent
5757
}

app/src/processing/app/ui/Editor.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,6 @@ public void rebuildModePopup() {
528528
manageModes.addActionListener(e -> ContributionManager.openModes());
529529
modePopup.add(manageModes);
530530

531-
JMenuItem enableModern = new JMenuItem(Language.text("toolbar.enable_modern"));
532-
enableModern.addActionListener(e -> {
533-
this.service.setEnabled(true);
534-
});
535-
modePopup.addSeparator();
536-
modePopup.add(enableModern);
537-
538531
Toolkit.setMenuMnemsInside(modePopup);
539532
}
540533

@@ -609,6 +602,7 @@ protected int getDividerLocation() {
609602
* with things in the Preferences window.
610603
*/
611604
public void applyPreferences() {
605+
service.setEnabled(Preferences.getBoolean("run.use_gradle"));
612606
// Even though this is only updating the theme (colors, icons),
613607
// subclasses use this to apply other preferences.
614608
// For instance, Java Mode applies changes to error checking.

app/src/processing/app/ui/PreferencesFrame.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class PreferencesFrame {
8585
JCheckBox hidpiDisableBox;
8686
// JLabel hidpiRestartLabel;
8787
JCheckBox syncSketchNameBox;
88+
JCheckBox useModernBuildSystem;
8889

8990
JComboBox<String> displaySelectionBox;
9091
JComboBox<String> languageSelectionBox;
@@ -554,6 +555,9 @@ public void mouseExited(MouseEvent e) {
554555
runningPanel.setBorder(new TitledBorder("Running"));
555556
runningPanel.setLayout(new BoxLayout(runningPanel, BoxLayout.Y_AXIS));
556557

558+
useModernBuildSystem = new JCheckBox(Language.text("preferences.use_modern_build_system"));
559+
addRow(runningPanel, useModernBuildSystem);
560+
557561
addRow(runningPanel, displayLabel, displaySelectionBox);
558562
addRow(runningPanel, backgroundColorLabel, presentColor);
559563
addRow(runningPanel, memoryOverrideBox, memoryField, mbLabel);
@@ -827,6 +831,8 @@ protected void applyFrame() {
827831
Preferences.setBoolean("pdex.completion", codeCompletionBox.isSelected());
828832
Preferences.setBoolean("pdex.suggest.imports", importSuggestionsBox.isSelected());
829833

834+
Preferences.setBoolean("run.use_gradle", useModernBuildSystem.isSelected());
835+
830836
for (Editor editor : base.getEditors()) {
831837
editor.applyPreferences();
832838
}
@@ -902,6 +908,11 @@ public void showFrame() {
902908
if (autoAssociateBox != null) {
903909
autoAssociateBox.setSelected(Preferences.getBoolean("platform.auto_file_type_associations")); //$NON-NLS-1$
904910
}
911+
912+
if(useModernBuildSystem != null) {
913+
useModernBuildSystem.setSelected(Preferences.getBoolean("run.use_gradle"));
914+
}
915+
905916
// The OK Button has to be set as the default button every time the
906917
// PrefWindow is to be displayed
907918
frame.getRootPane().setDefaultButton(okButton);

build/shared/lib/defaults.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ console.temp.days = 7
186186
console.scrollback.lines = 500
187187
console.scrollback.chars = 40000
188188

189+
# run java sketches with Gradle aka the Modern Build System
190+
run.use_gradle = false
191+
189192
# Any additional Java options when running.
190193
# If you change this and can't run things, it's your own durn fault.
191194
run.options =

java/gradle/src/main/kotlin/ProcessingPlugin.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
2525
val workingDir = project.findProperty("processing.workingDir") as String?
2626
val debugPort = project.findProperty("processing.debugPort") as String?
2727

28-
// Grab the settings from the most likely location
28+
// Grab the settings from the most likely location if not defined
2929
var settingsFolder = (project.findProperty("processing.settings") as String?)?.let { File(it) }
3030
if(settingsFolder == null) {
3131
val osName = System.getProperty("os.name").lowercase()
@@ -54,6 +54,8 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
5454
project.plugins.apply(JavaPlugin::class.java)
5555

5656
if(isProcessing){
57+
// TODO: Add support for grabbing Processing internals even if the user is not using the IDE
58+
5759
// Set the build directory to a temp file so it doesn't clutter up the sketch folder
5860
// Only if the build directory doesn't exist, otherwise proceed as normal
5961
if(!project.layout.buildDirectory.asFile.get().exists()) {
@@ -121,6 +123,7 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
121123
}
122124

123125
// TODO: Add support for top level .java files
126+
// TODO: Add support for customizing exports
124127

125128
// Add convenience tasks for running, presenting, and exporting the sketch outside of Processing
126129
if(!isProcessing) {

java/gradle/src/main/kotlin/ProcessingTask.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ abstract class ProcessingTask : SourceTask() {
115115
val deps = File(outputDirectory, "$sketchName.dependencies")
116116
deps.writeText(dependencies.joinToString("\n") { it.absolutePath })
117117

118-
// TODO: Add to the dependencies
118+
// TODO: Add renderer libraries to the dependencies
119119
val renderer = meta.sketchRenderer
120120
}
121121

java/src/processing/mode/java/JavaEditor.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,12 +639,14 @@ public void handleTweak() {
639639
}
640640

641641
protected void handleLaunch(boolean present, boolean tweak) {
642+
prepareRun();
643+
toolbar.activateRun();
644+
642645
if(this.service.getEnabled()){
643646
this.service.run();
644647
return;
645648
}
646-
prepareRun();
647-
toolbar.activateRun();
649+
648650
synchronized (runtimeLock) {
649651
runtimeLaunchRequested = true;
650652
}
@@ -673,6 +675,16 @@ protected void handleLaunch(boolean present, boolean tweak) {
673675
* session or performs standard stop action if not currently debugging.
674676
*/
675677
public void handleStop() {
678+
if(this.service.getEnabled()){
679+
// TODO: Improve Gradle UI Feedback
680+
toolbar.activateStop();
681+
this.service.stop();
682+
683+
toolbar.deactivateStop();
684+
toolbar.deactivateRun();
685+
return;
686+
}
687+
676688
if (debugger.isStarted()) {
677689
debugger.stopDebug();
678690

0 commit comments

Comments
 (0)