moving AWT utility functions into Toolkit class (for headless)

This commit is contained in:
benfry
2012-10-20 19:50:17 +00:00
parent fcc56f7983
commit ca53abcd7e
17 changed files with 235 additions and 314 deletions
+3 -118
View File
@@ -566,73 +566,6 @@ public class Base {
*/
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/** Command on Mac OS X, Ctrl on Windows and Linux */
static final int SHORTCUT_KEY_MASK =
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
/** Command-W on Mac OS X, Ctrl-W on Windows and Linux */
public static final KeyStroke WINDOW_CLOSE_KEYSTROKE =
KeyStroke.getKeyStroke('W', SHORTCUT_KEY_MASK);
/** Command-Option on Mac OS X, Ctrl-Alt on Windows and Linux */
static final int SHORTCUT_ALT_KEY_MASK = ActionEvent.ALT_MASK |
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
/**
* A software engineer, somewhere, needs to have his abstraction
* taken away. In some countries they jail or beat people for crafting
* the sort of API that would require a five line helper function
* just to set the shortcut key for a menu item.
*/
static public JMenuItem newJMenuItem(String title, int what) {
JMenuItem menuItem = new JMenuItem(title);
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers));
return menuItem;
}
/**
* Like newJMenuItem() but adds shift as a modifier for the shortcut.
*/
static public JMenuItem newJMenuItemShift(String title, int what) {
JMenuItem menuItem = new JMenuItem(title);
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
modifiers |= ActionEvent.SHIFT_MASK;
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers));
return menuItem;
}
/**
* Same as newJMenuItem(), but adds the ALT (on Linux and Windows)
* or OPTION (on Mac OS X) key as a modifier.
*/
static public JMenuItem newJMenuItemAlt(String title, int what) {
JMenuItem menuItem = new JMenuItem(title);
//int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
//menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers));
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_ALT_KEY_MASK));
return menuItem;
}
static public JCheckBoxMenuItem newJCheckBoxMenuItem(String title, int what) {
JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(title);
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers));
return menuItem;
}
static public void addDisabledItem(JMenu menu, String title) {
JMenuItem item = new JMenuItem(title);
item.setEnabled(false);
menu.add(item);
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -1579,7 +1512,7 @@ public class Base {
});
int w = image.getWidth(activeEditor);
int h = image.getHeight(activeEditor);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension screen = Toolkit.getScreenSize();
window.setBounds((screen.width-w)/2, (screen.height-h)/2, w, h);
window.setVisible(true);
}
@@ -2110,54 +2043,6 @@ public class Base {
// .................................................................
/**
* Give this Frame a Processing icon.
*/
static public void setIcon(Frame frame) {
Image image = Toolkit.getDefaultToolkit().createImage(PApplet.ICON_IMAGE);
frame.setIconImage(image);
}
// someone needs to be slapped
//static KeyStroke closeWindowKeyStroke;
/**
* Return true if the key event was a Ctrl-W or an ESC,
* both indicators to close the window.
* Use as part of a keyPressed() event handler for frames.
*/
/*
static public boolean isCloseWindowEvent(KeyEvent e) {
if (closeWindowKeyStroke == null) {
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
closeWindowKeyStroke = KeyStroke.getKeyStroke('W', modifiers);
}
return ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
KeyStroke.getKeyStrokeForEvent(e).equals(closeWindowKeyStroke));
}
*/
/**
* Registers key events for a Ctrl-W and ESC with an ActionListener
* that will take care of disposing the window.
*/
static public void registerWindowCloseKeys(JRootPane root,
ActionListener disposer) {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
root.registerKeyboardAction(disposer, stroke,
JComponent.WHEN_IN_FOCUSED_WINDOW);
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
stroke = KeyStroke.getKeyStroke('W', modifiers);
root.registerKeyboardAction(disposer, stroke,
JComponent.WHEN_IN_FOCUSED_WINDOW);
}
// .................................................................
/**
* "No cookie for you" type messages. Nothing fatal or all that
* much of a bummer, but something to notify the user about.
@@ -2466,10 +2351,10 @@ public class Base {
*/
static public Image getLibImage(String name, Component who) {
Image image = null;
Toolkit tk = Toolkit.getDefaultToolkit();
// Toolkit tk = Toolkit.getDefaultToolkit();
File imageLocation = new File(getContentFile("lib"), name);
image = tk.getImage(imageLocation.getAbsolutePath());
image = java.awt.Toolkit.getDefaultToolkit().getImage(imageLocation.getAbsolutePath());
MediaTracker tracker = new MediaTracker(who);
tracker.addImage(image, 0);
try {
+29 -29
View File
@@ -118,7 +118,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
this.state = state;
this.mode = mode;
Base.setIcon(this); // TODO should this be per-mode?
Toolkit.setIcon(this); // TODO should this be per-mode?
// Install default actions for Run, Present, etc.
// resetHandlers();
@@ -574,7 +574,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
JMenuItem item;
JMenu fileMenu = new JMenu("File");
item = Base.newJMenuItem("New", 'N');
item = Toolkit.newJMenuItem("New", 'N');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleNew();
@@ -582,7 +582,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
fileMenu.add(item);
item = Base.newJMenuItem("Open...", 'O');
item = Toolkit.newJMenuItem("Open...", 'O');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleOpenPrompt();
@@ -593,7 +593,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
fileMenu.add(base.getSketchbookMenu());
// fileMenu.add(mode.getExamplesMenu());
item = Base.newJMenuItemShift("Examples...", 'O');
item = Toolkit.newJMenuItemShift("Examples...", 'O');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mode.showExamplesFrame();
@@ -601,7 +601,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
fileMenu.add(item);
item = Base.newJMenuItem("Close", 'W');
item = Toolkit.newJMenuItem("Close", 'W');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleClose(Editor.this, false);
@@ -609,7 +609,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
fileMenu.add(item);
item = Base.newJMenuItem("Save", 'S');
item = Toolkit.newJMenuItem("Save", 'S');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleSave(false);
@@ -618,7 +618,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
saveMenuItem = item;
fileMenu.add(item);
item = Base.newJMenuItemShift("Save As...", 'S');
item = Toolkit.newJMenuItemShift("Save As...", 'S');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleSaveAs();
@@ -634,7 +634,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
}
fileMenu.addSeparator();
item = Base.newJMenuItemShift("Page Setup", 'P');
item = Toolkit.newJMenuItemShift("Page Setup", 'P');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handlePageSetup();
@@ -642,7 +642,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
fileMenu.add(item);
item = Base.newJMenuItem("Print", 'P');
item = Toolkit.newJMenuItem("Print", 'P');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handlePrint();
@@ -655,7 +655,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
if (!Base.isMacOS()) {
fileMenu.addSeparator();
item = Base.newJMenuItem("Preferences", ',');
item = Toolkit.newJMenuItem("Preferences", ',');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handlePrefs();
@@ -665,7 +665,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
fileMenu.addSeparator();
item = Base.newJMenuItem("Quit", 'Q');
item = Toolkit.newJMenuItem("Quit", 'Q');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleQuit();
@@ -691,16 +691,16 @@ public abstract class Editor extends JFrame implements RunnerListener {
JMenu menu = new JMenu("Edit");
JMenuItem item;
undoItem = Base.newJMenuItem("Undo", 'Z');
undoItem = Toolkit.newJMenuItem("Undo", 'Z');
undoItem.addActionListener(undoAction = new UndoAction());
menu.add(undoItem);
// Gotta follow them interface guidelines
// http://code.google.com/p/processing/issues/detail?id=363
if (Base.isWindows()) {
redoItem = Base.newJMenuItem("Redo", 'Y');
redoItem = Toolkit.newJMenuItem("Redo", 'Y');
} else { // Linux and OS X
redoItem = Base.newJMenuItemShift("Redo", 'Z');
redoItem = Toolkit.newJMenuItemShift("Redo", 'Z');
}
redoItem.addActionListener(redoAction = new RedoAction());
menu.add(redoItem);
@@ -709,7 +709,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
// TODO "cut" and "copy" should really only be enabled
// if some text is currently selected
item = Base.newJMenuItem("Cut", 'X');
item = Toolkit.newJMenuItem("Cut", 'X');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleCut();
@@ -717,7 +717,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
menu.add(item);
item = Base.newJMenuItem("Copy", 'C');
item = Toolkit.newJMenuItem("Copy", 'C');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textarea.copy();
@@ -725,7 +725,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
menu.add(item);
item = Base.newJMenuItemShift("Copy as HTML", 'C');
item = Toolkit.newJMenuItemShift("Copy as HTML", 'C');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleCopyAsHTML();
@@ -733,7 +733,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
menu.add(item);
item = Base.newJMenuItem("Paste", 'V');
item = Toolkit.newJMenuItem("Paste", 'V');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textarea.paste();
@@ -742,7 +742,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
menu.add(item);
item = Base.newJMenuItem("Select All", 'A');
item = Toolkit.newJMenuItem("Select All", 'A');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textarea.selectAll();
@@ -753,7 +753,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
/*
menu.addSeparator();
item = Base.newJMenuItem("Delete Selected Lines", 'D');
item = Toolkit.newJMenuItem("Delete Selected Lines", 'D');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleDeleteLines();
@@ -782,7 +782,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
menu.addSeparator();
item = Base.newJMenuItem("Auto Format", 'T');
item = Toolkit.newJMenuItem("Auto Format", 'T');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleAutoFormat();
@@ -790,7 +790,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
menu.add(item);
item = Base.newJMenuItem("Comment/Uncomment", '/');
item = Toolkit.newJMenuItem("Comment/Uncomment", '/');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleCommentUncomment();
@@ -798,7 +798,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
menu.add(item);
item = Base.newJMenuItem("Increase Indent", ']');
item = Toolkit.newJMenuItem("Increase Indent", ']');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleIndentOutdent(true);
@@ -806,7 +806,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
menu.add(item);
item = Base.newJMenuItem("Decrease Indent", '[');
item = Toolkit.newJMenuItem("Decrease Indent", '[');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleIndentOutdent(false);
@@ -816,7 +816,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
menu.addSeparator();
item = Base.newJMenuItem("Find...", 'F');
item = Toolkit.newJMenuItem("Find...", 'F');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find == null) {
@@ -830,7 +830,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
// TODO find next should only be enabled after a
// search has actually taken place
item = Base.newJMenuItem("Find Next", 'G');
item = Toolkit.newJMenuItem("Find Next", 'G');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find != null) {
@@ -840,7 +840,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
});
menu.add(item);
item = Base.newJMenuItemShift("Find Previous", 'G');
item = Toolkit.newJMenuItemShift("Find Previous", 'G');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find != null) {
@@ -851,7 +851,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
menu.add(item);
// For Arduino and Mac, this should be command-E, but that currently conflicts with Export Applet
item = Base.newJMenuItemAlt("Use Selection for Find", 'F');
item = Toolkit.newJMenuItemAlt("Use Selection for Find", 'F');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find == null) {
@@ -881,7 +881,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
sketchMenu.add(mode.getImportMenu());
item = Base.newJMenuItem("Show Sketch Folder", 'K');
item = Toolkit.newJMenuItem("Show Sketch Folder", 'K');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Base.openFolder(sketch.getFolder());
+3 -4
View File
@@ -348,7 +348,6 @@ public class EditorHeader extends JComponent {
//System.out.println("rebuilding editor header");
rebuildMenu();
repaint();
Toolkit.getDefaultToolkit().sync();
}
@@ -410,7 +409,7 @@ public class EditorHeader extends JComponent {
*/
//item = new JMenuItem("New Tab");
item = Base.newJMenuItemShift("New Tab", 'N');
item = Toolkit.newJMenuItemShift("New Tab", 'N');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editor.getSketch().handleNewCode();
@@ -457,7 +456,7 @@ public class EditorHeader extends JComponent {
item = new JMenuItem("Previous Tab");
KeyStroke ctrlAltLeft =
KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Base.SHORTCUT_ALT_KEY_MASK);
KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Toolkit.SHORTCUT_ALT_KEY_MASK);
item.setAccelerator(ctrlAltLeft);
// this didn't want to work consistently
/*
@@ -471,7 +470,7 @@ public class EditorHeader extends JComponent {
item = new JMenuItem("Next Tab");
KeyStroke ctrlAltRight =
KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Base.SHORTCUT_ALT_KEY_MASK);
KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Toolkit.SHORTCUT_ALT_KEY_MASK);
item.setAccelerator(ctrlAltRight);
/*
item.addActionListener(new ActionListener() {
+5 -5
View File
@@ -242,13 +242,13 @@ public class FindReplace extends JFrame {
handleClose();
}
});
Base.registerWindowCloseKeys(getRootPane(), new ActionListener() {
Toolkit.registerWindowCloseKeys(getRootPane(), new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
//hide();
handleClose();
}
});
Base.setIcon(this);
Toolkit.setIcon(this);
// hack to to get first field to focus properly on osx
addWindowListener(new WindowAdapter() {
@@ -441,7 +441,7 @@ public class FindReplace extends JFrame {
}
}
if (!foundAtLeastOne) {
Toolkit.getDefaultToolkit().beep();
Toolkit.beep();
}
setFound(false);
}
@@ -455,14 +455,14 @@ public class FindReplace extends JFrame {
public void findNext() {
if (!find(wrapAround, false)) {
Toolkit.getDefaultToolkit().beep();
Toolkit.beep();
}
}
public void findPrevious() {
if (!find(wrapAround, true)) {
Toolkit.getDefaultToolkit().beep();
Toolkit.beep();
}
}
}
+2 -2
View File
@@ -231,7 +231,7 @@ public abstract class Mode {
//System.out.println("rebuilding toolbar menu");
// Add the single "Open" item
item = Base.newJMenuItem("Open...", 'O');
item = Toolkit.newJMenuItem("Open...", 'O');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleOpenPrompt();
@@ -241,7 +241,7 @@ public abstract class Mode {
insertToolbarRecentMenu();
item = Base.newJMenuItemShift("Examples...", 'O');
item = Toolkit.newJMenuItemShift("Examples...", 'O');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showExamplesFrame();
+4 -4
View File
@@ -500,10 +500,10 @@ public class Preferences {
disposeFrame();
}
};
Base.registerWindowCloseKeys(dialog.getRootPane(), disposer);
Base.setIcon(dialog);
Toolkit.registerWindowCloseKeys(dialog.getRootPane(), disposer);
Toolkit.setIcon(dialog);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension screen = Toolkit.getScreenSize();
dialog.setLocation((screen.width - wide) / 2,
(screen.height - high) / 2);
@@ -518,7 +518,7 @@ public class Preferences {
pain.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
//System.out.println(e);
KeyStroke wc = Base.WINDOW_CLOSE_KEYSTROKE;
KeyStroke wc = Toolkit.WINDOW_CLOSE_KEYSTROKE;
if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
(KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
disposeFrame();
@@ -23,10 +23,15 @@
package processing.app.contrib;
import java.awt.*;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.event.*;
@@ -34,6 +39,7 @@ import javax.swing.event.*;
import processing.app.Base;
import processing.app.Editor;
import processing.app.Library;
import processing.app.Toolkit;
import processing.app.contrib.ContributionListing.Filter;
public class ContributionManagerDialog {
@@ -79,14 +85,14 @@ public class ContributionManagerDialog {
if (dialog == null) {
dialog = new JFrame(title);
Base.setIcon(dialog);
Toolkit.setIcon(dialog);
createComponents();
registerDisposeListeners();
dialog.pack();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension screen = Toolkit.getScreenSize();
dialog.setLocation((screen.width - dialog.getWidth()) / 2,
(screen.height - dialog.getHeight()) / 2);
@@ -267,14 +273,14 @@ public class ContributionManagerDialog {
disposeFrame();
}
};
Base.registerWindowCloseKeys(dialog.getRootPane(), disposer);
Toolkit.registerWindowCloseKeys(dialog.getRootPane(), disposer);
// handle window closing commands for ctrl/cmd-W or hitting ESC.
dialog.getContentPane().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
//System.out.println(e);
KeyStroke wc = Base.WINDOW_CLOSE_KEYSTROKE;
KeyStroke wc = Toolkit.WINDOW_CLOSE_KEYSTROKE;
if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
(KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
disposeFrame();
@@ -472,9 +478,9 @@ public class ContributionManagerDialog {
.setVisible(false);
}
}
}
abstract class JProgressMonitor extends AbstractProgressMonitor {
JProgressBar progressBar;
@@ -29,6 +29,7 @@ import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import processing.app.Base;
import processing.app.Toolkit;
import com.apple.eawt.*;
@@ -107,7 +108,7 @@ public class ThinkDifferent implements ApplicationListener {
JMenuItem item;
JMenu fileMenu = new JMenu("File");
item = Base.newJMenuItem("New", 'N');
item = Toolkit.newJMenuItem("New", 'N');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleNew();
@@ -115,7 +116,7 @@ public class ThinkDifferent implements ApplicationListener {
});
fileMenu.add(item);
item = Base.newJMenuItem("Open...", 'O');
item = Toolkit.newJMenuItem("Open...", 'O');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleOpenPrompt();
@@ -13,16 +13,17 @@ package processing.app.syntax;
import processing.app.*;
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Vector;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.undo.*;
import javax.swing.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.awt.*;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Vector;
import java.awt.im.InputMethodRequests;
import processing.app.syntax.im.InputMethodSupport;
@@ -1715,7 +1716,7 @@ public class JEditTextArea extends JComponent
cf.append("\n</pre>");
StringSelection formatted = new StringSelection(cf.toString());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Clipboard clipboard = processing.app.Toolkit.getSystemClipboard();
clipboard.setContents(formatted, new ClipboardOwner() {
public void lostOwnership(Clipboard clipboard, Transferable contents) {
// i don't care about ownership
@@ -24,7 +24,12 @@ package processing.app.tools;
import processing.app.*;
import processing.core.*;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
@@ -115,7 +120,7 @@ public class ColorSelector implements Tool, DocumentListener {
//slider.setSize(256, 20);
Dimension size = frame.getSize();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension screen = Toolkit.getScreenSize();
frame.setLocation((screen.width - size.width) / 2,
(screen.height - size.height) / 2);
@@ -125,13 +130,13 @@ public class ColorSelector implements Tool, DocumentListener {
frame.setVisible(false);
}
});
Base.registerWindowCloseKeys(frame.getRootPane(), new ActionListener() {
Toolkit.registerWindowCloseKeys(frame.getRootPane(), new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
frame.setVisible(false);
}
});
Base.setIcon(frame);
Toolkit.setIcon(frame);
hueField.getDocument().addDocumentListener(this);
saturationField.getDocument().addDocumentListener(this);
+16 -7
View File
@@ -26,7 +26,16 @@ package processing.app.tools;
import processing.app.*;
import processing.core.*;
import java.awt.*;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.RenderingHints;
import java.awt.event.*;
import java.io.*;
import java.util.*;
@@ -230,8 +239,8 @@ public class CreateFont extends JFrame implements Tool {
setVisible(false);
}
};
Base.registerWindowCloseKeys(root, disposer);
Base.setIcon(this);
Toolkit.registerWindowCloseKeys(root, disposer);
Toolkit.setIcon(this);
setResizable(false);
pack();
@@ -241,7 +250,7 @@ public class CreateFont extends JFrame implements Tool {
fontSelector.setSelectedIndex(0);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension screen = Toolkit.getScreenSize();
windowSize = getSize();
setLocation((screen.width - windowSize.width) / 2,
@@ -556,12 +565,12 @@ class CharacterSelector extends JFrame {
setVisible(false);
}
};
Base.registerWindowCloseKeys(root, disposer);
Base.setIcon(this);
Toolkit.registerWindowCloseKeys(root, disposer);
Toolkit.setIcon(this);
pack();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension screen = Toolkit.getScreenSize();
Dimension windowSize = getSize();
setLocation((screen.width - windowSize.width) / 2,
@@ -113,7 +113,7 @@ public class AndroidEditor extends JavaEditor {
public JMenu buildFileMenu() {
String exportPkgTitle = AndroidToolbar.getTitle(AndroidToolbar.EXPORT, false);
JMenuItem exportPackage = Base.newJMenuItem(exportPkgTitle, 'E');
JMenuItem exportPackage = Toolkit.newJMenuItem(exportPkgTitle, 'E');
exportPackage.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleExportPackage();
@@ -121,7 +121,7 @@ public class AndroidEditor extends JavaEditor {
});
String exportProjectTitle = AndroidToolbar.getTitle(AndroidToolbar.EXPORT, true);
JMenuItem exportProject = Base.newJMenuItemShift(exportProjectTitle, 'E');
JMenuItem exportProject = Toolkit.newJMenuItemShift(exportProjectTitle, 'E');
exportProject.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleExportProject();
@@ -133,14 +133,14 @@ public class AndroidEditor extends JavaEditor {
public JMenu buildSketchMenu() {
JMenuItem runItem = Base.newJMenuItem(AndroidToolbar.getTitle(AndroidToolbar.RUN, false), 'R');
JMenuItem runItem = Toolkit.newJMenuItem(AndroidToolbar.getTitle(AndroidToolbar.RUN, false), 'R');
runItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleRunDevice();
}
});
JMenuItem presentItem = Base.newJMenuItemShift(AndroidToolbar.getTitle(AndroidToolbar.RUN, true), 'R');
JMenuItem presentItem = Toolkit.newJMenuItemShift(AndroidToolbar.getTitle(AndroidToolbar.RUN, true), 'R');
presentItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleRunEmulator();
@@ -21,7 +21,9 @@
package processing.mode.android;
import java.awt.*;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.HashMap;
@@ -33,6 +35,7 @@ import javax.swing.event.*;
import processing.app.Base;
import processing.app.Preferences;
import processing.app.Sketch;
import processing.app.Toolkit;
public class Permissions extends JFrame {
@@ -278,12 +281,12 @@ public class Permissions extends JFrame {
setVisible(false);
}
};
Base.registerWindowCloseKeys(root, disposer);
Base.setIcon(this);
Toolkit.registerWindowCloseKeys(root, disposer);
Toolkit.setIcon(this);
pack();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension screen = Toolkit.getScreenSize();
Dimension windowSize = getSize();
setLocation((screen.width - windowSize.width) / 2,
+5 -4
View File
@@ -9,6 +9,7 @@ import javax.swing.*;
import javax.swing.border.*;
import processing.app.*;
import processing.app.Toolkit;
import processing.mode.java.runner.Runner;
@@ -48,7 +49,7 @@ public class JavaEditor extends Editor {
public JMenu buildFileMenu() {
String appTitle = JavaToolbar.getTitle(JavaToolbar.EXPORT, false);
JMenuItem exportApplication = Base.newJMenuItem(appTitle, 'E');
JMenuItem exportApplication = Toolkit.newJMenuItem(appTitle, 'E');
exportApplication.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleExportApplication();
@@ -68,14 +69,14 @@ public class JavaEditor extends Editor {
public JMenu buildSketchMenu() {
JMenuItem runItem = Base.newJMenuItem(JavaToolbar.getTitle(JavaToolbar.RUN, false), 'R');
JMenuItem runItem = Toolkit.newJMenuItem(JavaToolbar.getTitle(JavaToolbar.RUN, false), 'R');
runItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleRun();
}
});
JMenuItem presentItem = Base.newJMenuItemShift(JavaToolbar.getTitle(JavaToolbar.RUN, true), 'R');
JMenuItem presentItem = Toolkit.newJMenuItemShift(JavaToolbar.getTitle(JavaToolbar.RUN, true), 'R');
presentItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handlePresent();
@@ -126,7 +127,7 @@ public class JavaEditor extends Editor {
});
menu.add(item);
item = Base.newJMenuItemShift("Find in Reference", 'F');
item = Toolkit.newJMenuItemShift("Find in Reference", 'F');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (textarea.isSelectionActive()) {
@@ -3,8 +3,11 @@ package processing.mode.javascript;
import processing.app.Base;
import processing.app.Sketch;
import processing.app.SketchCode;
import processing.app.Toolkit;
import java.awt.*;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.*;
import javax.swing.*;
@@ -21,7 +24,7 @@ import java.util.regex.*;
public class DirectivesEditor
{
JavaScriptEditor editor;
JFrame frame;
JCheckBox crispBox;
JTextField fontField;
@@ -45,37 +48,37 @@ public class DirectivesEditor
private final static int PAUSE_ON_BLUR = 3;
private final static int PRELOAD = 4;
private final static int TRANSPARENT = 5;
private Pattern pjsPattern;
private Pattern pjsPattern;
public DirectivesEditor ( JavaScriptEditor e )
{
editor = e;
if ( frame == null ) createFrame();
// see processing-1.2.0.js
pjsPattern = Pattern.compile(
"\\/\\*\\s*@pjs\\s+((?:[^\\*]|\\*+[^\\*\\/])*)\\*\\/\\s*",
pjsPattern = Pattern.compile(
"\\/\\*\\s*@pjs\\s+((?:[^\\*]|\\*+[^\\*\\/])*)\\*\\/\\s*",
Pattern.DOTALL );
}
public void show ()
{
if ( editor.getSketch().isModified())
{
Base.showWarning( "Directives Editor",
Base.showWarning( "Directives Editor",
"Please save your sketch before changing "+
"the directives.", null);
return;
}
resetInterface();
findRemoveDirectives(false);
frame.setVisible(true);
}
private void resetInterface ()
{
for ( JCheckBox b : new JCheckBox[] {
@@ -93,14 +96,14 @@ public class DirectivesEditor
{
frame.setVisible(false);
}
void applyDirectives ()
{
findRemoveDirectives(true);
StringBuffer buffer = new StringBuffer();
String head = "", toe = "; \n";
if ( crispBox.isSelected() )
buffer.append( head + "crisp=true" + toe );
if ( !fontField.getText().trim().equals("") )
@@ -113,7 +116,7 @@ public class DirectivesEditor
buffer.append( head + "preload=\""+preloadField.getText().trim()+"\"" + toe );
/*if ( transparentBox.isSelected() )
buffer.append( head + "transparent=true" + toe );*/
Sketch sketch = editor.getSketch();
SketchCode code = sketch.getCode(0); // first tab
if ( buffer.length() > 0 )
@@ -123,31 +126,31 @@ public class DirectivesEditor
{
editor.setText(sketch.getCurrentCode().getProgram());
editor.setSelection(0,0);
}
}
sketch.setModified( false );
sketch.setModified( true );
}
}
void findRemoveDirectives ( boolean clean )
{
{
//if ( clean ) editor.startCompoundEdit();
Sketch sketch = editor.getSketch();
for (int i = 0; i < sketch.getCodeCount(); i++)
{
SketchCode code = sketch.getCode(i);
String program = code.getProgram();
StringBuffer buffer = new StringBuffer();
Matcher m = pjsPattern.matcher( program );
while (m.find())
{
String mm = m.group();
// TODO this urgently needs tests ..
/* remove framing */
mm = mm.replaceAll("^\\/\\*\\s*@pjs","").replaceAll("\\s*\\*\\/\\s*$","");
/* fix multiline nice formatting */
@@ -155,9 +158,9 @@ public class DirectivesEditor
/* fix multiline version without semicolons */
mm = mm.replaceAll("[\\s]*([^;\\s\\n\\r]+)[\\s]*[\\n\\r]+","$1;");
mm = mm.replaceAll("\n"," ").replaceAll("\r"," ");
//System.out.println(mm);
if ( clean )
{
m.appendReplacement(buffer, "");
@@ -172,17 +175,17 @@ public class DirectivesEditor
}
}
}
if ( clean )
{
m.appendTail(buffer);
// TODO: not working!
code.setProgram( buffer.toString() );
code.setModified( true );
}
}
if ( clean )
{
//editor.stopCompoundEdit();
@@ -191,7 +194,7 @@ public class DirectivesEditor
sketch.setModified( true );
}
}
private void parseDirective ( String directive )
{
if ( directive == null )
@@ -199,23 +202,23 @@ public class DirectivesEditor
System.err.println( "Directive is null." );
return;
}
String[] pair = directive.split("=");
if ( pair == null || pair.length != 2 )
{
System.err.println("Unable to parse directive: \"" + directive + "\" Ignored.");
return;
}
String key = pair[0].trim(),
String key = pair[0].trim(),
value = pair[1].trim();
// clean these, might have too much whitespace around commas
if ( validKeys.indexOf(key) == FONT || validKeys.indexOf(key) == PRELOAD )
{
value = value.replaceAll("[\\s]*,[\\s]*", ",");
}
if ( validKeys.indexOf(key) == -1 )
{
System.err.println("Directive key not recognized: \"" + key + "\" Ignored." );
@@ -226,11 +229,11 @@ public class DirectivesEditor
System.err.println("Directive value empty. Ignored.");
return;
}
value = value.replaceAll("^\"|\"$","").replaceAll("^'|'$","");
//System.out.println( key + " = " + value );
boolean v;
switch ( validKeys.indexOf(key) )
{
@@ -257,8 +260,8 @@ public class DirectivesEditor
//transparentBox.setSelected(v);
break;
}
}
}
void createFrame ()
{
/* see Preferences.java */
@@ -266,17 +269,17 @@ public class DirectivesEditor
int GUI_BETWEEN = 10;
int GUI_SMALL = 6;
int FIELD_SIZE = 30;
int left = GUI_BIG;
int top = GUI_BIG;
int right = 0;
Dimension d;
frame = new JFrame("Directives Editor");
Container pane = frame.getContentPane();
pane.setLayout(null);
JLabel label = new JLabel("Click here to read about directives.");
label.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e) {
@@ -291,9 +294,9 @@ public class DirectivesEditor
d = label.getPreferredSize();
label.setBounds(left, top, d.width, d.height);
top += d.height + GUI_BETWEEN + GUI_BETWEEN;
// CRISP
crispBox =
new JCheckBox("\"crisp\": disable antialiasing for line(), triangle() and rect()");
pane.add(crispBox);
@@ -301,20 +304,20 @@ public class DirectivesEditor
crispBox.setBounds(left, top, d.width + 10, d.height);
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN;
// FONTS
label = new JLabel("\"font\": to load (comma separated)");
pane.add(label);
d = label.getPreferredSize();
label.setBounds(left, top, d.width, d.height);
top += d.height + GUI_SMALL;
fontField = new JTextField(FIELD_SIZE);
pane.add(fontField);
d = fontField.getPreferredSize();
fontField.setBounds(left, top, d.width, d.height);
JButton button = new JButton("scan");
button.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e) {
@@ -326,9 +329,9 @@ public class DirectivesEditor
button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
top += d.height + GUI_BETWEEN;
// GLOBAL_KEY_EVENTS
globalKeyEventsBox =
new JCheckBox("\"globalKeyEvents\": receive global key events");
pane.add(globalKeyEventsBox);
@@ -336,9 +339,9 @@ public class DirectivesEditor
globalKeyEventsBox.setBounds(left, top, d.width + 10, d.height);
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN;
// PAUSE_ON_BLUR
pauseOnBlurBox =
new JCheckBox("\"pauseOnBlur\": pause if applet loses focus");
pane.add(pauseOnBlurBox);
@@ -346,9 +349,9 @@ public class DirectivesEditor
pauseOnBlurBox.setBounds(left, top, d.width + 10, d.height);
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN;
// PRELOAD images
label = new JLabel("\"preload\": images (comma separated)");
pane.add(label);
d = label.getPreferredSize();
@@ -371,9 +374,9 @@ public class DirectivesEditor
button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
top += d.height + GUI_BETWEEN;
// TRANSPARENT
/*transparentBox =
new JCheckBox("\"transparent\": set applet background to be transparent");
pane.add(transparentBox);
@@ -381,9 +384,9 @@ public class DirectivesEditor
transparentBox.setBounds(left, top, d.width + 10, d.height);
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN;*/
// APPLY / OK
button = new JButton("OK");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -410,29 +413,29 @@ public class DirectivesEditor
button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
top += BUTTON_HEIGHT + GUI_BETWEEN;
//frame.getContentPane().add(box);
frame.pack();
Insets insets = frame.getInsets();
frame.setSize(right + GUI_BIG + insets.left + insets.right,
top + GUI_SMALL + insets.top + insets.bottom);
//frame.setResizable(false);
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
frame.setVisible(false);
}
});
Base.registerWindowCloseKeys(frame.getRootPane(), new ActionListener() {
Toolkit.registerWindowCloseKeys(frame.getRootPane(), new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
frame.setVisible(false);
}
});
Base.setIcon(frame);
Toolkit.setIcon(frame);
}
void handleScanFonts()
{
handleScanFiles( fontField, new String[]{
@@ -446,7 +449,7 @@ public class DirectivesEditor
"gif", "jpg", "jpeg", "png", "tga"
});
}
void handleScanFiles ( JTextField field, String[] extensions )
{
String[] dataFiles = scanDataFolderForFilesByType(extensions);
@@ -480,29 +483,29 @@ public class DirectivesEditor
}
field.setText(finalFileList);
}
String[] scanDataFolderForFilesByType ( String[] extensions )
{
ArrayList files = new ArrayList();
File dataFolder = editor.getSketch().getDataFolder();
if ( !dataFolder.exists() ) return null; // TODO no folder present .. warn?
for ( String ext : extensions )
{
String[] found = listFiles(dataFolder, true, ext);
if ( found == null || found.length == 0 ) continue;
for ( String f : found )
{
if ( files.indexOf(f) == -1 )
files.add(f);
}
}
return (String[])files.toArray(new String[0]);
}
// #718
// http://code.google.com/p/processing/issues/detail?id=718
private String[] listFiles(File folder, boolean relative, String extension) {
@@ -26,7 +26,7 @@ public class JavaScriptEditor extends ServingEditor
// tapping into Java mode might not be wanted?
processing.mode.java.PdeKeyListener listener;
/**
* Constructor, overrides ServingEditor( .. )
*
@@ -45,9 +45,9 @@ public class JavaScriptEditor extends ServingEditor
// abstract Editor implementations
// and standard overrides
// ----------------------------------------
/**
* Create and return the toolbar (tools above text area),
* Create and return the toolbar (tools above text area),
* implements abstract Editor.createToolbar(),
* called in Editor constructor to add the toolbar to the window.
*
@@ -60,7 +60,7 @@ public class JavaScriptEditor extends ServingEditor
}
/**
* Create a formatter to prettify code,
* Create a formatter to prettify code,
* implements abstract Editor.createFormatter(),
* called by Editor.handleAutoFormat() to handle menu item or shortcut
*
@@ -80,7 +80,7 @@ public class JavaScriptEditor extends ServingEditor
*/
public JMenu buildFileMenu ()
{
JMenuItem exportItem = Base.newJMenuItem("Export", 'E');
JMenuItem exportItem = Toolkit.newJMenuItem("Export", 'E');
exportItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleExport( true );
@@ -98,14 +98,14 @@ public class JavaScriptEditor extends ServingEditor
*/
public JMenu buildSketchMenu ()
{
JMenuItem startServerItem = Base.newJMenuItem("Run in Browser", 'R');
JMenuItem startServerItem = Toolkit.newJMenuItem("Run in Browser", 'R');
startServerItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleStartServer();
}
});
JMenuItem openInBrowserItem = Base.newJMenuItem("Reopen in Browser", 'B');
JMenuItem openInBrowserItem = Toolkit.newJMenuItem("Reopen in Browser", 'B');
openInBrowserItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleOpenInBrowser();
@@ -120,8 +120,8 @@ public class JavaScriptEditor extends ServingEditor
});
return buildSketchMenu(new JMenuItem[] {
startServerItem,
openInBrowserItem,
startServerItem,
openInBrowserItem,
stopServerItem
});
}
@@ -133,11 +133,11 @@ public class JavaScriptEditor extends ServingEditor
*
* @return JMenu containing the menu items for "JavaScript" menu
*/
public JMenu buildModeMenu()
public JMenu buildModeMenu()
{
JMenu menu = new JMenu("JavaScript");
JMenuItem item;
item = new JMenuItem("Playback Settings (Directives)");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -145,7 +145,7 @@ public class JavaScriptEditor extends ServingEditor
}
});
menu.add(item);
JMenuItem copyServerAddressItem = new JMenuItem("Copy Server Address");
copyServerAddressItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
@@ -182,7 +182,7 @@ public class JavaScriptEditor extends ServingEditor
return menu;
}
/**
* Build the "Help" menu,
* implements abstract Editor.buildHelpMenu(),
@@ -243,7 +243,7 @@ public class JavaScriptEditor extends ServingEditor
});
menu.add(item);
item = Base.newJMenuItemShift("Find in Reference", 'F');
item = Toolkit.newJMenuItemShift("Find in Reference", 'F');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleFindReferenceImpl();
@@ -288,7 +288,7 @@ public class JavaScriptEditor extends ServingEditor
* Returns the default commenting prefix for comment/uncomment command,
* implements abstract Editor.getCommentPrefix(),
* called from Editor.handleCommentUncomment()
*
*
* @return the comment prefix as String
*/
public String getCommentPrefix ()
@@ -312,7 +312,7 @@ public class JavaScriptEditor extends ServingEditor
directivesEditor = null;
}
}
/**
* Implements abstract Editor.deactivateRun()
*/
@@ -333,7 +333,7 @@ public class JavaScriptEditor extends ServingEditor
statusEmpty();
boolean wasRunning = serverRunning();
if ( wasRunning )
if ( wasRunning )
{
statusNotice("Server was running, changing the port requires a restart.");
stopServer();
@@ -434,7 +434,7 @@ public class JavaScriptEditor extends ServingEditor
// TODO: catch handleFindReference directly
handleFindReferenceImpl();
}
/**
* Menu item callback, handles showing a reference page.
*/
@@ -465,7 +465,7 @@ public class JavaScriptEditor extends ServingEditor
// waiting for server to call "serverStarted() below ..."
}
/**
* Menu item callback, open running server address in a browser
*/
@@ -485,7 +485,7 @@ public class JavaScriptEditor extends ServingEditor
}
/**
* Menu item callback, call the export method of the sketch
* Menu item callback, call the export method of the sketch
* and handle the gui stuff
*/
public boolean handleExport ( boolean openFolder )
@@ -522,29 +522,29 @@ public class JavaScriptEditor extends ServingEditor
}
/**
* Menu item callback, changed from Editor.java to automaticaly
* export and handle the server when it's running.
* Menu item callback, changed from Editor.java to automaticaly
* export and handle the server when it's running.
* Normal save ops otherwise.
*
* @param immediately set to false to allow it to be run in a Swing optimized manner
* @param immediately set to false to allow it to be run in a Swing optimized manner
*/
public boolean handleSave ( boolean immediately )
{
if (sketch.isUntitled())
if (sketch.isUntitled())
{
return handleSaveAs();
}
else if (immediately)
}
else if (immediately)
{
handleSave();
statusEmpty();
if ( serverRunning() ) handleStartServer();
}
else
}
else
{
SwingUtilities.invokeLater(new Runnable()
SwingUtilities.invokeLater(new Runnable()
{
public void run()
public void run()
{
handleSave();
statusEmpty();
@@ -564,7 +564,7 @@ public class JavaScriptEditor extends ServingEditor
handleSaveImpl();
toolbar.deactivate(JavaScriptToolbar.SAVE);
}
/**
* Called from handleExport()
*/
@@ -619,7 +619,7 @@ public class JavaScriptEditor extends ServingEditor
// ----------------------------------------
/**
* BasicServerListener implementation,
* BasicServerListener implementation,
* called by server once it starts serving
*/
public void serverStarted ()
@@ -647,7 +647,7 @@ public class JavaScriptEditor extends ServingEditor
/**
* Return the custom template folder
*
*
* @return the custom template folder as File
*/
private File getCustomTemplateFolder ()
+13 -5
View File
@@ -15,11 +15,19 @@ X library manager using renameTo() (can't cross FS)
X http://code.google.com/p/processing/issues/detail?id=1295
X 2.0b3 needs existing sketchbook folder on Linux
X http://code.google.com/p/processing/issues/detail?id=1286
_ change mode handling so that XQMode works properly
_ move ecj.jar into the java mode folders
_ remove ecj.jar from the .exe, plist, sh, and the rest
_ replaced ecj.jar with org.eclipse.jdt.core_3.7.1.v_B76_R37x.jar
o change mode handling so that XQMode works properly
X decided to just replace ecj with jdt-core
o move ecj.jar into the java mode folders
X replace ecj.jar in the .exe, plist, sh, and the rest
X replaced ecj.jar with org.eclipse.jdt.core_3.7.1.v_B76_R37x.jar
X rationale
X built-in modes don't bother with their own 'mode' folder and don't
X currently use their own classloader. this could be changed, but as
X it turns out, things like XQMode already *depend* on JavaMode, so
X that would mean putting the .jar file for ecj into each of the modes
X that subclass it. not a good solution, but no good solution for
X library deps either. punting on that for now, and instead just deal
X with this specific (more esoteric) low-level case w/ a workaround
2.0 FINAL / command line