mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
Code inspection: cleaned up processing.app.Editor
This commit is contained in:
@ -28,7 +28,6 @@ import cc.arduino.view.StubMenuListener;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.jcraft.jsch.JSchException;
|
import com.jcraft.jsch.JSchException;
|
||||||
import jssc.SerialPortException;
|
import jssc.SerialPortException;
|
||||||
import org.apache.commons.compress.utils.IOUtils;
|
|
||||||
import processing.app.debug.*;
|
import processing.app.debug.*;
|
||||||
import processing.app.forms.PasswordAuthorizationDialog;
|
import processing.app.forms.PasswordAuthorizationDialog;
|
||||||
import processing.app.helpers.OSUtils;
|
import processing.app.helpers.OSUtils;
|
||||||
@ -77,10 +76,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Sketch sketch) {
|
public boolean apply(Sketch sketch) {
|
||||||
if (PreferencesData.getBoolean("editor.save_on_verify")) {
|
return PreferencesData.getBoolean("editor.save_on_verify") && sketch.isModified() && !sketch.isReadOnly();
|
||||||
return sketch.isModified() && !sketch.isReadOnly();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,20 +88,20 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static List<String> BOARD_PROTOCOLS_ORDER = Arrays.asList(new String[]{"serial", "network"});
|
private final static List<String> BOARD_PROTOCOLS_ORDER = Arrays.asList("serial", "network");
|
||||||
private final static List<String> BOARD_PROTOCOLS_ORDER_TRANSLATIONS = Arrays.asList(new String[]{_("Serial ports"), _("Network ports")});
|
private final static List<String> BOARD_PROTOCOLS_ORDER_TRANSLATIONS = Arrays.asList(_("Serial ports"), _("Network ports"));
|
||||||
|
|
||||||
Base base;
|
final Base base;
|
||||||
|
|
||||||
// otherwise, if the window is resized with the message label
|
// otherwise, if the window is resized with the message label
|
||||||
// set to blank, it's preferredSize() will be fukered
|
// set to blank, it's preferredSize() will be fukered
|
||||||
static protected final String EMPTY =
|
private static final String EMPTY =
|
||||||
" " +
|
" " +
|
||||||
" " +
|
" " +
|
||||||
" ";
|
" ";
|
||||||
|
|
||||||
/** Command on Mac OS X, Ctrl on Windows and Linux */
|
/** Command on Mac OS X, Ctrl on Windows and Linux */
|
||||||
static final int SHORTCUT_KEY_MASK =
|
private static final int SHORTCUT_KEY_MASK =
|
||||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||||
/** Command-W on Mac OS X, Ctrl-W on Windows and Linux */
|
/** Command-W on Mac OS X, Ctrl-W on Windows and Linux */
|
||||||
static final KeyStroke WINDOW_CLOSE_KEYSTROKE =
|
static final KeyStroke WINDOW_CLOSE_KEYSTROKE =
|
||||||
@ -119,15 +115,15 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
*/
|
*/
|
||||||
boolean untitled;
|
boolean untitled;
|
||||||
|
|
||||||
PageFormat pageFormat;
|
private PageFormat pageFormat;
|
||||||
|
|
||||||
// file, sketch, and tools menus for re-inserting items
|
// file, sketch, and tools menus for re-inserting items
|
||||||
JMenu fileMenu;
|
private JMenu fileMenu;
|
||||||
JMenu toolsMenu;
|
private JMenu toolsMenu;
|
||||||
|
|
||||||
int numTools = 0;
|
private int numTools = 0;
|
||||||
|
|
||||||
EditorToolbar toolbar;
|
private final EditorToolbar toolbar;
|
||||||
// these menus are shared so that they needn't be rebuilt for all windows
|
// these menus are shared so that they needn't be rebuilt for all windows
|
||||||
// each time a sketch is created, renamed, or moved.
|
// each time a sketch is created, renamed, or moved.
|
||||||
static JMenu toolbarMenu;
|
static JMenu toolbarMenu;
|
||||||
@ -135,55 +131,49 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
static JMenu examplesMenu;
|
static JMenu examplesMenu;
|
||||||
static JMenu importMenu;
|
static JMenu importMenu;
|
||||||
|
|
||||||
static JMenu serialMenu;
|
private static JMenu serialMenu;
|
||||||
|
|
||||||
static AbstractMonitor serialMonitor;
|
static AbstractMonitor serialMonitor;
|
||||||
|
|
||||||
EditorHeader header;
|
final EditorHeader header;
|
||||||
EditorStatus status;
|
EditorStatus status;
|
||||||
EditorConsole console;
|
EditorConsole console;
|
||||||
|
|
||||||
JSplitPane splitPane;
|
private JSplitPane splitPane;
|
||||||
JPanel consolePanel;
|
|
||||||
|
|
||||||
JLabel lineNumberComponent;
|
|
||||||
|
|
||||||
// currently opened program
|
// currently opened program
|
||||||
Sketch sketch;
|
Sketch sketch;
|
||||||
|
|
||||||
EditorLineStatus lineStatus;
|
private EditorLineStatus lineStatus;
|
||||||
|
|
||||||
//JEditorPane editorPane;
|
//JEditorPane editorPane;
|
||||||
|
|
||||||
SketchTextArea textarea;
|
private SketchTextArea textarea;
|
||||||
RTextScrollPane scrollPane;
|
private RTextScrollPane scrollPane;
|
||||||
|
|
||||||
// runtime information and window placement
|
|
||||||
Point sketchWindowLocation;
|
|
||||||
//Runner runtime;
|
//Runner runtime;
|
||||||
|
|
||||||
JMenuItem exportAppItem;
|
private JMenuItem saveMenuItem;
|
||||||
JMenuItem saveMenuItem;
|
private JMenuItem saveAsMenuItem;
|
||||||
JMenuItem saveAsMenuItem;
|
|
||||||
|
|
||||||
boolean running;
|
|
||||||
//boolean presenting;
|
//boolean presenting;
|
||||||
boolean uploading;
|
private boolean uploading;
|
||||||
|
|
||||||
// undo fellers
|
// undo fellers
|
||||||
JMenuItem undoItem, redoItem;
|
private JMenuItem undoItem;
|
||||||
|
private JMenuItem redoItem;
|
||||||
protected UndoAction undoAction;
|
protected UndoAction undoAction;
|
||||||
protected RedoAction redoAction;
|
protected RedoAction redoAction;
|
||||||
|
|
||||||
FindReplace find;
|
private FindReplace find;
|
||||||
|
|
||||||
Runnable runHandler;
|
Runnable runHandler;
|
||||||
Runnable presentHandler;
|
Runnable presentHandler;
|
||||||
Runnable runAndSaveHandler;
|
private Runnable runAndSaveHandler;
|
||||||
Runnable presentAndSaveHandler;
|
private Runnable presentAndSaveHandler;
|
||||||
Runnable stopHandler;
|
private Runnable stopHandler;
|
||||||
Runnable exportHandler;
|
Runnable exportHandler;
|
||||||
Runnable exportAppHandler;
|
private Runnable exportAppHandler;
|
||||||
|
|
||||||
|
|
||||||
public Editor(Base ibase, File file, int[] location, Platform platform) throws Exception {
|
public Editor(Base ibase, File file, int[] location, Platform platform) throws Exception {
|
||||||
@ -263,7 +253,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
textarea.setName("editor");
|
textarea.setName("editor");
|
||||||
|
|
||||||
// assemble console panel, consisting of status area and the console itself
|
// assemble console panel, consisting of status area and the console itself
|
||||||
consolePanel = new JPanel();
|
JPanel consolePanel = new JPanel();
|
||||||
consolePanel.setLayout(new BorderLayout());
|
consolePanel.setLayout(new BorderLayout());
|
||||||
|
|
||||||
status = new EditorStatus(this);
|
status = new EditorStatus(this);
|
||||||
@ -362,7 +352,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
* window. Dragging files into the editor window is the same as using
|
* window. Dragging files into the editor window is the same as using
|
||||||
* "Sketch → Add File" for each file.
|
* "Sketch → Add File" for each file.
|
||||||
*/
|
*/
|
||||||
class FileDropHandler extends TransferHandler {
|
private class FileDropHandler extends TransferHandler {
|
||||||
public boolean canImport(JComponent dest, DataFlavor[] flavors) {
|
public boolean canImport(JComponent dest, DataFlavor[] flavors) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -388,14 +378,14 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
// this method of moving files.
|
// this method of moving files.
|
||||||
String data = (String)transferable.getTransferData(uriListFlavor);
|
String data = (String)transferable.getTransferData(uriListFlavor);
|
||||||
String[] pieces = PApplet.splitTokens(data, "\r\n");
|
String[] pieces = PApplet.splitTokens(data, "\r\n");
|
||||||
for (int i = 0; i < pieces.length; i++) {
|
for (String piece : pieces) {
|
||||||
if (pieces[i].startsWith("#")) continue;
|
if (piece.startsWith("#")) continue;
|
||||||
|
|
||||||
String path = null;
|
String path = null;
|
||||||
if (pieces[i].startsWith("file:///")) {
|
if (piece.startsWith("file:///")) {
|
||||||
path = pieces[i].substring(7);
|
path = piece.substring(7);
|
||||||
} else if (pieces[i].startsWith("file:/")) {
|
} else if (piece.startsWith("file:/")) {
|
||||||
path = pieces[i].substring(5);
|
path = piece.substring(5);
|
||||||
}
|
}
|
||||||
if (sketch.addFile(new File(path))) {
|
if (sketch.addFile(new File(path))) {
|
||||||
successful++;
|
successful++;
|
||||||
@ -422,7 +412,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void setPlacement(int[] location) {
|
private void setPlacement(int[] location) {
|
||||||
setBounds(location[0], location[1], location[2], location[3]);
|
setBounds(location[0], location[1], location[2], location[3]);
|
||||||
if (location[4] != 0) {
|
if (location[4] != 0) {
|
||||||
splitPane.setDividerLocation(location[4]);
|
splitPane.setDividerLocation(location[4]);
|
||||||
@ -512,7 +502,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||||
|
|
||||||
|
|
||||||
protected void buildMenuBar() throws Exception {
|
private void buildMenuBar() {
|
||||||
JMenuBar menubar = new JMenuBar();
|
JMenuBar menubar = new JMenuBar();
|
||||||
final JMenu fileMenu = buildFileMenu();
|
final JMenu fileMenu = buildFileMenu();
|
||||||
fileMenu.addMenuListener(new StubMenuListener() {
|
fileMenu.addMenuListener(new StubMenuListener() {
|
||||||
@ -572,7 +562,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected JMenu buildFileMenu() {
|
private JMenu buildFileMenu() {
|
||||||
JMenuItem item;
|
JMenuItem item;
|
||||||
fileMenu = new JMenu(_("File"));
|
fileMenu = new JMenu(_("File"));
|
||||||
|
|
||||||
@ -698,7 +688,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void buildSketchMenu(JMenu sketchMenu) {
|
private void buildSketchMenu(JMenu sketchMenu) {
|
||||||
sketchMenu.removeAll();
|
sketchMenu.removeAll();
|
||||||
|
|
||||||
JMenuItem item = newJMenuItem(_("Verify / Compile"), 'R');
|
JMenuItem item = newJMenuItem(_("Verify / Compile"), 'R');
|
||||||
@ -770,7 +760,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected JMenu buildToolsMenu() throws Exception {
|
private JMenu buildToolsMenu() {
|
||||||
toolsMenu = new JMenu(_("Tools"));
|
toolsMenu = new JMenu(_("Tools"));
|
||||||
|
|
||||||
addInternalTools(toolsMenu);
|
addInternalTools(toolsMenu);
|
||||||
@ -853,7 +843,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void addTools(JMenu menu, File sourceFolder) {
|
private void addTools(JMenu menu, File sourceFolder) {
|
||||||
if (sourceFolder == null)
|
if (sourceFolder == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -874,8 +864,8 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < folders.length; i++) {
|
for (File folder : folders) {
|
||||||
File toolDirectory = new File(folders[i], "tool");
|
File toolDirectory = new File(folder, "tool");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// add dir to classpath for .classes
|
// add dir to classpath for .classes
|
||||||
@ -885,7 +875,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
File[] archives = toolDirectory.listFiles(new FilenameFilter() {
|
File[] archives = toolDirectory.listFiles(new FilenameFilter() {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
return (name.toLowerCase().endsWith(".jar") ||
|
return (name.toLowerCase().endsWith(".jar") ||
|
||||||
name.toLowerCase().endsWith(".zip"));
|
name.toLowerCase().endsWith(".zip"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -896,8 +886,8 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
URLClassLoader loader = new URLClassLoader(urlList);
|
URLClassLoader loader = new URLClassLoader(urlList);
|
||||||
|
|
||||||
String className = null;
|
String className = null;
|
||||||
for (int j = 0; j < archives.length; j++) {
|
for (File archive : archives) {
|
||||||
className = findClassInZipFile(folders[i].getName(), archives[j]);
|
className = findClassInZipFile(folder.getName(), archive);
|
||||||
if (className != null) break;
|
if (className != null) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -953,12 +943,12 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
Collections.sort(toolList);
|
Collections.sort(toolList);
|
||||||
for (String title : toolList) {
|
for (String title : toolList) {
|
||||||
menu.add((JMenuItem) toolItems.get(title));
|
menu.add(toolItems.get(title));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String findClassInZipFile(String base, File file) {
|
private String findClassInZipFile(String base, File file) {
|
||||||
// Class file to search for
|
// Class file to search for
|
||||||
String classFileName = "/" + base + ".class";
|
String classFileName = "/" + base + ".class";
|
||||||
|
|
||||||
@ -997,7 +987,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected SketchTextArea createTextArea() throws IOException {
|
private SketchTextArea createTextArea() throws IOException {
|
||||||
final SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
|
final SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
|
||||||
textArea.requestFocusInWindow();
|
textArea.requestFocusInWindow();
|
||||||
textArea.setMarkOccurrences(PreferencesData.getBoolean("editor.advanced"));
|
textArea.setMarkOccurrences(PreferencesData.getBoolean("editor.advanced"));
|
||||||
@ -1035,7 +1025,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
return textArea;
|
return textArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JMenuItem createToolMenuItem(String className) {
|
private JMenuItem createToolMenuItem(String className) {
|
||||||
try {
|
try {
|
||||||
Class<?> toolClass = Class.forName(className);
|
Class<?> toolClass = Class.forName(className);
|
||||||
final Tool tool = (Tool) toolClass.newInstance();
|
final Tool tool = (Tool) toolClass.newInstance();
|
||||||
@ -1058,10 +1048,13 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected JMenu addInternalTools(JMenu menu) {
|
private void addInternalTools(JMenu menu) {
|
||||||
JMenuItem item;
|
JMenuItem item;
|
||||||
|
|
||||||
item = createToolMenuItem("cc.arduino.packages.formatter.AStyle");
|
item = createToolMenuItem("cc.arduino.packages.formatter.AStyle");
|
||||||
|
if (item == null) {
|
||||||
|
throw new NullPointerException("Tool cc.arduino.packages.formatter.AStyle unavailable");
|
||||||
|
}
|
||||||
item.setName("menuToolsAutoFormat");
|
item.setName("menuToolsAutoFormat");
|
||||||
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||||
item.setAccelerator(KeyStroke.getKeyStroke('T', modifiers));
|
item.setAccelerator(KeyStroke.getKeyStroke('T', modifiers));
|
||||||
@ -1071,17 +1064,6 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
//menu.add(createToolMenuItem("processing.app.tools.ColorSelector"));
|
//menu.add(createToolMenuItem("processing.app.tools.ColorSelector"));
|
||||||
menu.add(createToolMenuItem("processing.app.tools.Archiver"));
|
menu.add(createToolMenuItem("processing.app.tools.Archiver"));
|
||||||
menu.add(createToolMenuItem("processing.app.tools.FixEncoding"));
|
menu.add(createToolMenuItem("processing.app.tools.FixEncoding"));
|
||||||
|
|
||||||
// // These are temporary entries while Android mode is being worked out.
|
|
||||||
// // The mode will not be in the tools menu, and won't involve a cmd-key
|
|
||||||
// if (!Base.RELEASE) {
|
|
||||||
// item = createToolMenuItem("processing.app.tools.android.AndroidTool");
|
|
||||||
// item.setAccelerator(KeyStroke.getKeyStroke('D', modifiers));
|
|
||||||
// menu.add(item);
|
|
||||||
// menu.add(createToolMenuItem("processing.app.tools.android.Reset"));
|
|
||||||
// }
|
|
||||||
|
|
||||||
return menu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1100,7 +1082,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void selectSerialPort(String name) {
|
private void selectSerialPort(String name) {
|
||||||
if(serialMenu == null) {
|
if(serialMenu == null) {
|
||||||
System.out.println(_("serialMenu is null"));
|
System.out.println(_("serialMenu is null"));
|
||||||
return;
|
return;
|
||||||
@ -1116,10 +1098,6 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
JCheckBoxMenuItem checkBoxMenuItem = ((JCheckBoxMenuItem) menuItem);
|
JCheckBoxMenuItem checkBoxMenuItem = ((JCheckBoxMenuItem) menuItem);
|
||||||
if (checkBoxMenuItem == null) {
|
|
||||||
System.out.println(_("name is null"));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
checkBoxMenuItem.setState(false);
|
checkBoxMenuItem.setState(false);
|
||||||
if (name.equals(checkBoxMenuItem.getText())) selection = checkBoxMenuItem;
|
if (name.equals(checkBoxMenuItem.getText())) selection = checkBoxMenuItem;
|
||||||
}
|
}
|
||||||
@ -1141,7 +1119,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void populatePortMenu() {
|
private void populatePortMenu() {
|
||||||
serialMenu.removeAll();
|
serialMenu.removeAll();
|
||||||
|
|
||||||
String selectedPort = PreferencesData.get("serial.port");
|
String selectedPort = PreferencesData.get("serial.port");
|
||||||
@ -1187,7 +1165,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected JMenu buildHelpMenu() {
|
private JMenu buildHelpMenu() {
|
||||||
// To deal with a Mac OS X 10.5 bug, add an extra space after the name
|
// To deal with a Mac OS X 10.5 bug, add an extra space after the name
|
||||||
// so that the OS doesn't try to insert its slow help menu.
|
// so that the OS doesn't try to insert its slow help menu.
|
||||||
JMenu menu = new JMenu(_("Help"));
|
JMenu menu = new JMenu(_("Help"));
|
||||||
@ -1277,7 +1255,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
item = new JMenuItem(_("Troubleshooting"));
|
item = new JMenuItem(_("Troubleshooting"));
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Base.showReference("reference/Galileo_help_files", "Guide_Troubleshooting_Galileo");;
|
Base.showReference("reference/Galileo_help_files", "Guide_Troubleshooting_Galileo");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
@ -1298,7 +1276,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
item = new JMenuItem(_("Troubleshooting"));
|
item = new JMenuItem(_("Troubleshooting"));
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Base.showReference("reference/Edison_help_files", "Guide_Troubleshooting_Edison");;
|
Base.showReference("reference/Edison_help_files", "Guide_Troubleshooting_Edison");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
@ -1348,7 +1326,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected JMenu buildEditMenu() {
|
private JMenu buildEditMenu() {
|
||||||
JMenu menu = new JMenu(_("Edit"));
|
JMenu menu = new JMenu(_("Edit"));
|
||||||
menu.setName("menuEdit");
|
menu.setName("menuEdit");
|
||||||
|
|
||||||
@ -1537,7 +1515,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
* Same as newJMenuItem(), but adds the ALT (on Linux and Windows)
|
* Same as newJMenuItem(), but adds the ALT (on Linux and Windows)
|
||||||
* or OPTION (on Mac OS X) key as a modifier.
|
* or OPTION (on Mac OS X) key as a modifier.
|
||||||
*/
|
*/
|
||||||
static public JMenuItem newJMenuItemAlt(String title, int what) {
|
private static JMenuItem newJMenuItemAlt(String title, int what) {
|
||||||
JMenuItem menuItem = new JMenuItem(title);
|
JMenuItem menuItem = new JMenuItem(title);
|
||||||
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_ALT_KEY_MASK));
|
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_ALT_KEY_MASK));
|
||||||
return menuItem;
|
return menuItem;
|
||||||
@ -1624,24 +1602,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
// abstract from the editor in this fashion.
|
// abstract from the editor in this fashion.
|
||||||
|
|
||||||
|
|
||||||
public void setHandlers(Runnable runHandler,
|
private void resetHandlers() {
|
||||||
Runnable presentHandler,
|
|
||||||
Runnable runAndSaveHandler,
|
|
||||||
Runnable presentAndSaveHandler,
|
|
||||||
Runnable stopHandler,
|
|
||||||
Runnable exportHandler,
|
|
||||||
Runnable exportAppHandler) {
|
|
||||||
this.runHandler = runHandler;
|
|
||||||
this.presentHandler = presentHandler;
|
|
||||||
this.runAndSaveHandler = runAndSaveHandler;
|
|
||||||
this.presentAndSaveHandler = presentAndSaveHandler;
|
|
||||||
this.stopHandler = stopHandler;
|
|
||||||
this.exportHandler = exportHandler;
|
|
||||||
this.exportAppHandler = exportAppHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void resetHandlers() {
|
|
||||||
runHandler = new BuildHandler();
|
runHandler = new BuildHandler();
|
||||||
presentHandler = new BuildHandler(true);
|
presentHandler = new BuildHandler(true);
|
||||||
runAndSaveHandler = new BuildHandler(false, true);
|
runAndSaveHandler = new BuildHandler(false, true);
|
||||||
@ -1683,18 +1644,6 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a range of text from the current buffer.
|
|
||||||
*/
|
|
||||||
public String getText(int start, int stop) {
|
|
||||||
try {
|
|
||||||
return textarea.getText(start, stop - start);
|
|
||||||
} catch (BadLocationException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace the entire contents of the front-most tab.
|
* Replace the entire contents of the front-most tab.
|
||||||
*/
|
*/
|
||||||
@ -1736,25 +1685,6 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the position (character offset) of the caret. With text selected,
|
|
||||||
* this will be the last character actually selected, no matter the direction
|
|
||||||
* of the selection. That is, if the user clicks and drags to select lines
|
|
||||||
* 7 up to 4, then the caret position will be somewhere on line four.
|
|
||||||
*/
|
|
||||||
public int getCaretOffset() {
|
|
||||||
return textarea.getCaretPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* True if some text is currently selected.
|
|
||||||
*/
|
|
||||||
public boolean isSelectionActive() {
|
|
||||||
return textarea.isSelectionActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the beginning point of the current selection.
|
* Get the beginning point of the current selection.
|
||||||
*/
|
*/
|
||||||
@ -1774,7 +1704,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
/**
|
/**
|
||||||
* Get text for a specified line.
|
* Get text for a specified line.
|
||||||
*/
|
*/
|
||||||
public String getLineText(int line) {
|
private String getLineText(int line) {
|
||||||
try {
|
try {
|
||||||
return textarea.getText(textarea.getLineStartOffset(line), textarea.getLineEndOffset(line));
|
return textarea.getText(textarea.getLineStartOffset(line), textarea.getLineEndOffset(line));
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
@ -1783,38 +1713,6 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get character offset for the start of a given line of text.
|
|
||||||
*/
|
|
||||||
public int getLineStartOffset(int line) {
|
|
||||||
try {
|
|
||||||
return textarea.getLineStartOffset(line);
|
|
||||||
} catch (BadLocationException e) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get character offset for end of a given line of text.
|
|
||||||
*/
|
|
||||||
public int getLineStopOffset(int line) {
|
|
||||||
try {
|
|
||||||
return textarea.getLineEndOffset(line);
|
|
||||||
} catch (BadLocationException e) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of lines in the currently displayed buffer.
|
|
||||||
*/
|
|
||||||
public int getLineCount() {
|
|
||||||
return textarea.getLineCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getScrollPosition() {
|
public int getScrollPosition() {
|
||||||
return scrollPane.getVerticalScrollBar().getValue();
|
return scrollPane.getVerticalScrollBar().getValue();
|
||||||
}
|
}
|
||||||
@ -1882,64 +1780,21 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
/**
|
/**
|
||||||
* Implements Edit → Cut.
|
* Implements Edit → Cut.
|
||||||
*/
|
*/
|
||||||
public void handleCut() {
|
private void handleCut() {
|
||||||
textarea.cut();
|
textarea.cut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
private void handleDiscourseCopy() {
|
||||||
* Implements Edit → Copy.
|
|
||||||
*/
|
|
||||||
public void handleCopy() {
|
|
||||||
textarea.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void handleDiscourseCopy() {
|
|
||||||
new DiscourseFormat(Editor.this, false).show();
|
new DiscourseFormat(Editor.this, false).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void handleHTMLCopy() {
|
private void handleHTMLCopy() {
|
||||||
new DiscourseFormat(Editor.this, true).show();
|
new DiscourseFormat(Editor.this, true).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements Edit → Paste.
|
|
||||||
*/
|
|
||||||
public void handlePaste() {
|
|
||||||
textarea.paste();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements Edit → Select All.
|
|
||||||
*/
|
|
||||||
public void handleSelectAll() {
|
|
||||||
textarea.selectAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Begins an "atomic" edit. This method is called when TextArea
|
|
||||||
* KNOWS that some edits should be compound automatically, such as the playing back of a macro.
|
|
||||||
*
|
|
||||||
* @see #endInternalAtomicEdit()
|
|
||||||
*/
|
|
||||||
public void beginInternalAtomicEdit(){
|
|
||||||
textarea.getUndoManager().beginInternalAtomicEdit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ends an "atomic" edit.
|
|
||||||
*
|
|
||||||
* @see #beginInternalAtomicEdit()
|
|
||||||
*/
|
|
||||||
public void endInternalAtomicEdit(){
|
|
||||||
textarea.getUndoManager().endInternalAtomicEdit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void handleCommentUncomment() {
|
void handleCommentUncomment() {
|
||||||
|
|
||||||
Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaToggleCommentAction);
|
Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaToggleCommentAction);
|
||||||
@ -1948,7 +1803,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void handleIndentOutdent(boolean indent) {
|
private void handleIndentOutdent(boolean indent) {
|
||||||
if (indent) {
|
if (indent) {
|
||||||
|
|
||||||
int caretPosition = textarea.getCaretPosition();
|
int caretPosition = textarea.getCaretPosition();
|
||||||
@ -1977,13 +1832,8 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
action.actionPerformed(null);
|
action.actionPerformed(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks the preferences you are in external editing mode */
|
|
||||||
public static boolean isExternalMode(){
|
|
||||||
return PreferencesData.getBoolean("editor.external");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getCurrentKeyword() {
|
private String getCurrentKeyword() {
|
||||||
String text = "";
|
String text = "";
|
||||||
if (textarea.getSelectedText() != null)
|
if (textarea.getSelectedText() != null)
|
||||||
text = textarea.getSelectedText().trim();
|
text = textarea.getSelectedText().trim();
|
||||||
@ -2024,7 +1874,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleFindReference() {
|
private void handleFindReference() {
|
||||||
String text = getCurrentKeyword();
|
String text = getCurrentKeyword();
|
||||||
|
|
||||||
String referenceFile = base.getPdeKeywords().getReference(text);
|
String referenceFile = base.getPdeKeywords().getReference(text);
|
||||||
@ -2049,12 +1899,11 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
handleRun(verbose, new ShouldSaveIfModified(), verboseHandler, nonVerboseHandler);
|
handleRun(verbose, new ShouldSaveIfModified(), verboseHandler, nonVerboseHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleRun(final boolean verbose, Predicate<Sketch> shouldSavePredicate, Runnable verboseHandler, Runnable nonVerboseHandler) {
|
private void handleRun(final boolean verbose, Predicate<Sketch> shouldSavePredicate, Runnable verboseHandler, Runnable nonVerboseHandler) {
|
||||||
internalCloseRunner();
|
internalCloseRunner();
|
||||||
if (shouldSavePredicate.apply(sketch)) {
|
if (shouldSavePredicate.apply(sketch)) {
|
||||||
handleSave(true);
|
handleSave(true);
|
||||||
}
|
}
|
||||||
running = true;
|
|
||||||
toolbar.activate(EditorToolbar.RUN);
|
toolbar.activate(EditorToolbar.RUN);
|
||||||
status.progress(_("Compiling sketch..."));
|
status.progress(_("Compiling sketch..."));
|
||||||
|
|
||||||
@ -2110,35 +1959,18 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DefaultStopHandler implements Runnable {
|
private class DefaultStopHandler implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
// TODO
|
// TODO
|
||||||
// DAM: we should try to kill the compilation or upload process here.
|
// DAM: we should try to kill the compilation or upload process here.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the location of the sketch run window. Used by Runner to update the
|
|
||||||
* Editor about window drag events while the sketch is running.
|
|
||||||
*/
|
|
||||||
public void setSketchLocation(Point p) {
|
|
||||||
sketchWindowLocation = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the last location of the sketch's run window. Used by Runner to make
|
|
||||||
* the window show up in the same location as when it was last closed.
|
|
||||||
*/
|
|
||||||
public Point getSketchLocation() {
|
|
||||||
return sketchWindowLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Sketch → Stop, or pressing Stop on the toolbar.
|
* Implements Sketch → Stop, or pressing Stop on the toolbar.
|
||||||
*/
|
*/
|
||||||
public void handleStop() { // called by menu or buttons
|
private void handleStop() { // called by menu or buttons
|
||||||
// toolbar.activate(EditorToolbar.STOP);
|
// toolbar.activate(EditorToolbar.STOP);
|
||||||
|
|
||||||
internalCloseRunner();
|
internalCloseRunner();
|
||||||
@ -2151,23 +1983,10 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deactivate the Run button. This is called by Runner to notify that the
|
|
||||||
* sketch has stopped running, usually in response to an error (or maybe
|
|
||||||
* the sketch completing and exiting?) Tools should not call this function.
|
|
||||||
* To initiate a "stop" action, call handleStop() instead.
|
|
||||||
*/
|
|
||||||
public void internalRunnerClosed() {
|
|
||||||
running = false;
|
|
||||||
toolbar.deactivate(EditorToolbar.RUN);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle internal shutdown of the runner.
|
* Handle internal shutdown of the runner.
|
||||||
*/
|
*/
|
||||||
public void internalCloseRunner() {
|
public void internalCloseRunner() {
|
||||||
running = false;
|
|
||||||
|
|
||||||
if (stopHandler != null)
|
if (stopHandler != null)
|
||||||
try {
|
try {
|
||||||
@ -2241,7 +2060,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
// on macosx, setting the destructive property places this option
|
// on macosx, setting the destructive property places this option
|
||||||
// away from the others at the lefthand side
|
// away from the others at the lefthand side
|
||||||
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
|
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
|
||||||
new Integer(2));
|
2);
|
||||||
|
|
||||||
JDialog dialog = pane.createDialog(this, null);
|
JDialog dialog = pane.createDialog(this, null);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
@ -2249,12 +2068,8 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
Object result = pane.getValue();
|
Object result = pane.getValue();
|
||||||
if (result == options[0]) { // save (and close/quit)
|
if (result == options[0]) { // save (and close/quit)
|
||||||
return handleSave(true);
|
return handleSave(true);
|
||||||
|
} else {
|
||||||
} else if (result == options[2]) { // don't save (still close/quit)
|
return result == options[2];
|
||||||
return true;
|
|
||||||
|
|
||||||
} else { // cancel?
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2412,7 +2227,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean handleSave2() {
|
private boolean handleSave2() {
|
||||||
toolbar.activate(EditorToolbar.SAVE);
|
toolbar.activate(EditorToolbar.SAVE);
|
||||||
statusNotice(_("Saving..."));
|
statusNotice(_("Saving..."));
|
||||||
boolean saved = false;
|
boolean saved = false;
|
||||||
@ -2479,11 +2294,11 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean serialPrompt() {
|
private boolean serialPrompt() {
|
||||||
int count = serialMenu.getItemCount();
|
int count = serialMenu.getItemCount();
|
||||||
Object[] names = new Object[count];
|
Object[] names = new Object[count];
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
names[i] = ((JCheckBoxMenuItem)serialMenu.getItem(i)).getText();
|
names[i] = serialMenu.getItem(i).getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
String result = (String)
|
String result = (String)
|
||||||
@ -2548,8 +2363,6 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
boolean success = sketch.exportApplet(false);
|
boolean success = sketch.exportApplet(false);
|
||||||
if (success) {
|
if (success) {
|
||||||
statusNotice(_("Done uploading."));
|
statusNotice(_("Done uploading."));
|
||||||
} else {
|
|
||||||
// error message will already be visible
|
|
||||||
}
|
}
|
||||||
} catch (SerialNotFoundException e) {
|
} catch (SerialNotFoundException e) {
|
||||||
if (serialMenu.getItemCount() == 0) statusError(e);
|
if (serialMenu.getItemCount() == 0) statusError(e);
|
||||||
@ -2610,8 +2423,6 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
boolean success = sketch.exportApplet(true);
|
boolean success = sketch.exportApplet(true);
|
||||||
if (success) {
|
if (success) {
|
||||||
statusNotice(_("Done uploading."));
|
statusNotice(_("Done uploading."));
|
||||||
} else {
|
|
||||||
// error message will already be visible
|
|
||||||
}
|
}
|
||||||
} catch (SerialNotFoundException e) {
|
} catch (SerialNotFoundException e) {
|
||||||
if (serialMenu.getItemCount() == 0) statusError(e);
|
if (serialMenu.getItemCount() == 0) statusError(e);
|
||||||
@ -2641,40 +2452,6 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if the sketch has been modified, and if so,
|
|
||||||
* asks the user to save the sketch or cancel the export.
|
|
||||||
* This prevents issues where an incomplete version of the sketch
|
|
||||||
* would be exported, and is a fix for
|
|
||||||
* <A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=157">Bug 157</A>
|
|
||||||
*/
|
|
||||||
protected boolean handleExportCheckModified() {
|
|
||||||
if (!sketch.isModified()) return true;
|
|
||||||
|
|
||||||
Object[] options = { _("OK"), _("Cancel") };
|
|
||||||
int result = JOptionPane.showOptionDialog(this,
|
|
||||||
_("Save changes before export?"),
|
|
||||||
_("Save"),
|
|
||||||
JOptionPane.OK_CANCEL_OPTION,
|
|
||||||
JOptionPane.QUESTION_MESSAGE,
|
|
||||||
null,
|
|
||||||
options,
|
|
||||||
options[0]);
|
|
||||||
|
|
||||||
if (result == JOptionPane.OK_OPTION) {
|
|
||||||
handleSave(true);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// why it's not CANCEL_OPTION is beyond me (at least on the mac)
|
|
||||||
// but f-- it.. let's get this shite done..
|
|
||||||
//} else if (result == JOptionPane.CANCEL_OPTION) {
|
|
||||||
statusNotice(_("Export canceled, changes must first be saved."));
|
|
||||||
//toolbar.clear();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void handleSerial() {
|
public void handleSerial() {
|
||||||
if (serialMonitor != null) {
|
if (serialMonitor != null) {
|
||||||
@ -2764,7 +2541,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void handleBurnBootloader() {
|
private void handleBurnBootloader() {
|
||||||
console.clear();
|
console.clear();
|
||||||
statusNotice(_("Burning bootloader to I/O Board (this may take a minute)..."));
|
statusNotice(_("Burning bootloader to I/O Board (this may take a minute)..."));
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@ -2795,7 +2572,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
/**
|
/**
|
||||||
* Handler for File → Page Setup.
|
* Handler for File → Page Setup.
|
||||||
*/
|
*/
|
||||||
public void handlePageSetup() {
|
private void handlePageSetup() {
|
||||||
PrinterJob printerJob = PrinterJob.getPrinterJob();
|
PrinterJob printerJob = PrinterJob.getPrinterJob();
|
||||||
if (pageFormat == null) {
|
if (pageFormat == null) {
|
||||||
pageFormat = printerJob.defaultPage();
|
pageFormat = printerJob.defaultPage();
|
||||||
@ -2807,7 +2584,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
/**
|
/**
|
||||||
* Handler for File → Print.
|
* Handler for File → Print.
|
||||||
*/
|
*/
|
||||||
public void handlePrint() {
|
private void handlePrint() {
|
||||||
statusNotice(_("Printing..."));
|
statusNotice(_("Printing..."));
|
||||||
//printerJob = null;
|
//printerJob = null;
|
||||||
PrinterJob printerJob = PrinterJob.getPrinterJob();
|
PrinterJob printerJob = PrinterJob.getPrinterJob();
|
||||||
@ -2920,7 +2697,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
/**
|
/**
|
||||||
* Clear the status area.
|
* Clear the status area.
|
||||||
*/
|
*/
|
||||||
public void statusEmpty() {
|
private void statusEmpty() {
|
||||||
statusNotice(EMPTY);
|
statusNotice(EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2938,13 +2715,16 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void configurePopupMenu(final SketchTextArea textarea){
|
private void configurePopupMenu(final SketchTextArea textarea){
|
||||||
|
|
||||||
JPopupMenu menu = textarea.getPopupMenu();
|
JPopupMenu menu = textarea.getPopupMenu();
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
JMenuItem item = createToolMenuItem("cc.arduino.packages.formatter.AStyle");
|
JMenuItem item = createToolMenuItem("cc.arduino.packages.formatter.AStyle");
|
||||||
|
if (item == null) {
|
||||||
|
throw new NullPointerException("Tool cc.arduino.packages.formatter.AStyle unavailable");
|
||||||
|
}
|
||||||
item.setName("menuToolsAutoFormat");
|
item.setName("menuToolsAutoFormat");
|
||||||
|
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
Reference in New Issue
Block a user