mirror of
https://github.com/processing/processing4.git
synced 2026-01-28 02:41:08 +01:00
clean up warnings, swap in some lambdas
This commit is contained in:
@@ -25,11 +25,9 @@ package processing.mode.java;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -78,7 +76,7 @@ public class JavaEditor extends Editor {
|
||||
JMenu modeMenu;
|
||||
// protected JMenuItem inspectorItem;
|
||||
|
||||
static final int ERROR_TAB_INDEX = 0;
|
||||
// static final int ERROR_TAB_INDEX = 0;
|
||||
|
||||
private boolean hasJavaTabs;
|
||||
private boolean javaTabWarned;
|
||||
@@ -87,13 +85,12 @@ public class JavaEditor extends Editor {
|
||||
|
||||
protected Debugger debugger;
|
||||
|
||||
private InspectMode inspect;
|
||||
private ShowUsage usage;
|
||||
private Rename rename;
|
||||
final private InspectMode inspect;
|
||||
final private ShowUsage usage;
|
||||
final private Rename rename;
|
||||
final private ErrorChecker errorChecker;
|
||||
|
||||
private boolean pdexEnabled = true;
|
||||
|
||||
private ErrorChecker errorChecker;
|
||||
private boolean pdexEnabled;
|
||||
|
||||
// set true to show AST debugging window
|
||||
static private final boolean SHOW_AST_VIEWER = false;
|
||||
@@ -252,11 +249,7 @@ public class JavaEditor extends Editor {
|
||||
//String appTitle = JavaToolbar.getTitle(JavaToolbar.EXPORT, false);
|
||||
String appTitle = Language.text("menu.file.export_application");
|
||||
JMenuItem exportApplication = Toolkit.newJMenuItemShift(appTitle, 'E');
|
||||
exportApplication.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleExportApplication();
|
||||
}
|
||||
});
|
||||
exportApplication.addActionListener(e -> handleExportApplication());
|
||||
|
||||
return buildFileMenu(new JMenuItem[] { exportApplication });
|
||||
}
|
||||
@@ -264,40 +257,23 @@ public class JavaEditor extends Editor {
|
||||
|
||||
public JMenu buildSketchMenu() {
|
||||
JMenuItem runItem = Toolkit.newJMenuItem(Language.text("menu.sketch.run"), 'R');
|
||||
runItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleRun();
|
||||
}
|
||||
});
|
||||
runItem.addActionListener(e -> handleRun());
|
||||
|
||||
JMenuItem presentItem = Toolkit.newJMenuItemShift(Language.text("menu.sketch.present"), 'R');
|
||||
presentItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handlePresent();
|
||||
}
|
||||
});
|
||||
presentItem.addActionListener(e -> handlePresent());
|
||||
|
||||
JMenuItem stopItem = new JMenuItem(Language.text("menu.sketch.stop"));
|
||||
stopItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (isDebuggerEnabled()) {
|
||||
Messages.log("Invoked 'Stop' menu item");
|
||||
debugger.stopDebug();
|
||||
} else {
|
||||
handleStop();
|
||||
}
|
||||
stopItem.addActionListener(e -> {
|
||||
if (isDebuggerEnabled()) {
|
||||
Messages.log("Invoked 'Stop' menu item");
|
||||
debugger.stopDebug();
|
||||
} else {
|
||||
handleStop();
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem tweakItem = Toolkit.newJMenuItemShift(Language.text("menu.sketch.tweak"), 'T');
|
||||
// tweakItem.setSelected(JavaMode.enableTweak);
|
||||
tweakItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// JavaMode.enableTweak = true;
|
||||
// handleRun();
|
||||
handleTweak();
|
||||
}
|
||||
});
|
||||
tweakItem.addActionListener(e -> handleTweak());
|
||||
|
||||
return buildSketchMenu(new JMenuItem[] {
|
||||
runItem, presentItem, tweakItem, stopItem
|
||||
@@ -312,52 +288,36 @@ public class JavaEditor extends Editor {
|
||||
// macosx already has its own about menu
|
||||
if (!Platform.isMacOS()) {
|
||||
item = new JMenuItem(Language.text("menu.help.about"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new About(JavaEditor.this);
|
||||
}
|
||||
});
|
||||
item.addActionListener(e -> new About(JavaEditor.this));
|
||||
menu.add(item);
|
||||
}
|
||||
|
||||
item = new JMenuItem(Language.text("menu.help.welcome"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
new Welcome(base, Preferences.getSketchbookPath().equals(Preferences.getOldSketchbookPath()));
|
||||
} catch (IOException ioe) {
|
||||
Messages.showWarning("Unwelcome Error",
|
||||
"Please report this error to\n" +
|
||||
"https://github.com/processing/processing/issues", ioe);
|
||||
}
|
||||
item.addActionListener(e -> {
|
||||
try {
|
||||
new Welcome(base, Preferences.getSketchbookPath().equals(Preferences.getOldSketchbookPath()));
|
||||
} catch (IOException ioe) {
|
||||
Messages.showWarning("Unwelcome Error",
|
||||
"Please report this error to\n" +
|
||||
"https://github.com/processing/processing/issues", ioe);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(Language.text("menu.help.environment"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showReference("environment" + File.separator + "index.html");
|
||||
}
|
||||
});
|
||||
item.addActionListener(e -> showReference("environment" + File.separator + "index.html"));
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(Language.text("menu.help.reference"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showReference("index.html");
|
||||
}
|
||||
});
|
||||
item.addActionListener(e -> showReference("index.html"));
|
||||
menu.add(item);
|
||||
|
||||
item = Toolkit.newJMenuItemShift(Language.text("menu.help.find_in_reference"), 'F');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (textarea.isSelectionActive()) {
|
||||
handleFindReference();
|
||||
} else {
|
||||
statusNotice(Language.text("editor.status.find_reference.select_word_first"));
|
||||
}
|
||||
item.addActionListener(e -> {
|
||||
if (textarea.isSelectionActive()) {
|
||||
handleFindReference();
|
||||
} else {
|
||||
statusNotice(Language.text("editor.status.find_reference.select_word_first"));
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
@@ -416,20 +376,20 @@ public class JavaEditor extends Editor {
|
||||
|
||||
@Override
|
||||
public void menuSelected(MenuEvent e) {
|
||||
boolean isCoreToolMenuItemAdded = false;
|
||||
boolean isContribToolMenuItemAdded = false;
|
||||
boolean coreToolMenuItemAdded;
|
||||
boolean contribToolMenuItemAdded;
|
||||
|
||||
List<ToolContribution> contribTools = base.getToolContribs();
|
||||
// Adding this in in case a reference folder is added for MovieMaker, or in case
|
||||
// other core tools are introduced later
|
||||
isCoreToolMenuItemAdded = addToolReferencesToSubMenu(base.getCoreTools(), toolRefSubmenu);
|
||||
coreToolMenuItemAdded = addToolReferencesToSubMenu(base.getCoreTools(), toolRefSubmenu);
|
||||
|
||||
if (isCoreToolMenuItemAdded && !contribTools.isEmpty())
|
||||
if (coreToolMenuItemAdded && !contribTools.isEmpty())
|
||||
toolRefSubmenu.addSeparator();
|
||||
|
||||
isContribToolMenuItemAdded = addToolReferencesToSubMenu(contribTools, toolRefSubmenu);
|
||||
contribToolMenuItemAdded = addToolReferencesToSubMenu(contribTools, toolRefSubmenu);
|
||||
|
||||
if (!isContribToolMenuItemAdded && !isCoreToolMenuItemAdded) {
|
||||
if (!contribToolMenuItemAdded && !coreToolMenuItemAdded) {
|
||||
toolRefSubmenu.removeAll(); // in case a separator was added
|
||||
final JMenuItem emptyMenuItem = new JMenuItem(Language.text("menu.help.empty"));
|
||||
emptyMenuItem.setEnabled(false);
|
||||
@@ -438,7 +398,7 @@ public class JavaEditor extends Editor {
|
||||
emptyMenuItem.setFocusPainted(false);
|
||||
toolRefSubmenu.add(emptyMenuItem);
|
||||
}
|
||||
else if (!isContribToolMenuItemAdded && !contribTools.isEmpty()) {
|
||||
else if (!contribToolMenuItemAdded && !contribTools.isEmpty()) {
|
||||
// re-populate the menu to get rid of terminal separator
|
||||
toolRefSubmenu.removeAll();
|
||||
addToolReferencesToSubMenu(base.getCoreTools(), toolRefSubmenu);
|
||||
@@ -463,43 +423,23 @@ public class JavaEditor extends Editor {
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(Language.text("menu.help.getting_started"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Platform.openURL(Language.text("menu.help.getting_started.url"));
|
||||
}
|
||||
});
|
||||
item.addActionListener(e -> Platform.openURL(Language.text("menu.help.getting_started.url")));
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(Language.text("menu.help.troubleshooting"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Platform.openURL(Language.text("menu.help.troubleshooting.url"));
|
||||
}
|
||||
});
|
||||
item.addActionListener(e -> Platform.openURL(Language.text("menu.help.troubleshooting.url")));
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(Language.text("menu.help.faq"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Platform.openURL(Language.text("menu.help.faq.url"));
|
||||
}
|
||||
});
|
||||
item.addActionListener(e -> Platform.openURL(Language.text("menu.help.faq.url")));
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(Language.text("menu.help.foundation"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Platform.openURL(Language.text("menu.help.foundation.url"));
|
||||
}
|
||||
});
|
||||
item.addActionListener(e -> Platform.openURL(Language.text("menu.help.foundation.url")));
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(Language.text("menu.help.visit"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Platform.openURL(Language.text("menu.help.visit.url"));
|
||||
}
|
||||
});
|
||||
item.addActionListener(e -> Platform.openURL(Language.text("menu.help.visit.url")));
|
||||
menu.add(item);
|
||||
|
||||
return menu;
|
||||
@@ -524,18 +464,10 @@ public class JavaEditor extends Editor {
|
||||
*/
|
||||
private boolean addLibReferencesToSubMenu(List<Library> libsList, JMenu subMenu) {
|
||||
boolean isItemAdded = false;
|
||||
Iterator<Library> iter = libsList.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Library libContrib = iter.next();
|
||||
for (Library libContrib : libsList) {
|
||||
if (libContrib.hasReference()) {
|
||||
JMenuItem libRefItem = new JMenuItem(libContrib.getName());
|
||||
libRefItem.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
showReferenceFile(libContrib.getReferenceIndexFile());
|
||||
}
|
||||
});
|
||||
libRefItem.addActionListener(arg0 -> showReferenceFile(libContrib.getReferenceIndexFile()));
|
||||
subMenu.add(libRefItem);
|
||||
isItemAdded = true;
|
||||
}
|
||||
@@ -559,19 +491,11 @@ public class JavaEditor extends Editor {
|
||||
*/
|
||||
private boolean addToolReferencesToSubMenu(List<ToolContribution> toolsList, JMenu subMenu) {
|
||||
boolean isItemAdded = false;
|
||||
Iterator<ToolContribution> iter = toolsList.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final ToolContribution toolContrib = iter.next();
|
||||
for (ToolContribution toolContrib : toolsList) {
|
||||
final File toolRef = new File(toolContrib.getFolder(), "reference/index.html");
|
||||
if (toolRef.exists()) {
|
||||
JMenuItem libRefItem = new JMenuItem(toolContrib.getName());
|
||||
libRefItem.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
showReferenceFile(toolRef);
|
||||
}
|
||||
});
|
||||
libRefItem.addActionListener(arg0 -> showReferenceFile(toolRef));
|
||||
subMenu.add(libRefItem);
|
||||
isItemAdded = true;
|
||||
}
|
||||
@@ -591,37 +515,6 @@ public class JavaEditor extends Editor {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
/**
|
||||
* Called by Sketch → Export.
|
||||
* Handles calling the export() function on sketch, and
|
||||
* queues all the gui status stuff that comes along with it.
|
||||
* <p/>
|
||||
* Made synchronized to (hopefully) avoid problems of people
|
||||
* hitting export twice, quickly, and horking things up.
|
||||
*/
|
||||
/*
|
||||
public void handleExportApplet() {
|
||||
if (handleExportCheckModified()) {
|
||||
toolbar.activate(JavaToolbar.EXPORT);
|
||||
try {
|
||||
boolean success = jmode.handleExportApplet(sketch);
|
||||
if (success) {
|
||||
File appletFolder = new File(sketch.getFolder(), "applet");
|
||||
Base.openFolder(appletFolder);
|
||||
statusNotice("Done exporting.");
|
||||
} else {
|
||||
// error message will already be visible
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
statusError(e);
|
||||
}
|
||||
toolbar.deactivate(JavaToolbar.EXPORT);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Handler for Sketch → Export Application
|
||||
*/
|
||||
@@ -634,7 +527,7 @@ public class JavaEditor extends Editor {
|
||||
if (exportApplicationPrompt()) {
|
||||
Platform.openFolder(sketch.getFolder());
|
||||
statusNotice(Language.text("export.notice.exporting.done"));
|
||||
} else {
|
||||
//} else {
|
||||
// error message will already be visible
|
||||
// or there was no error, in which case it was canceled.
|
||||
}
|
||||
@@ -698,11 +591,9 @@ public class JavaEditor extends Editor {
|
||||
// final JCheckBox linuxButton = new JCheckBox("Linux");
|
||||
|
||||
windowsButton.setSelected(Preferences.getBoolean(EXPORT_WINDOWS));
|
||||
windowsButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
Preferences.setBoolean(EXPORT_WINDOWS, windowsButton.isSelected());
|
||||
updateExportButton();
|
||||
}
|
||||
windowsButton.addItemListener(e -> {
|
||||
Preferences.setBoolean(EXPORT_WINDOWS, windowsButton.isSelected());
|
||||
updateExportButton();
|
||||
});
|
||||
|
||||
// Only possible to export OS X applications on OS X
|
||||
@@ -711,11 +602,9 @@ public class JavaEditor extends Editor {
|
||||
Preferences.setBoolean(EXPORT_MACOSX, false);
|
||||
}
|
||||
macosButton.setSelected(Preferences.getBoolean(EXPORT_MACOSX));
|
||||
macosButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
Preferences.setBoolean(EXPORT_MACOSX, macosButton.isSelected());
|
||||
updateExportButton();
|
||||
}
|
||||
macosButton.addItemListener(e -> {
|
||||
Preferences.setBoolean(EXPORT_MACOSX, macosButton.isSelected());
|
||||
updateExportButton();
|
||||
});
|
||||
if (!Platform.isMacOS()) {
|
||||
macosButton.setEnabled(false);
|
||||
@@ -723,11 +612,9 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
|
||||
linuxButton.setSelected(Preferences.getBoolean(EXPORT_LINUX));
|
||||
linuxButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
Preferences.setBoolean(EXPORT_LINUX, linuxButton.isSelected());
|
||||
updateExportButton();
|
||||
}
|
||||
linuxButton.addItemListener(e -> {
|
||||
Preferences.setBoolean(EXPORT_LINUX, linuxButton.isSelected());
|
||||
updateExportButton();
|
||||
});
|
||||
|
||||
updateExportButton(); // do the initial enable/disable based on prefs.txt
|
||||
@@ -752,22 +639,16 @@ public class JavaEditor extends Editor {
|
||||
|
||||
final JCheckBox showStopButton = new JCheckBox(Language.text("export.options.show_stop_button"));
|
||||
showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
|
||||
showStopButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
Preferences.setBoolean("export.application.stop", showStopButton.isSelected());
|
||||
}
|
||||
});
|
||||
showStopButton.addItemListener(e -> Preferences.setBoolean("export.application.stop", showStopButton.isSelected()));
|
||||
showStopButton.setEnabled(Preferences.getBoolean("export.application.present"));
|
||||
showStopButton.setBorder(new EmptyBorder(3, 13 + indent, 6, 13));
|
||||
|
||||
final JCheckBox presentButton = new JCheckBox(Language.text("export.options.present"));
|
||||
presentButton.setSelected(Preferences.getBoolean("export.application.present"));
|
||||
presentButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
boolean sal = presentButton.isSelected();
|
||||
Preferences.setBoolean("export.application.present", sal);
|
||||
showStopButton.setEnabled(sal);
|
||||
}
|
||||
presentButton.addItemListener(e -> {
|
||||
boolean sal = presentButton.isSelected();
|
||||
Preferences.setBoolean("export.application.present", sal);
|
||||
showStopButton.setEnabled(sal);
|
||||
});
|
||||
presentButton.setBorder(new EmptyBorder(3, 13, 3, 13));
|
||||
|
||||
@@ -872,15 +753,13 @@ public class JavaEditor extends Editor {
|
||||
//new JCheckBox(Language.text("export.embed_java.for") + " " + platformName);
|
||||
new JCheckBox(Language.interpolate("export.include_java", platformName));
|
||||
embedJavaButton.setSelected(embed);
|
||||
embedJavaButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
boolean selected = embedJavaButton.isSelected();
|
||||
Preferences.setBoolean("export.application.embed_java", selected);
|
||||
if (selected) {
|
||||
warningLabel.setText(embedWarning);
|
||||
} else {
|
||||
warningLabel.setText(nopeWarning);
|
||||
}
|
||||
embedJavaButton.addItemListener(e -> {
|
||||
boolean selected = embedJavaButton.isSelected();
|
||||
Preferences.setBoolean("export.application.embed_java", selected);
|
||||
if (selected) {
|
||||
warningLabel.setText(embedWarning);
|
||||
} else {
|
||||
warningLabel.setText(nopeWarning);
|
||||
}
|
||||
});
|
||||
embedJavaButton.setBorder(new EmptyBorder(3, 13, 3, 13));
|
||||
@@ -966,29 +845,19 @@ public class JavaEditor extends Editor {
|
||||
final JDialog dialog = new JDialog(this, Language.text("export"), true);
|
||||
dialog.setContentPane(optionPane);
|
||||
|
||||
exportButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
optionPane.setValue(exportButton);
|
||||
}
|
||||
});
|
||||
exportButton.addActionListener(e -> optionPane.setValue(exportButton));
|
||||
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
optionPane.setValue(cancelButton);
|
||||
}
|
||||
});
|
||||
cancelButton.addActionListener(e -> optionPane.setValue(cancelButton));
|
||||
|
||||
optionPane.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
String prop = e.getPropertyName();
|
||||
optionPane.addPropertyChangeListener(e -> {
|
||||
String prop = e.getPropertyName();
|
||||
|
||||
if (dialog.isVisible() &&
|
||||
(e.getSource() == optionPane) &&
|
||||
(prop.equals(JOptionPane.VALUE_PROPERTY))) {
|
||||
// If you were going to check something before
|
||||
// closing the window, you'd do it here.
|
||||
dialog.setVisible(false);
|
||||
}
|
||||
if (dialog.isVisible() &&
|
||||
(e.getSource() == optionPane) &&
|
||||
(prop.equals(JOptionPane.VALUE_PROPERTY))) {
|
||||
// If you were going to check something before
|
||||
// closing the window, you'd do it here.
|
||||
dialog.setVisible(false);
|
||||
}
|
||||
});
|
||||
dialog.pack();
|
||||
@@ -1442,7 +1311,7 @@ public class JavaEditor extends Editor {
|
||||
for (int i = 0; i < sketch.getCodeCount(); i++) {
|
||||
SketchCode tab = sketch.getCode(i);
|
||||
String code = tab.getProgram();
|
||||
String lines[] = code.split("\\r?\\n"); // newlines not included
|
||||
String[] lines = code.split("\\r?\\n"); // newlines not included
|
||||
//System.out.println(code);
|
||||
|
||||
// scan code for breakpoint comments
|
||||
@@ -1494,7 +1363,7 @@ public class JavaEditor extends Editor {
|
||||
tab.load();
|
||||
String code = tab.getProgram();
|
||||
//System.out.println("code: " + code);
|
||||
String lines[] = code.split("\\r?\\n"); // newlines not included
|
||||
String[] lines = code.split("\\r?\\n"); // newlines not included
|
||||
for (LineBreakpoint bp : bps) {
|
||||
//System.out.println("adding bp: " + bp.lineID());
|
||||
lines[bp.lineID().lineIdx()] += breakpointMarkerComment;
|
||||
@@ -1527,14 +1396,11 @@ public class JavaEditor extends Editor {
|
||||
addBreakpointComments(tabFilename);
|
||||
}
|
||||
} else {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (String tabFilename : modified) {
|
||||
addBreakpointComments(tabFilename);
|
||||
}
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(() -> {
|
||||
for (String tabFilename : modified) {
|
||||
addBreakpointComments(tabFilename);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// if file location has changed, update autosaver
|
||||
@@ -1714,7 +1580,7 @@ public class JavaEditor extends Editor {
|
||||
continue;
|
||||
}
|
||||
|
||||
Library library = null;
|
||||
Library library;
|
||||
try {
|
||||
library = this.getMode().getLibrary(entry);
|
||||
if (library == null) {
|
||||
@@ -1773,32 +1639,26 @@ public class JavaEditor extends Editor {
|
||||
JPanel panelButtons = new JPanel(new FlowLayout(FlowLayout.CENTER, 8, 2));
|
||||
|
||||
JButton btnRunSave = new JButton("Save and Run");
|
||||
btnRunSave.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleSave(true);
|
||||
if (dontRedisplay.isSelected()) {
|
||||
JavaMode.autoSavePromptEnabled = !dontRedisplay.isSelected();
|
||||
JavaMode.defaultAutoSaveEnabled = true;
|
||||
jmode.savePreferences();
|
||||
}
|
||||
autoSaveDialog.dispose();
|
||||
}
|
||||
});
|
||||
btnRunSave.addActionListener(e -> {
|
||||
handleSave(true);
|
||||
if (dontRedisplay.isSelected()) {
|
||||
JavaMode.autoSavePromptEnabled = !dontRedisplay.isSelected();
|
||||
JavaMode.defaultAutoSaveEnabled = true;
|
||||
jmode.savePreferences();
|
||||
}
|
||||
autoSaveDialog.dispose();
|
||||
});
|
||||
panelButtons.add(btnRunSave);
|
||||
|
||||
JButton btnRunNoSave = new JButton("Run, Don't Save");
|
||||
btnRunNoSave.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (dontRedisplay.isSelected()) {
|
||||
JavaMode.autoSavePromptEnabled = !dontRedisplay.isSelected();
|
||||
JavaMode.defaultAutoSaveEnabled = false;
|
||||
jmode.savePreferences();
|
||||
}
|
||||
autoSaveDialog.dispose();
|
||||
}
|
||||
});
|
||||
btnRunNoSave.addActionListener(e -> {
|
||||
if (dontRedisplay.isSelected()) {
|
||||
JavaMode.autoSavePromptEnabled = !dontRedisplay.isSelected();
|
||||
JavaMode.defaultAutoSaveEnabled = false;
|
||||
jmode.savePreferences();
|
||||
}
|
||||
autoSaveDialog.dispose();
|
||||
});
|
||||
panelButtons.add(btnRunNoSave);
|
||||
panelMain.add(panelButtons);
|
||||
|
||||
@@ -2023,7 +1883,8 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
|
||||
|
||||
/** Remove all highlights for breakpointed lines. */
|
||||
/*
|
||||
// Remove all highlights for breakpoint lines.
|
||||
public void clearBreakpointedLines() {
|
||||
for (LineHighlight hl : breakpointedLines) {
|
||||
hl.clear();
|
||||
@@ -2039,6 +1900,7 @@ public class JavaEditor extends Editor {
|
||||
currentLine.paint();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@@ -2251,27 +2113,25 @@ public class JavaEditor extends Editor {
|
||||
frmImportSuggest.getContentPane().add(panel);
|
||||
frmImportSuggest.pack();
|
||||
|
||||
classList.addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (classList.getSelectedValue() != null) {
|
||||
try {
|
||||
String t = classList.getSelectedValue().trim();
|
||||
Messages.log(t);
|
||||
int x = t.indexOf('(');
|
||||
String impString = "import " + t.substring(x + 1, t.indexOf(')')) + ";\n";
|
||||
int ct = getSketch().getCurrentCodeIndex();
|
||||
getSketch().setCurrentCode(0);
|
||||
getTextArea().getDocument().insertString(0, impString, null);
|
||||
getSketch().setCurrentCode(ct);
|
||||
} catch (BadLocationException ble) {
|
||||
Messages.log("Failed to insert import");
|
||||
ble.printStackTrace();
|
||||
}
|
||||
classList.addListSelectionListener(e -> {
|
||||
if (classList.getSelectedValue() != null) {
|
||||
try {
|
||||
String t = classList.getSelectedValue().trim();
|
||||
Messages.log(t);
|
||||
int x1 = t.indexOf('(');
|
||||
String impString = "import " + t.substring(x1 + 1, t.indexOf(')')) + ";\n";
|
||||
int ct = getSketch().getCurrentCodeIndex();
|
||||
getSketch().setCurrentCode(0);
|
||||
getTextArea().getDocument().insertString(0, impString, null);
|
||||
getSketch().setCurrentCode(ct);
|
||||
} catch (BadLocationException ble) {
|
||||
Messages.log("Failed to insert import");
|
||||
ble.printStackTrace();
|
||||
}
|
||||
frmImportSuggest.setVisible(false);
|
||||
frmImportSuggest.dispose();
|
||||
frmImportSuggest = null;
|
||||
}
|
||||
frmImportSuggest.setVisible(false);
|
||||
frmImportSuggest.dispose();
|
||||
frmImportSuggest = null;
|
||||
});
|
||||
|
||||
frmImportSuggest.addWindowFocusListener(new WindowFocusListener() {
|
||||
@@ -2488,13 +2348,13 @@ public class JavaEditor extends Editor {
|
||||
|
||||
|
||||
private void loadSavedCode() {
|
||||
SketchCode[] code = sketch.getCode();
|
||||
for (int i=0; i<code.length; i++) {
|
||||
if (!code[i].getProgram().equals(code[i].getSavedProgram())) {
|
||||
code[i].setProgram(code[i].getSavedProgram());
|
||||
//SketchCode[] code = sketch.getCode();
|
||||
for (SketchCode code : sketch.getCode()) {
|
||||
if (!code.getProgram().equals(code.getSavedProgram())) {
|
||||
code.setProgram(code.getSavedProgram());
|
||||
/* Wild Hack: set document to null so the text editor will refresh
|
||||
the program contents when the document tab is being clicked */
|
||||
code[i].setDocument(null);
|
||||
code.setDocument(null);
|
||||
}
|
||||
}
|
||||
// this will update the current code
|
||||
@@ -2662,7 +2522,7 @@ public class JavaEditor extends Editor {
|
||||
|
||||
|
||||
static private String replaceString(String str, int start, int end, String put) {
|
||||
return str.substring(0, start) + put + str.substring(end, str.length());
|
||||
return str.substring(0, start) + put + str.substring(end);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user