| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 803365d commit db4878b
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,7 +65,7 @@ public class PreferencesFrame { | |||
| 65 | 65 | ||
| 66 | 66 | ColorChooser selector; | |
| 67 | 67 | ||
| 68 | - // JCheckBox errorCheckerBox; | ||
| 68 | + JCheckBox errorCheckerBox; | ||
| 69 | 69 | JCheckBox warningsCheckerBox; | |
| 70 | 70 | JCheckBox codeCompletionBox; | |
| 71 | 71 | JCheckBox importSuggestionsBox; | |
@@ -270,8 +270,11 @@ public void mouseClicked(MouseEvent e) { | |||
| 270 | 270 | ||
| 271 | 271 | // [ ] Continuously check for errors - PDE X | |
| 272 | 272 | ||
| 273 | - // errorCheckerBox = | ||
| 274 | - // new JCheckBox(Language.text("preferences.continuously_check")); | ||
| 273 | + errorCheckerBox = | ||
| 274 | + new JCheckBox(Language.text("preferences.continuously_check")); | ||
| 275 | + errorCheckerBox.addItemListener(e -> { | ||
| 276 | + warningsCheckerBox.setEnabled(errorCheckerBox.isSelected()); | ||
| 277 | + }); | ||
| 275 | 278 | ||
| 276 | 279 | ||
| 277 | 280 | // [ ] Show Warnings - PDE X | |
@@ -407,9 +410,9 @@ public void actionPerformed(ActionEvent e) { | |||
| 407 | 410 | .addComponent(presentColor, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) | |
| 408 | 411 | .addComponent(editorAntialiasBox) | |
| 409 | 412 | .addComponent(inputMethodBox) | |
| 410 | - // .addGroup(layout.createSequentialGroup() | ||
| 411 | - // .addComponent(errorCheckerBox) | ||
| 412 | - // .addComponent(warningsCheckerBox)) | ||
| 413 | + .addGroup(layout.createSequentialGroup() | ||
| 414 | + .addComponent(errorCheckerBox) | ||
| 415 | + .addComponent(warningsCheckerBox)) | ||
| 413 | 416 | .addComponent(warningsCheckerBox) | |
| 414 | 417 | .addComponent(codeCompletionBox) | |
| 415 | 418 | .addComponent(importSuggestionsBox) | |
@@ -465,10 +468,9 @@ public void actionPerformed(ActionEvent e) { | |||
| 465 | 468 | .addComponent(presentColor)) | |
| 466 | 469 | .addComponent(editorAntialiasBox) | |
| 467 | 470 | .addComponent(inputMethodBox) | |
| 468 | - // .addGroup(layout.createParallelGroup() | ||
| 469 | - // .addComponent(errorCheckerBox) | ||
| 470 | - // .addComponent(warningsCheckerBox)) | ||
| 471 | - .addComponent(warningsCheckerBox) | ||
| 471 | + .addGroup(layout.createParallelGroup() | ||
| 472 | + .addComponent(errorCheckerBox) | ||
| 473 | + .addComponent(warningsCheckerBox)) | ||
| 472 | 474 | .addComponent(codeCompletionBox) | |
| 473 | 475 | .addComponent(importSuggestionsBox) | |
| 474 | 476 | .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) | |
@@ -655,7 +657,7 @@ protected void applyFrame() { | |||
| 655 | 657 | autoAssociateBox.isSelected()); | |
| 656 | 658 | } | |
| 657 | 659 | ||
| 658 | - // Preferences.setBoolean("pdex.errorCheckEnabled", errorCheckerBox.isSelected()); | ||
| 660 | + Preferences.setBoolean("pdex.errorCheckEnabled", errorCheckerBox.isSelected()); | ||
| 659 | 661 | Preferences.setBoolean("pdex.warningsEnabled", warningsCheckerBox.isSelected()); | |
| 660 | 662 | Preferences.setBoolean("pdex.completion", codeCompletionBox.isSelected()); | |
| 661 | 663 | // Preferences.setBoolean("pdex.completion.trigger", codeCompletionTriggerBox.isSelected()); | |
@@ -670,8 +672,9 @@ protected void applyFrame() { | |||
| 670 | 672 | public void showFrame() { | |
| 671 | 673 | editorAntialiasBox.setSelected(Preferences.getBoolean("editor.smooth")); //$NON-NLS-1$ | |
| 672 | 674 | inputMethodBox.setSelected(Preferences.getBoolean("editor.input_method_support")); //$NON-NLS-1$ | |
| 673 | - // errorCheckerBox.setSelected(Preferences.getBoolean("pdex.errorCheckEnabled")); | ||
| 675 | + errorCheckerBox.setSelected(Preferences.getBoolean("pdex.errorCheckEnabled")); | ||
| 674 | 676 | warningsCheckerBox.setSelected(Preferences.getBoolean("pdex.warningsEnabled")); | |
| 677 | + warningsCheckerBox.setEnabled(errorCheckerBox.isSelected()); | ||
| 675 | 678 | codeCompletionBox.setSelected(Preferences.getBoolean("pdex.completion")); | |
| 676 | 679 | //codeCompletionTriggerBox.setSelected(Preferences.getBoolean("pdex.completion.trigger")); | |
| 677 | 680 | //codeCompletionTriggerBox.setEnabled(codeCompletionBox.isSelected()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -306,7 +306,7 @@ void initLogger() { | |||
| 306 | 306 | // } | |
| 307 | 307 | ||
| 308 | 308 | ||
| 309 | - // static public volatile boolean errorCheckEnabled = true; | ||
| 309 | + static public volatile boolean errorCheckEnabled = true; | ||
| 310 | 310 | static public volatile boolean warningsEnabled = true; | |
| 311 | 311 | static public volatile boolean codeCompletionsEnabled = true; | |
| 312 | 312 | static public volatile boolean debugOutputEnabled = false; | |
@@ -325,7 +325,7 @@ void initLogger() { | |||
| 325 | 325 | */ | |
| 326 | 326 | volatile public static int codeCompletionTriggerLength = 1; | |
| 327 | 327 | ||
| 328 | - // static public final String prefErrorCheck = "pdex.errorCheckEnabled"; | ||
| 328 | + static public final String prefErrorCheck = "pdex.errorCheckEnabled"; | ||
| 329 | 329 | static public final String prefWarnings = "pdex.warningsEnabled"; | |
| 330 | 330 | static public final String prefDebugOP = "pdex.dbgOutput"; | |
| 331 | 331 | static public final String prefErrorLogs = "pdex.writeErrorLogs"; | |
@@ -351,7 +351,7 @@ void initLogger() { | |||
| 351 | 351 | public void loadPreferences() { | |
| 352 | 352 | Messages.log("Load PDEX prefs"); | |
| 353 | 353 | ensurePrefsExist(); | |
| 354 | - // errorCheckEnabled = Preferences.getBoolean(prefErrorCheck); | ||
| 354 | + errorCheckEnabled = Preferences.getBoolean(prefErrorCheck); | ||
| 355 | 355 | warningsEnabled = Preferences.getBoolean(prefWarnings); | |
| 356 | 356 | codeCompletionsEnabled = Preferences.getBoolean(COMPLETION_PREF); | |
| 357 | 357 | // DEBUG = Preferences.getBoolean(prefDebugOP); | |
@@ -370,7 +370,7 @@ public void loadPreferences() { | |||
| 370 | 370 | ||
| 371 | 371 | public void savePreferences() { | |
| 372 | 372 | Messages.log("Saving PDEX prefs"); | |
| 373 | - // Preferences.setBoolean(prefErrorCheck, errorCheckEnabled); | ||
| 373 | + Preferences.setBoolean(prefErrorCheck, errorCheckEnabled); | ||
| 374 | 374 | Preferences.setBoolean(prefWarnings, warningsEnabled); | |
| 375 | 375 | Preferences.setBoolean(COMPLETION_PREF, codeCompletionsEnabled); | |
| 376 | 376 | // Preferences.setBoolean(prefDebugOP, DEBUG); | |
@@ -429,8 +429,8 @@ public void loadSuggestionsMap() { | |||
| 429 | 429 | ||
| 430 | 430 | public void ensurePrefsExist() { | |
| 431 | 431 | //TODO: Need to do a better job of managing prefs. Think lists. | |
| 432 | - // if (Preferences.get(prefErrorCheck) == null) | ||
| 433 | - // Preferences.setBoolean(prefErrorCheck, errorCheckEnabled); | ||
| 432 | + if (Preferences.get(prefErrorCheck) == null) | ||
| 433 | + Preferences.setBoolean(prefErrorCheck, errorCheckEnabled); | ||
| 434 | 434 | if (Preferences.get(prefWarnings) == null) | |
| 435 | 435 | Preferences.setBoolean(prefWarnings, warningsEnabled); | |
| 436 | 436 | if (Preferences.get(COMPLETION_PREF) == null) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -152,6 +152,7 @@ public void sketchChanged() { | |||
| 152 | 152 | ||
| 153 | 153 | ||
| 154 | 154 | public void preferencesChanged() { | |
| 155 | + errorChecker.preferencesChanged(); | ||
| 155 | 156 | sketchChanged(); | |
| 156 | 157 | } | |
| 157 | 158 | ||
@@ -1026,16 +1027,22 @@ private static class ErrorChecker { | |||
| 1026 | 1027 | private ScheduledExecutorService scheduler; | |
| 1027 | 1028 | private volatile ScheduledFuture<?> scheduledUiUpdate = null; | |
| 1028 | 1029 | private volatile long nextUiUpdate = 0; | |
| 1030 | + private volatile boolean enabled = true; | ||
| 1029 | 1031 | ||
| 1030 | 1032 | private final Consumer<PreprocessedSketch> errorHandlerListener = this::handleSketchProblems; | |
| 1031 | 1033 | ||
| 1032 | 1034 | private JavaEditor editor; | |
| 1035 | + private PreprocessingService pps; | ||
| 1033 | 1036 | ||
| 1034 | 1037 | ||
| 1035 | 1038 | public ErrorChecker(JavaEditor editor, PreprocessingService pps) { | |
| 1036 | 1039 | this.editor = editor; | |
| 1040 | + this.pps = pps; | ||
| 1037 | 1041 | scheduler = Executors.newSingleThreadScheduledExecutor(); | |
| 1038 | - pps.registerListener(errorHandlerListener); | ||
| 1042 | + this.enabled = JavaMode.errorCheckEnabled; | ||
| 1043 | + if (enabled) { | ||
| 1044 | + pps.registerListener(errorHandlerListener); | ||
| 1045 | + } | ||
| 1039 | 1046 | } | |
| 1040 | 1047 | ||
| 1041 | 1048 | ||
@@ -1044,6 +1051,20 @@ public void notifySketchChanged() { | |||
| 1044 | 1051 | } | |
| 1045 | 1052 | ||
| 1046 | 1053 | ||
| 1054 | + public void preferencesChanged() { | ||
| 1055 | + if (enabled != JavaMode.errorCheckEnabled) { | ||
| 1056 | + enabled = JavaMode.errorCheckEnabled; | ||
| 1057 | + if (enabled) { | ||
| 1058 | + pps.registerListener(errorHandlerListener); | ||
| 1059 | + } else { | ||
| 1060 | + pps.unregisterListener(errorHandlerListener); | ||
| 1061 | + editor.setProblemList(Collections.emptyList()); | ||
| 1062 | + nextUiUpdate = 0; | ||
| 1063 | + } | ||
| 1064 | + } | ||
| 1065 | + } | ||
| 1066 | + | ||
| 1067 | + | ||
| 1047 | 1068 | public void dispose() { | |
| 1048 | 1069 | if (scheduler != null) { | |
| 1049 | 1070 | scheduler.shutdownNow(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments