Skip to content

Commit aef561a

Browse files
committed
a few minor warnings, remove commented code
1 parent ad8e382 commit aef561a

File tree

1 file changed

+14
-178
lines changed

1 file changed

+14
-178
lines changed

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

+14-178
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ public abstract class Editor extends JFrame implements RunnerListener {
106106

107107
// File and sketch menus for re-inserting items
108108
private JMenu fileMenu;
109-
// private JMenuItem saveMenuItem;
110-
// private JMenuItem saveAsMenuItem;
111-
112109
private JMenu sketchMenu;
113110

114111
protected EditorHeader header;
@@ -210,51 +207,12 @@ public void windowDeactivated(WindowEvent e) {
210207

211208
buildMenuBar();
212209

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());
229210
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();
246211
setContentPane(contentPain);
247212
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));
253213

254214
Box box = Box.createVerticalBox();
255215
Box upper = Box.createVerticalBox();
256-
// upper.setOpaque(false);
257-
// box.setOpaque(false);
258216

259217
rebuildModePopup();
260218
toolbar = createToolbar();
@@ -393,23 +351,6 @@ public void windowGainedFocus(WindowEvent e) {
393351
}
394352

395353

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-
413354
protected JEditTextArea createTextArea() {
414355
return new JEditTextArea(new PdeTextAreaDefaults(mode),
415356
new PdeInputHandler(this));
@@ -461,7 +402,7 @@ public boolean importData(TransferHandler.TransferSupport support) {
461402
new DataFlavor("text/uri-list;class=java.lang.String");
462403

463404
if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
464-
List list = (List)
405+
List<?> list = (List<?>)
465406
transferable.getTransferData(DataFlavor.javaFileListFlavor);
466407
for (Object o : list) {
467408
File file = (File) o;
@@ -565,6 +506,7 @@ public void rebuildModePopup() {
565506
Toolkit.setMenuMnemsInside(modePopup);
566507
}
567508

509+
568510
// Re-select the old checkbox, because it was automatically
569511
// updated by Java, even though the Mode could not be changed.
570512
// https://github.com/processing/processing/issues/2615
@@ -579,27 +521,17 @@ private void reselectMode() {
579521
}
580522
}
581523

524+
582525
public JPopupMenu getModePopup() {
583526
return modePopup.getPopupMenu();
584527
}
585528

586529

587-
// public JMenu getModeMenu() {
588-
// return modePopup;
589-
// }
590-
591-
592530
public EditorConsole getConsole() {
593531
return console;
594532
}
595533

596534

597-
598-
// public Settings getTheme() {
599-
// return mode.getTheme();
600-
// }
601-
602-
603535
public EditorHeader createHeader() {
604536
return new EditorHeader(this);
605537
}
@@ -622,31 +554,6 @@ public void rebuildToolbar() {
622554
abstract public Formatter createFormatter();
623555

624556

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-
650557
protected void setDividerLocation(int pos) {
651558
splitPane.setDividerLocation(pos);
652559
}
@@ -671,43 +578,6 @@ public void applyPreferences() {
671578
textarea.repaint();
672579

673580
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-
*/
711581
}
712582

713583

@@ -2461,6 +2331,7 @@ protected void handleOpenInternal(String path) throws EditorException {
24612331
final String defaultName = parentName + "." + mode.getDefaultExtension();
24622332
final File altFile = new File(file.getParent(), defaultName);
24632333

2334+
//noinspection StatementWithEmptyBody
24642335
if (defaultName.equals(file.getName())) {
24652336
// no beef with this guy
24662337
} else if (altFile.exists()) {
@@ -2512,7 +2383,9 @@ protected void handleOpenInternal(String path) throws EditorException {
25122383
}
25132384

25142385
// 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+
}
25162389

25172390
// update with the new path
25182391
path = properPdeFile.getAbsolutePath();
@@ -2612,10 +2485,11 @@ protected void handleSaveImpl() {
26122485
public boolean handleSaveAs() {
26132486
statusNotice(Language.text("editor.status.saving"));
26142487
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.
26162492
//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.
26192493
} else {
26202494
statusNotice(Language.text("editor.status.saving.canceled"));
26212495
return false;
@@ -2628,29 +2502,6 @@ public boolean handleSaveAs() {
26282502
}
26292503

26302504

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-
26542505
/**
26552506
* Handler for File &rarr; Page Setup.
26562507
*/
@@ -2675,7 +2526,9 @@ public void handlePrint() {
26752526

26762527
StringBuilder html = new StringBuilder("<html><body>");
26772528
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>");
26792532
html.append(textarea.getTextAsHtml((SyntaxDocument)tab.getDocument()));
26802533
html.append("<br>");
26812534
}
@@ -3197,24 +3050,7 @@ public TextAreaPopup() {
31973050

31983051
// if no text is selected, disable copy and cut menu items
31993052
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-
32163053
// Centralize the checks for each item at the Action.
3217-
// boolean active = textarea.isSelectionActive();
32183054
cutItem.setEnabled(cutAction.canDo());
32193055
copyItem.setEnabled(copyAction.canDo());
32203056
discourseItem.setEnabled(copyAsHtmlAction.canDo());

0 commit comments

Comments
 (0)