break up the overly large processing.app pkg and get some distance between ui and non-ui code

This commit is contained in:
Ben Fry
2015-06-26 09:56:57 -04:00
parent 1256c152c4
commit 0398780e7a
47 changed files with 198 additions and 117 deletions
+12 -23
View File
@@ -43,6 +43,11 @@ import javax.swing.JPopupMenu;
import javax.swing.tree.DefaultMutableTreeNode;
import processing.app.contrib.*;
import processing.app.ui.Editor;
import processing.app.ui.EditorConsole;
import processing.app.ui.EditorState;
import processing.app.ui.PreferencesFrame;
import processing.app.ui.Recent;
import processing.core.*;
import processing.data.StringDict;
import processing.data.StringList;
@@ -237,7 +242,7 @@ public class Base {
}
static protected boolean isCommandLine() {
static public boolean isCommandLine() {
return commandLine;
}
@@ -446,7 +451,7 @@ public class Base {
* The call has already checked to make sure this sketch is not modified,
* now change the mode.
*/
protected void changeMode(Mode mode) {
public void changeMode(Mode mode) {
if (activeEditor.getMode() != mode) {
Sketch sketch = activeEditor.getSketch();
nextMode = mode;
@@ -558,7 +563,7 @@ public class Base {
// changes to the focused and active Windows can be made. Developers must
// never assume that this Window is the focused or active Window until this
// Window receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event.
protected void handleActivated(Editor whichEditor) {
public void handleActivated(Editor whichEditor) {
activeEditor = whichEditor;
// set the current window to be the console that's getting output
@@ -1192,25 +1197,6 @@ public class Base {
}
// public JMenu getSketchbookMenu() {
// if (sketchbookMenu == null) {
// sketchbookMenu = new JMenu(Language.text("menu.file.sketchbook"));
// rebuildSketchbookMenu();
// }
// return sketchbookMenu;
// }
// public JMenu getRecentMenu() {
// if (recentMenu == null) {
// recentMenu = recent.createMenu();
// } else {
// recent.updateMenu(recentMenu);
// }
// return recentMenu;
// }
public JMenu getRecentMenu() {
return recent.getMenu();
}
@@ -1224,10 +1210,13 @@ public class Base {
public void handleRecent(Editor editor) {
recent.handle(editor);
}
public void handleRecentRename(Editor editor,String oldPath){
recent.handleRename(editor,oldPath);
}
/**
* Called before a sketch is renamed so that its old name is
* no longer in the menu.
@@ -1863,7 +1852,7 @@ public class Base {
* Used to determine whether to disable the "Show Sketch Folder" option.
* @return true If a means of opening a folder is known to be available.
*/
static protected boolean openFolderAvailable() {
static public boolean openFolderAvailable() {
return platform.openFolderAvailable();
}
+3
View File
@@ -41,6 +41,9 @@ import javax.swing.tree.*;
import processing.app.contrib.ContributionType;
import processing.app.contrib.ExamplesContribution;
import processing.app.syntax.*;
import processing.app.ui.Editor;
import processing.app.ui.EditorState;
import processing.app.ui.Toolkit;
import processing.core.PApplet;
import processing.core.PConstants;
+4 -24
View File
@@ -25,6 +25,7 @@ import java.awt.*;
import java.io.*;
import java.util.*;
import processing.app.ui.Toolkit;
import processing.core.*;
@@ -53,27 +54,6 @@ public class Preferences {
static HashMap<String, String> table = new HashMap<String, String>();
static File preferencesFile;
static final String PROMPT_YES = Language.text("prompt.yes");
static final String PROMPT_NO = Language.text("prompt.no");
static final String PROMPT_CANCEL = Language.text("prompt.cancel");
static final String PROMPT_OK = Language.text("prompt.ok");
static final String PROMPT_BROWSE = Language.text("prompt.browse");
/**
* Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
* Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
*/
static public int BUTTON_WIDTH =
Integer.parseInt(Language.text("preferences.button.width"));
// Indents and spacing standards. These probably need to be modified
// per platform as well, because Mac OS X is so huge, Windows is smaller,
// and Linux is all over the map. Consider these deprecated.
static final int GUI_BIG = 13;
static final int GUI_BETWEEN = 8;
static final int GUI_SMALL = 6;
static public void init() {
// start by loading the defaults, in case something
@@ -192,7 +172,7 @@ public class Preferences {
}
static protected String getPreferencesPath() {
static public String getPreferencesPath() {
return preferencesFile.getAbsolutePath();
}
@@ -262,7 +242,7 @@ public class Preferences {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
static protected void save() {
static public void save() {
// on startup, don't worry about it
// this is trying to update the prefs for who is open
// before Preferences.init() has been called.
@@ -452,7 +432,7 @@ public class Preferences {
}
static protected String getSketchbookPath() {
static public String getSketchbookPath() {
return get("sketchbook.path.three"); //$NON-NLS-1$
}
+1
View File
@@ -27,6 +27,7 @@ import java.awt.*;
import java.io.*;
import java.util.*;
import processing.app.ui.Toolkit;
import processing.core.*;
+16 -14
View File
@@ -23,6 +23,9 @@
package processing.app;
import processing.app.ui.Editor;
import processing.app.ui.ProgressFrame;
import processing.app.ui.Toolkit;
import processing.core.*;
import java.awt.Component;
@@ -407,8 +410,8 @@ public class Sketch {
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE,
null, new Object[] {
Preferences.PROMPT_OK,
Preferences.PROMPT_CANCEL },
Toolkit.PROMPT_OK,
Toolkit.PROMPT_CANCEL },
field);
if (userReply == JOptionPane.OK_OPTION) {
@@ -604,7 +607,7 @@ public class Sketch {
setCurrentCode(newName);
// update the tabs
editor.header.rebuild();
editor.rebuildHeader();
}
@@ -657,7 +660,7 @@ public class Sketch {
// make a new sketch, and i think this will rebuild the sketch menu
//editor.handleNewUnchecked();
//editor.handleClose2();
editor.base.handleClose(editor, false);
editor.getBase().handleClose(editor, false);
} else {
// delete the file
@@ -675,7 +678,7 @@ public class Sketch {
setCurrentCode(0);
// update the tabs
editor.header.repaint();
editor.repaintHeader();
}
}
}
@@ -737,7 +740,7 @@ public class Sketch {
break;
}
}
editor.header.repaint();
editor.repaintHeader();
if (Base.isMacOS()) {
// http://developer.apple.com/qa/qa2001/qa1146.html
@@ -797,7 +800,7 @@ public class Sketch {
* Also removes the previously-generated .class and .jar files,
* because they can cause trouble.
*/
protected boolean saveAs() throws IOException {
public boolean saveAs() throws IOException {
String newParentDir = null;
String newName = null;
@@ -1005,8 +1008,8 @@ public class Sketch {
calcModified();
// System.out.println("modified is now " + modified);
editor.updateTitle();
editor.base.rebuildSketchbookMenus();
editor.base.handleRecentRename(editor,oldPath);
editor.getBase().rebuildSketchbookMenus();
editor.getBase().handleRecentRename(editor,oldPath);
// editor.header.rebuild();
}
@@ -1099,7 +1102,7 @@ public class Sketch {
// check whether this file already exists
if (destFile.exists()) {
Object[] options = { Language.text("prompt.ok"), Language.text("prompt.cancel") };
String prompt = Language.interpolate("add_file.messages.confirm_replace",
String prompt = Language.interpolate("add_file.messages.confirm_replace",
filename);
int result = JOptionPane.showOptionDialog(editor,
prompt,
@@ -1167,7 +1170,7 @@ public class Sketch {
sortCode();
}
setCurrentCode(filename);
editor.header.repaint();
editor.repaintHeader();
if (isUntitled()) { // TODO probably not necessary? problematic?
// Mark the new code as modified so that the sketch is saved
current.setModified(true);
@@ -1217,8 +1220,7 @@ public class Sketch {
current.visited = System.currentTimeMillis();
editor.setCode(current);
// editor.header.rebuild();
editor.header.repaint();
editor.repaintHeader();
}
@@ -1226,7 +1228,7 @@ public class Sketch {
* Internal helper function to set the current tab based on a name.
* @param findName the file name (not pretty name) to be shown
*/
protected void setCurrentCode(String findName) {
public void setCurrentCode(String findName) {
for (int i = 0; i < codeCount; i++) {
if (findName.equals(code[i].getFileName()) ||
findName.equals(code[i].getPrettyName())) {
@@ -29,8 +29,8 @@ import java.util.zip.GZIPOutputStream;
import javax.swing.SwingWorker;
import processing.app.Base;
import processing.app.Editor;
import processing.app.Language;
import processing.app.ui.Editor;
import processing.core.PApplet;
import processing.data.StringDict;
@@ -31,6 +31,8 @@ import java.util.*;
import javax.swing.*;
import processing.app.*;
import processing.app.ui.Editor;
import processing.app.ui.Toolkit;
/**
*
@@ -41,9 +41,9 @@ import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.StyleSheet;
import processing.app.Base;
import processing.app.Editor;
import processing.app.Toolkit;
import processing.app.Language;
import processing.app.ui.Editor;
import processing.app.ui.Toolkit;
// TODO clean up accessors (too many cases of several de-references for basic tasks
@@ -38,6 +38,7 @@ import javax.swing.border.EmptyBorder;
import javax.swing.event.*;
import processing.app.*;
import processing.app.ui.Editor;
public class ContributionTab {
@@ -27,8 +27,8 @@ import java.io.IOException;
import java.util.ArrayList;
import processing.app.Base;
import processing.app.Editor;
import processing.app.Library;
import processing.app.ui.Editor;
public enum ContributionType {
LIBRARY, TOOL, MODE, EXAMPLES;
@@ -31,6 +31,7 @@ import java.util.zip.*;
import javax.swing.JOptionPane;
import processing.app.*;
import processing.app.ui.Editor;
import processing.core.PApplet;
import processing.data.StringDict;
import processing.data.StringList;
@@ -28,8 +28,8 @@ import java.util.*;
import processing.app.Base;
//import processing.app.Base;
import processing.app.Editor;
import processing.app.tools.Tool;
import processing.app.ui.Editor;
public class ToolContribution extends LocalContribution implements Tool {
@@ -31,6 +31,8 @@ import com.apple.eawt.*;
import com.apple.eawt.AppEvent.*;
import processing.app.*;
import processing.app.ui.About;
import processing.app.ui.Toolkit;
/**
@@ -1749,7 +1749,7 @@ public class JEditTextArea extends JComponent
HtmlSelection formatted = new HtmlSelection(cf.toString());
Clipboard clipboard = processing.app.Toolkit.getSystemClipboard();
Clipboard clipboard = processing.app.ui.Toolkit.getSystemClipboard();
clipboard.setContents(formatted, new ClipboardOwner() {
public void lostOwnership(Clipboard clipboard, Transferable contents) {
// i don't care about ownership
@@ -26,7 +26,7 @@ package processing.app.syntax;
import javax.swing.text.Segment;
import processing.app.Editor;
import processing.app.ui.Editor;
public class PdeKeywords extends TokenMarker {
@@ -25,6 +25,7 @@
package processing.app.tools;
import processing.app.*;
import processing.app.ui.Editor;
import processing.core.PApplet;
import java.io.*;
@@ -22,6 +22,9 @@
package processing.app.tools;
import processing.app.*;
import processing.app.ui.ColorChooser;
import processing.app.ui.Editor;
import processing.app.ui.Toolkit;
import java.awt.Color;
import java.awt.datatransfer.Clipboard;
@@ -24,6 +24,8 @@
package processing.app.tools;
import processing.app.*;
import processing.app.ui.Editor;
import processing.app.ui.Toolkit;
import processing.core.*;
import java.awt.Component;
@@ -29,8 +29,8 @@ import java.io.PrintWriter;
import javax.swing.JOptionPane;
import processing.app.Base;
import processing.app.Editor;
import processing.app.Language;
import processing.app.ui.Editor;
import processing.core.PApplet;
import processing.data.StringList;
+1 -1
View File
@@ -23,7 +23,7 @@
package processing.app.tools;
import processing.app.Editor;
import processing.app.ui.Editor;
/**
@@ -20,7 +20,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.Color;
import java.awt.Dimension;
@@ -34,6 +34,8 @@ import java.awt.Window;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import processing.app.Base;
public class About extends Window {
Image image;
@@ -1,4 +1,4 @@
package processing.app;
package processing.app.ui;
import java.awt.EventQueue;
import java.awt.Frame;
@@ -10,6 +10,11 @@ import java.lang.reflect.InvocationTargetException;
import javax.swing.JOptionPane;
import processing.app.Base;
import processing.app.Preferences;
import processing.app.Sketch;
import processing.app.SketchCode;
public class ChangeDetector implements WindowFocusListener {
private Sketch sketch;
@@ -19,8 +19,10 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import processing.app.Base;
import processing.app.Language;
import processing.core.*;
import java.awt.BorderLayout;
@@ -21,8 +21,17 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import processing.app.Base;
import processing.app.Formatter;
import processing.app.Language;
import processing.app.Mode;
import processing.app.Preferences;
import processing.app.RunnerListener;
import processing.app.Sketch;
import processing.app.SketchCode;
import processing.app.SketchException;
import processing.app.contrib.ToolContribution;
import processing.app.syntax.*;
import processing.app.tools.*;
@@ -534,6 +543,16 @@ public abstract class Editor extends JFrame implements RunnerListener {
}
public void repaintHeader() {
header.repaint();
}
public void rebuildHeader() {
header.rebuild();
}
protected void initModeMenu() {
modeMenu = new JMenu();
ButtonGroup modeGroup = new ButtonGroup();
@@ -1912,7 +1931,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
* Switch between tabs, this swaps out the Document object
* that's currently being manipulated.
*/
protected void setCode(SketchCode code) {
public void setCode(SketchCode code) {
SyntaxDocument document = (SyntaxDocument) code.getDocument();
if (document == null) { // this document not yet inited
@@ -2500,7 +2519,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
* Check if the sketch is modified and ask user to save changes.
* @return false if canceling the close/quit operation
*/
protected boolean checkModified() {
public boolean checkModified() {
if (!sketch.isModified()) return true;
// As of Processing 1.0.10, this always happens immediately.
@@ -18,13 +18,15 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package processing.app;
package processing.app.ui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import processing.app.Mode;
abstract public class EditorButton extends JComponent
implements MouseListener, MouseMotionListener, ActionListener {
@@ -21,7 +21,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.*;
import java.awt.event.*;
@@ -29,6 +29,10 @@ import java.io.*;
import javax.swing.*;
import javax.swing.text.*;
import processing.app.Base;
import processing.app.Mode;
import processing.app.Preferences;
import processing.core.PApplet;
import java.text.SimpleDateFormat;
@@ -22,7 +22,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.CardLayout;
import java.awt.Color;
@@ -39,6 +39,9 @@ import java.util.List;
import javax.swing.*;
import processing.app.Mode;
import processing.app.Sketch;
/**
* Console/error/whatever tabs at the bottom of the editor window.
@@ -22,7 +22,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.*;
import java.awt.event.*;
@@ -31,6 +31,12 @@ import java.util.Arrays;
import javax.swing.*;
import processing.app.Base;
import processing.app.Language;
import processing.app.Mode;
import processing.app.Sketch;
import processing.app.SketchCode;
/**
* Sketch tabs at the top of the editor window.
@@ -502,7 +508,7 @@ public class EditorHeader extends JComponent {
public void actionPerformed(ActionEvent e) {
Sketch sketch = editor.getSketch();
if (!Base.isMacOS() && // ok on OS X
editor.base.editors.size() == 1 && // mmm! accessor
editor.base.getEditors().size() == 1 && // mmm! accessor
sketch.getCurrentCodeIndex() == 0) {
Base.showWarning(Language.text("editor.header.delete.warning.title"),
Language.text("editor.header.delete.warning.text"), null);
@@ -19,7 +19,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
@@ -29,6 +29,7 @@ import java.awt.Rectangle;
import java.io.*;
import java.util.List;
import processing.app.Preferences;
import processing.core.PApplet;
//import processing.core.PApplet;
@@ -65,7 +66,7 @@ public class EditorState {
* set its placement relative to the last opened window.
* @param editors List of active editor objects
*/
EditorState(List<Editor> editors) {
public EditorState(List<Editor> editors) {
defaultConfig();
defaultLocation(editors);
}
@@ -21,19 +21,22 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.*;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import processing.app.Mode;
/**
* Panel just below the editing area that contains status messages.
*/
public class EditorStatus extends BasicSplitPaneDivider { //JPanel {
static final int HIGH = 28;
static final int GUI_SMALL = 6;
Color[] bgcolor;
Color[] fgcolor;
@@ -211,14 +214,14 @@ public class EditorStatus extends BasicSplitPaneDivider { //JPanel {
// https://github.com/processing/processing/issues/3265
if (message != null) {
g.setFont(font); // needs to be set each time on osx
g.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2);
g.drawString(message, GUI_SMALL, (sizeH + ascent) / 2);
}
if (indeterminate) {
//int x = cancelButton.getX();
//int w = cancelButton.getWidth();
int w = Preferences.BUTTON_WIDTH;
int x = getWidth() - Preferences.GUI_SMALL - w;
int w = Toolkit.BUTTON_WIDTH;
int x = getWidth() - GUI_SMALL - w;
int y = getHeight() / 3;
int h = getHeight() / 3;
g.setColor(new Color(0x80000000, true));
@@ -21,7 +21,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -41,6 +41,10 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import processing.app.Base;
import processing.app.Language;
import processing.app.Mode;
/**
* Run/Stop button plus Mode selection
@@ -20,7 +20,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.*;
import java.awt.event.*;
@@ -30,6 +30,10 @@ import javax.swing.GroupLayout.Group;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import processing.app.Base;
import processing.app.Language;
import processing.app.Sketch;
/**
* Find & Replace window for the Processing editor.
@@ -21,7 +21,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.*;
import java.awt.event.*;
@@ -32,8 +32,10 @@ import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import processing.app.ColorChooser;
import processing.app.Base;
import processing.app.Language;
import processing.app.Preferences;
import processing.app.ui.ColorChooser;
import processing.core.*;
@@ -92,7 +94,6 @@ public class PreferencesFrame {
pain.setLayout(layout);
final int BUTTON_WIDTH = Preferences.BUTTON_WIDTH;
final int BORDER = Base.isMacOS() ? 20 : 13;
JLabel sketchbookLocationLabel, restartProcessingLabel;
@@ -106,7 +107,7 @@ public class PreferencesFrame {
sketchbookLocationField = new JTextField(40);
browseButton = new JButton(Preferences.PROMPT_BROWSE);
browseButton = new JButton(Toolkit.PROMPT_BROWSE);
browseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
File dflt = new File(sketchbookLocationField.getText());
@@ -359,7 +360,7 @@ public class PreferencesFrame {
// [ OK ] [ Cancel ]
okButton = new JButton(Preferences.PROMPT_OK);
okButton = new JButton(Toolkit.PROMPT_OK);
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
applyFrame();
@@ -367,7 +368,7 @@ public class PreferencesFrame {
}
});
JButton cancelButton = new JButton(Preferences.PROMPT_CANCEL);
JButton cancelButton = new JButton(Toolkit.PROMPT_CANCEL);
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
disposeFrame();
@@ -428,8 +429,8 @@ public class PreferencesFrame {
.addComponent(preferencePathLabel)
.addComponent(preferenceHintLabel)
.addGroup(GroupLayout.Alignment.TRAILING,layout.createSequentialGroup() // Trailing so that the buttons are to the right
.addComponent(okButton, BUTTON_WIDTH, GroupLayout.DEFAULT_SIZE, BUTTON_WIDTH) // Ok and Cancel buttton are now of size BUTTON_WIDTH
.addComponent(cancelButton, BUTTON_WIDTH, GroupLayout.DEFAULT_SIZE, BUTTON_WIDTH)
.addComponent(okButton, Toolkit.BUTTON_WIDTH, GroupLayout.DEFAULT_SIZE, Toolkit.BUTTON_WIDTH) // Ok and Cancel buttton are now of size BUTTON_WIDTH
.addComponent(cancelButton, Toolkit.BUTTON_WIDTH, GroupLayout.DEFAULT_SIZE, Toolkit.BUTTON_WIDTH)
))
.addGap(BORDER)
);
@@ -660,7 +661,7 @@ public class PreferencesFrame {
}
protected void showFrame() {
public void showFrame() {
editorAntialiasBox.setSelected(Preferences.getBoolean("editor.smooth")); //$NON-NLS-1$
inputMethodBox.setSelected(Preferences.getBoolean("editor.input_method_support")); //$NON-NLS-1$
errorCheckerBox.setSelected(Preferences.getBoolean("pdex.errorCheckEnabled"));
@@ -1,4 +1,4 @@
package processing.app;
package processing.app.ui;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -15,6 +15,9 @@ import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.SwingWorker;
import processing.app.Base;
import processing.app.Language;
// TODO This code was contributed and needs a lot of work. [fry]
// + It probably shouldn't a "Frame" object at all.
@@ -19,7 +19,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.event.*;
import java.io.*;
@@ -28,6 +28,11 @@ import java.util.List;
import javax.swing.*;
import processing.app.Base;
import processing.app.Language;
import processing.app.Library;
import processing.app.Mode;
import processing.app.Preferences;
import processing.core.PApplet;
@@ -226,7 +231,7 @@ public class Recent {
}
synchronized void remove(Editor editor) {
synchronized public void remove(Editor editor) {
int index = findRecord(editor.getSketch().getMainFilePath());
if (index != -1) {
records.remove(index);
@@ -273,7 +278,7 @@ public class Recent {
* entry on the Recent queue. If the sketch is already in the list, it is
* first removed so it doesn't show up multiple times.
*/
synchronized void handle(Editor editor) {
synchronized public void handle(Editor editor) {
if (!editor.getSketch().isUntitled()) {
// If this sketch is already in the menu, remove it
remove(editor);
@@ -294,7 +299,7 @@ public class Recent {
}
//handles renaming done within processing
synchronized void handleRename(Editor editor,String oldPath){
synchronized public void handleRename(Editor editor,String oldPath){
if (records.size() == remember) {
records.remove(0); // remove the first entry
}
@@ -305,7 +310,8 @@ synchronized void handleRename(Editor editor,String oldPath){
}
records.add(new Record(editor));
save();
}
}
int findRecord(String path) {
for (int i = 0; i < records.size(); i++) {
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2012 The Processing Foundation
Copyright (c) 2012-15 The Processing Foundation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
@@ -19,7 +19,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
package processing.app.ui;
import java.awt.Component;
import java.awt.Dimension;
@@ -66,6 +66,10 @@ import javax.swing.JPopupMenu;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
import processing.app.Base;
import processing.app.Language;
import processing.app.Preferences;
/**
* Utility functions for base that require a java.awt.Toolkit object. These
@@ -74,6 +78,20 @@ import javax.swing.KeyStroke;
* @author fry
*/
public class Toolkit {
static public final String PROMPT_YES = Language.text("prompt.yes");
static public final String PROMPT_NO = Language.text("prompt.no");
static public final String PROMPT_CANCEL = Language.text("prompt.cancel");
static public final String PROMPT_OK = Language.text("prompt.ok");
static public final String PROMPT_BROWSE = Language.text("prompt.browse");
/**
* Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
* Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
*/
static public int BUTTON_WIDTH =
//Integer.parseInt(Language.text("preferences.button.width"));
Preferences.getInteger("preferences.button.width");
static final java.awt.Toolkit awtToolkit =
java.awt.Toolkit.getDefaultToolkit();
@@ -24,8 +24,8 @@ import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileSystemView;
import processing.app.Editor;
import processing.app.Language;
import processing.app.ui.Editor;
import ch.randelshofer.gui.datatransfer.FileTextFieldTransferHandler;
import ch.randelshofer.media.mp3.MP3AudioInputStream;
import ch.randelshofer.media.quicktime.QuickTimeWriter;
@@ -24,6 +24,7 @@
package processing.mode.java;
import processing.app.*;
import processing.app.ui.Editor;
import processing.core.*;
import java.io.*;
@@ -24,7 +24,6 @@ import org.eclipse.jdt.core.compiler.IProblem;
import processing.core.PApplet;
import processing.data.StringList;
import processing.app.*;
import processing.app.Toolkit;
import processing.app.contrib.AvailableContribution;
import processing.app.contrib.Contribution;
import processing.app.contrib.ContributionListing;
@@ -32,6 +31,14 @@ import processing.app.contrib.ContributionManager;
import processing.app.contrib.ToolContribution;
import processing.app.syntax.JEditTextArea;
import processing.app.syntax.PdeTextAreaDefaults;
import processing.app.ui.About;
import processing.app.ui.ColorChooser;
import processing.app.ui.Editor;
import processing.app.ui.EditorFooter;
import processing.app.ui.EditorHeader;
import processing.app.ui.EditorState;
import processing.app.ui.EditorToolbar;
import processing.app.ui.Toolkit;
import processing.mode.java.debug.LineBreakpoint;
import processing.mode.java.debug.LineHighlight;
import processing.mode.java.debug.LineID;
@@ -24,10 +24,10 @@
package processing.mode.java;
import processing.app.Editor;
import processing.app.Preferences;
import processing.app.Sketch;
import processing.app.syntax.*;
import processing.app.ui.Editor;
import java.awt.*;
import java.awt.event.*;
@@ -32,6 +32,8 @@ import java.util.logging.Logger;
import javax.swing.ImageIcon;
import processing.app.*;
import processing.app.ui.Editor;
import processing.app.ui.EditorState;
import processing.mode.java.runner.Runner;
import processing.mode.java.tweak.SketchParser;
@@ -28,10 +28,10 @@ import java.util.List;
import javax.swing.Box;
import processing.app.Editor;
import processing.app.EditorButton;
import processing.app.EditorToolbar;
import processing.app.Language;
import processing.app.ui.Editor;
import processing.app.ui.EditorButton;
import processing.app.ui.EditorToolbar;
public class JavaToolbar extends EditorToolbar {
@@ -109,8 +109,8 @@ import org.jsoup.select.Elements;
import processing.app.Base;
import processing.app.Library;
import processing.app.SketchCode;
import processing.app.Toolkit;
import processing.app.syntax.JEditTextArea;
import processing.app.ui.Toolkit;
import processing.mode.java.JavaEditor;
import processing.mode.java.JavaMode;
import processing.mode.java.preproc.PdePreprocessor;
@@ -50,11 +50,11 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import processing.app.Base;
import processing.app.Editor;
import processing.app.EditorStatus;
import processing.app.Library;
import processing.app.SketchCode;
import processing.app.syntax.SyntaxDocument;
import processing.app.ui.Editor;
import processing.app.ui.EditorStatus;
import processing.core.PApplet;
import processing.mode.java.JavaMode;
import processing.mode.java.JavaEditor;
@@ -36,11 +36,11 @@ import javax.swing.DefaultListModel;
import javax.swing.SwingWorker;
import processing.app.Base;
import processing.app.Editor;
import processing.app.Mode;
import processing.app.syntax.JEditTextArea;
import processing.app.syntax.PdeTextAreaDefaults;
import processing.app.syntax.TextAreaDefaults;
import processing.app.ui.Editor;
// TODO The way listeners are added/removed here is fragile and
@@ -48,12 +48,12 @@ import javax.swing.text.Segment;
import javax.swing.text.Utilities;
import processing.app.Base;
import processing.app.Editor;
import processing.app.SketchCode;
import processing.app.syntax.SyntaxDocument;
import processing.app.syntax.TextAreaDefaults;
import processing.app.syntax.TextAreaPainter;
import processing.app.syntax.TokenMarker;
import processing.app.ui.Editor;
/**
@@ -24,6 +24,7 @@ package processing.mode.java.runner;
import processing.app.*;
import processing.app.exec.StreamRedirectThread;
import processing.app.ui.Editor;
import processing.core.*;
import processing.mode.java.JavaBuild;