@@ -106,9 +106,6 @@ public abstract class Editor extends JFrame implements RunnerListener {
106
106
107
107
// File and sketch menus for re-inserting items
108
108
private JMenu fileMenu ;
109
- // private JMenuItem saveMenuItem;
110
- // private JMenuItem saveAsMenuItem;
111
-
112
109
private JMenu sketchMenu ;
113
110
114
111
protected EditorHeader header ;
@@ -210,51 +207,12 @@ public void windowDeactivated(WindowEvent e) {
210
207
211
208
buildMenuBar ();
212
209
213
- /*
214
- //backgroundGradient = Toolkit.getLibImage("vertical-gradient.png");
215
- backgroundGradient = mode.getGradient("editor", 400, 400);
216
- JPanel contentPain = new JPanel() {
217
- @Override
218
- public void paintComponent(Graphics g) {
219
- // super.paintComponent(g);
220
- Dimension dim = getSize();
221
- g.drawImage(backgroundGradient, 0, 0, dim.width, dim.height, this);
222
- // g.setColor(Color.RED);
223
- // g.fillRect(0, 0, dim.width, dim.height);
224
- }
225
- };
226
- */
227
- //contentPain.setBorder(new EmptyBorder(0, 0, 0, 0));
228
- //System.out.println(contentPain.getBorder());
229
210
JPanel contentPain = new JPanel ();
230
-
231
- // JFrame f = new JFrame();
232
- // f.setContentPane(new JPanel() {
233
- // @Override
234
- // public void paintComponent(Graphics g) {
235
- //// super.paintComponent(g);
236
- // Dimension dim = getSize();
237
- // g.drawImage(backgroundGradient, 0, 0, dim.width, dim.height, this);
238
- //// g.setColor(Color.RED);
239
- //// g.fillRect(0, 0, dim.width, dim.height);
240
- // }
241
- // });
242
- // f.setResizable(true);
243
- // f.setVisible(true);
244
-
245
- //Container contentPain = getContentPane();
246
211
setContentPane (contentPain );
247
212
contentPain .setLayout (new BorderLayout ());
248
- // JPanel pain = new JPanel();
249
- // pain.setOpaque(false);
250
- // pain.setLayout(new BorderLayout());
251
- // contentPain.add(pain, BorderLayout.CENTER);
252
- // contentPain.setBorder(new EmptyBorder(10, 10, 10, 10));
253
213
254
214
Box box = Box .createVerticalBox ();
255
215
Box upper = Box .createVerticalBox ();
256
- // upper.setOpaque(false);
257
- // box.setOpaque(false);
258
216
259
217
rebuildModePopup ();
260
218
toolbar = createToolbar ();
@@ -393,23 +351,6 @@ public void windowGainedFocus(WindowEvent e) {
393
351
}
394
352
395
353
396
- /*
397
- protected List<ToolContribution> getCoreTools() {
398
- return coreTools;
399
- }
400
-
401
-
402
- public List<ToolContribution> getToolContribs() {
403
- return contribTools;
404
- }
405
-
406
-
407
- public void removeToolContrib(ToolContribution tc) {
408
- contribTools.remove(tc);
409
- }
410
- */
411
-
412
-
413
354
protected JEditTextArea createTextArea () {
414
355
return new JEditTextArea (new PdeTextAreaDefaults (mode ),
415
356
new PdeInputHandler (this ));
@@ -461,7 +402,7 @@ public boolean importData(TransferHandler.TransferSupport support) {
461
402
new DataFlavor ("text/uri-list;class=java.lang.String" );
462
403
463
404
if (transferable .isDataFlavorSupported (DataFlavor .javaFileListFlavor )) {
464
- List list = (List )
405
+ List <?> list = (List <?> )
465
406
transferable .getTransferData (DataFlavor .javaFileListFlavor );
466
407
for (Object o : list ) {
467
408
File file = (File ) o ;
@@ -565,6 +506,7 @@ public void rebuildModePopup() {
565
506
Toolkit .setMenuMnemsInside (modePopup );
566
507
}
567
508
509
+
568
510
// Re-select the old checkbox, because it was automatically
569
511
// updated by Java, even though the Mode could not be changed.
570
512
// https://github.com/processing/processing/issues/2615
@@ -579,27 +521,17 @@ private void reselectMode() {
579
521
}
580
522
}
581
523
524
+
582
525
public JPopupMenu getModePopup () {
583
526
return modePopup .getPopupMenu ();
584
527
}
585
528
586
529
587
- // public JMenu getModeMenu() {
588
- // return modePopup;
589
- // }
590
-
591
-
592
530
public EditorConsole getConsole () {
593
531
return console ;
594
532
}
595
533
596
534
597
-
598
- // public Settings getTheme() {
599
- // return mode.getTheme();
600
- // }
601
-
602
-
603
535
public EditorHeader createHeader () {
604
536
return new EditorHeader (this );
605
537
}
@@ -622,31 +554,6 @@ public void rebuildToolbar() {
622
554
abstract public Formatter createFormatter ();
623
555
624
556
625
- // protected void setPlacement(int[] location) {
626
- // setBounds(location[0], location[1], location[2], location[3]);
627
- // if (location[4] != 0) {
628
- // splitPane.setDividerLocation(location[4]);
629
- // }
630
- // }
631
- //
632
- //
633
- // protected int[] getPlacement() {
634
- // int[] location = new int[5];
635
- //
636
- // // Get the dimensions of the Frame
637
- // Rectangle bounds = getBounds();
638
- // location[0] = bounds.x;
639
- // location[1] = bounds.y;
640
- // location[2] = bounds.width;
641
- // location[3] = bounds.height;
642
- //
643
- // // Get the current placement of the divider
644
- // location[4] = splitPane.getDividerLocation();
645
- //
646
- // return location;
647
- // }
648
-
649
-
650
557
protected void setDividerLocation (int pos ) {
651
558
splitPane .setDividerLocation (pos );
652
559
}
@@ -671,43 +578,6 @@ public void applyPreferences() {
671
578
textarea .repaint ();
672
579
673
580
console .updateAppearance ();
674
-
675
- // All of this code was specific to using an external editor.
676
- /*
677
- // // apply the setting for 'use external editor'
678
- // boolean external = Preferences.getBoolean("editor.external");
679
- // textarea.setEditable(!external);
680
- // saveMenuItem.setEnabled(!external);
681
- // saveAsMenuItem.setEnabled(!external);
682
-
683
- TextAreaPainter painter = textarea.getPainter();
684
- // if (external) {
685
- // // disable line highlight and turn off the caret when disabling
686
- // Color color = mode.getColor("editor.external.bgcolor");
687
- // painter.setBackground(color);
688
- // painter.setLineHighlightEnabled(false);
689
- // textarea.setCaretVisible(false);
690
- // } else {
691
- Color color = mode.getColor("editor.bgcolor");
692
- painter.setBackground(color);
693
- boolean highlight = Preferences.getBoolean("editor.linehighlight");
694
- painter.setLineHighlightEnabled(highlight);
695
- textarea.setCaretVisible(true);
696
- // }
697
-
698
- // apply changes to the font size for the editor
699
- // painter.setFont(Preferences.getFont("editor.font"));
700
-
701
- // in case tab expansion stuff has changed
702
- // removing this, just checking prefs directly instead
703
- // listener.applyPreferences();
704
-
705
- // in case moved to a new location
706
- // For 0125, changing to async version (to be implemented later)
707
- //sketchbook.rebuildMenus();
708
- // For 0126, moved into Base, which will notify all editors.
709
- //base.rebuildMenusAsync();
710
- */
711
581
}
712
582
713
583
@@ -2461,6 +2331,7 @@ protected void handleOpenInternal(String path) throws EditorException {
2461
2331
final String defaultName = parentName + "." + mode .getDefaultExtension ();
2462
2332
final File altFile = new File (file .getParent (), defaultName );
2463
2333
2334
+ //noinspection StatementWithEmptyBody
2464
2335
if (defaultName .equals (file .getName ())) {
2465
2336
// no beef with this guy
2466
2337
} else if (altFile .exists ()) {
@@ -2512,7 +2383,9 @@ protected void handleOpenInternal(String path) throws EditorException {
2512
2383
}
2513
2384
2514
2385
// remove the original file, so user doesn't get confused
2515
- origPdeFile .delete ();
2386
+ if (!origPdeFile .delete ()) {
2387
+ Messages .loge ("Could not delete " + origPdeFile );
2388
+ }
2516
2389
2517
2390
// update with the new path
2518
2391
path = properPdeFile .getAbsolutePath ();
@@ -2612,10 +2485,11 @@ protected void handleSaveImpl() {
2612
2485
public boolean handleSaveAs () {
2613
2486
statusNotice (Language .text ("editor.status.saving" ));
2614
2487
try {
2615
- if (sketch .saveAs ()) {
2488
+ //noinspection StatementWithEmptyBody
2489
+ if (!sketch .saveAs ()) {
2490
+ // No longer showing "Done" message except in cases where a
2491
+ // progress bar is necessary. Message will come from Sketch.
2616
2492
//statusNotice(Language.text("editor.status.saving.done"));
2617
- // status is now printed from Sketch so that "Done Saving."
2618
- // is only printed after Save As when progress bar is shown.
2619
2493
} else {
2620
2494
statusNotice (Language .text ("editor.status.saving.canceled" ));
2621
2495
return false ;
@@ -2628,29 +2502,6 @@ public boolean handleSaveAs() {
2628
2502
}
2629
2503
2630
2504
2631
- /*
2632
- public void handleSaveAs() {
2633
- statusNotice(Language.text("editor.status.saving"));
2634
- sketch.saveAs();
2635
- }
2636
-
2637
-
2638
- public void handleSaveAsSuccess() {
2639
- statusNotice(Language.text("editor.status.saving.done"));
2640
- }
2641
-
2642
-
2643
- public void handleSaveAsCanceled() {
2644
- statusNotice(Language.text("editor.status.saving.canceled"));
2645
- }
2646
-
2647
-
2648
- public void handleSaveAsError(Exception e) {
2649
- statusError(e);
2650
- }
2651
- */
2652
-
2653
-
2654
2505
/**
2655
2506
* Handler for File → Page Setup.
2656
2507
*/
@@ -2675,7 +2526,9 @@ public void handlePrint() {
2675
2526
2676
2527
StringBuilder html = new StringBuilder ("<html><body>" );
2677
2528
for (SketchCode tab : sketch .getCode ()) {
2678
- html .append ("<b>" + tab .getPrettyName () + "</b><br>" );
2529
+ html .append ("<b>" );
2530
+ html .append (tab .getPrettyName ());
2531
+ html .append ("</b><br>" );
2679
2532
html .append (textarea .getTextAsHtml ((SyntaxDocument )tab .getDocument ()));
2680
2533
html .append ("<br>" );
2681
2534
}
@@ -3197,24 +3050,7 @@ public TextAreaPopup() {
3197
3050
3198
3051
// if no text is selected, disable copy and cut menu items
3199
3052
public void show (Component component , int x , int y ) {
3200
- // if (textarea.isSelectionActive()) {
3201
- // cutItem.setEnabled(true);
3202
- // copyItem.setEnabled(true);
3203
- // discourseItem.setEnabled(true);
3204
- //
3205
- //// String sel = textarea.getSelectedText().trim();
3206
- //// String referenceFile = mode.lookupReference(sel);
3207
- //// referenceItem.setEnabled(referenceFile != null);
3208
- //
3209
- // } else {
3210
- // cutItem.setEnabled(false);
3211
- // copyItem.setEnabled(false);
3212
- // discourseItem.setEnabled(false);
3213
- //// referenceItem.setEnabled(false);
3214
- // }
3215
-
3216
3053
// Centralize the checks for each item at the Action.
3217
- // boolean active = textarea.isSelectionActive();
3218
3054
cutItem .setEnabled (cutAction .canDo ());
3219
3055
copyItem .setEnabled (copyAction .canDo ());
3220
3056
discourseItem .setEnabled (copyAsHtmlAction .canDo ());
0 commit comments