Skip to content

Commit

Permalink
Saving a couple of variables won't make the IDE any faster, but will …
Browse files Browse the repository at this point in the history
…make the dev slower
  • Loading branch information
Federico Fissore committed May 27, 2015
1 parent 4bc93e5 commit bd8f793
Showing 1 changed file with 40 additions and 41 deletions.
81 changes: 40 additions & 41 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,6 @@ public void actionPerformed(ActionEvent e) {
protected JMenu buildEditMenu() {
JMenu menu = new JMenu(_("Edit"));
menu.setName("menuEdit");
JMenuItem item;

undoItem = newJMenuItem(_("Undo"), 'Z');
undoItem.setName("menuEditUndo");
Expand All @@ -1355,24 +1354,24 @@ protected JMenu buildEditMenu() {

// TODO "cut" and "copy" should really only be enabled
// if some text is currently selected
item = newJMenuItem(_("Cut"), 'X');
item.addActionListener(new ActionListener() {
JMenuItem cutItem = newJMenuItem(_("Cut"), 'X');
cutItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleCut();
}
});
menu.add(item);
menu.add(cutItem);

item = newJMenuItem(_("Copy"), 'C');
item.addActionListener(new ActionListener() {
JMenuItem copyItem = newJMenuItem(_("Copy"), 'C');
copyItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textarea.copy();
}
});
menu.add(item);
menu.add(copyItem);

item = newJMenuItemShift(_("Copy for Forum"), 'C');
item.addActionListener(new ActionListener() {
JMenuItem copyForumItem = newJMenuItemShift(_("Copy for Forum"), 'C');
copyForumItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
Expand All @@ -1381,10 +1380,10 @@ public void actionPerformed(ActionEvent e) {
// });
}
});
menu.add(item);
menu.add(copyForumItem);

item = newJMenuItemAlt(_("Copy as HTML"), 'C');
item.addActionListener(new ActionListener() {
JMenuItem copyHTMLItem = newJMenuItemAlt(_("Copy as HTML"), 'C');
copyHTMLItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
Expand All @@ -1393,56 +1392,56 @@ public void actionPerformed(ActionEvent e) {
// });
}
});
menu.add(item);
menu.add(copyHTMLItem);

item = newJMenuItem(_("Paste"), 'V');
item.addActionListener(new ActionListener() {
JMenuItem pasteItem = newJMenuItem(_("Paste"), 'V');
pasteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textarea.paste();
sketch.setModified(true);
}
});
menu.add(item);
menu.add(pasteItem);

item = newJMenuItem(_("Select All"), 'A');
item.addActionListener(new ActionListener() {
JMenuItem selectAllItem = newJMenuItem(_("Select All"), 'A');
selectAllItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textarea.selectAll();
}
});
menu.add(item);
menu.add(selectAllItem);

menu.addSeparator();

item = newJMenuItem(_("Comment/Uncomment"), '/');
item.addActionListener(new ActionListener() {
JMenuItem commentItem = newJMenuItem(_("Comment/Uncomment"), '/');
commentItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleCommentUncomment();
}
});
menu.add(item);
menu.add(commentItem);

item = newJMenuItem(_("Increase Indent"), ']');
item.addActionListener(new ActionListener() {
JMenuItem increaseIndentItem = newJMenuItem(_("Increase Indent"), ']');
increaseIndentItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleIndentOutdent(true);
}
});
menu.add(item);
menu.add(increaseIndentItem);

item = newJMenuItem(_("Decrease Indent"), '[');
item.setName("menuDecreaseIndent");
item.addActionListener(new ActionListener() {
JMenuItem decreseIndentItem = newJMenuItem(_("Decrease Indent"), '[');
decreseIndentItem.setName("menuDecreaseIndent");
decreseIndentItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleIndentOutdent(false);
}
});
menu.add(item);
menu.add(decreseIndentItem);

menu.addSeparator();

item = newJMenuItem(_("Find..."), 'F');
item.addActionListener(new ActionListener() {
JMenuItem findItem = newJMenuItem(_("Find..."), 'F');
findItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find == null) {
find = new FindReplace(Editor.this);
Expand All @@ -1454,39 +1453,39 @@ public void actionPerformed(ActionEvent e) {
find.setVisible(true);
}
});
menu.add(item);
menu.add(findItem);

item = newJMenuItem(_("Find Next"), 'G');
item.addActionListener(new ActionListener() {
JMenuItem findNextItem = newJMenuItem(_("Find Next"), 'G');
findNextItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find != null) {
find.findNext();
}
}
});
menu.add(item);
menu.add(findNextItem);

item = newJMenuItemShift(_("Find Previous"), 'G');
item.addActionListener(new ActionListener() {
JMenuItem findPreviousItem = newJMenuItemShift(_("Find Previous"), 'G');
findPreviousItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find != null) {
find.findPrevious();
}
}
});
menu.add(item);
menu.add(findPreviousItem);

if (OSUtils.isMacOS()) {
item = newJMenuItem(_("Use Selection For Find"), 'E');
item.addActionListener(new ActionListener() {
JMenuItem useSelectionForFindItem = newJMenuItem(_("Use Selection For Find"), 'E');
useSelectionForFindItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find == null) {
find = new FindReplace(Editor.this);
}
find.setFindText(getSelectedText());
}
});
menu.add(item);
menu.add(useSelectionForFindItem);
}

return menu;
Expand Down

0 comments on commit bd8f793

Please sign in to comment.