Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Merge remote-tracking branch 'upstream/master'
Conflicts:
	app/src/processing/app/contrib/ContributionPanel.java
	app/src/processing/app/syntax/JEditTextArea.java
	build/macosx/appbundler.jar
	build/macosx/appbundler/native/main.m
	core/src/processing/core/PGraphics.java
	core/todo.txt
	java/src/processing/mode/java/pdex/JavaTextAreaPainter.java
	todo.txt
  • Loading branch information
JayDusara committed Apr 4, 2015
commit 01867133f5485c707ae4527096a10dd2ec580887
273 changes: 166 additions & 107 deletions app/src/processing/app/Mode.java

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions app/src/processing/app/PreferencesFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public PreferencesFrame(Base base) {

button = new JButton(Preferences.PROMPT_BROWSE);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
File dflt = new File(sketchbookLocationField.getText());
PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"),
Expand Down Expand Up @@ -255,6 +256,7 @@ public void removeUpdate(DocumentEvent e) {
final String colorValue = presentColorHex.getText().toUpperCase();
if (colorValue.length() == 7 && (colorValue.startsWith("#")))
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
presentColorHex.setText(colorValue.substring(1));
}
Expand All @@ -267,6 +269,7 @@ public void run() {
colorValue.substring(4, 6), 16)));
if (!colorValue.equals(presentColorHex.getText()))
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
presentColorHex.setText(colorValue);
}
Expand All @@ -279,6 +282,7 @@ public void insertUpdate(DocumentEvent e) {
final String colorValue = presentColorHex.getText().toUpperCase();
if (colorValue.length() == 7 && (colorValue.startsWith("#")))
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
presentColorHex.setText(colorValue.substring(1));
}
Expand All @@ -291,6 +295,7 @@ public void run() {
colorValue.substring(4, 6), 16)));
if (!colorValue.equals(presentColorHex.getText()))
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
presentColorHex.setText(colorValue);
}
Expand Down Expand Up @@ -528,14 +533,17 @@ public void stateChanged(ChangeEvent e) {
label = new JLabel(Preferences.getPreferencesPath());
final JLabel clickable = label;
label.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
Base.openFolder(Base.getSettingsFolder());
}

@Override
public void mouseEntered(MouseEvent e) {
clickable.setForeground(new Color(0, 0, 140));
}

@Override
public void mouseExited(MouseEvent e) {
clickable.setForeground(Color.BLACK);
}
Expand All @@ -559,6 +567,7 @@ public void mouseExited(MouseEvent e) {

button = new JButton(Preferences.PROMPT_OK);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
applyFrame();
disposeFrame();
Expand All @@ -574,6 +583,7 @@ public void actionPerformed(ActionEvent e) {

button = new JButton(Preferences.PROMPT_CANCEL);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
disposeFrame();
}
Expand All @@ -593,12 +603,14 @@ public void actionPerformed(ActionEvent e) {
// closing the window is same as hitting cancel button

dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
disposeFrame();
}
});

ActionListener disposer = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
disposeFrame();
}
Expand All @@ -619,6 +631,7 @@ public void actionPerformed(ActionEvent actionEvent) {
// handle window closing commands for ctrl/cmd-W or hitting ESC.

pain.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
//System.out.println(e);
KeyStroke wc = Toolkit.WINDOW_CLOSE_KEYSTROKE;
Expand Down Expand Up @@ -677,6 +690,7 @@ protected void applyFrame() {
String newPath = sketchbookLocationField.getText();
if (!newPath.equals(oldPath)) {
base.setSketchbookFolder(new File(newPath));
base.getNextMode().rebuildTree();
}

// setBoolean("editor.external", externalEditorBox.isSelected());
Expand Down Expand Up @@ -799,6 +813,7 @@ protected void showFrame() {

// This takes a while to load, so run it from a separate thread
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
initFontList();
}
Expand Down Expand Up @@ -830,6 +845,7 @@ public void run() {
* Oracle staffer, are you reading this? This could be your meal ticket.
*/
static class FontNamer extends JLabel implements ListCellRenderer<Font> {
@Override
public Component getListCellRendererComponent(JList<? extends Font> list,
Font value, int index,
boolean isSelected,
Expand Down
44 changes: 25 additions & 19 deletions app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,26 +328,28 @@ public void handleRenameCode() {
current.getPrettyName() : current.getFileName();
// editor.status.edit(prompt, oldName);
promptForTabName(prompt+":", oldName);
mode.rebuildTree();
}

/**
* Displays a dialog for renaming or creating a new tab
* @param prompt - msg to display
* @param oldName
*/
protected void promptForTabName(String prompt, String oldName) {
final JTextField field = new JTextField(oldName);

field.addKeyListener(new KeyAdapter() {
// Forget ESC, the JDialog should handle it.
// Use keyTyped to catch when the feller is actually added to the text
// field. With keyTyped, as opposed to keyPressed, the keyCode will be
// zero, even if it's enter or backspace or whatever, so the keychar
// Use keyTyped to catch when the feller is actually added to the text
// field. With keyTyped, as opposed to keyPressed, the keyCode will be
// zero, even if it's enter or backspace or whatever, so the keychar
// should be used instead. Grr.
@Override
public void keyTyped(KeyEvent event) {
//System.out.println("got event " + event);
char ch = event.getKeyChar();
if ((ch == '_') || (ch == '.') || // allow.pde and .java
if ((ch == '_') || (ch == '.') || // allow.pde and .java
(('A' <= ch) && (ch <= 'Z')) || (('a' <= ch) && (ch <= 'z'))) {
// These events are allowed straight through.
} else if (ch == ' ') {
Expand All @@ -363,28 +365,28 @@ public void keyTyped(KeyEvent event) {
// getSelectionStart means that it *will be* the first
// char, because the selection is about to be replaced
// with whatever is typed.
if (field.getCaretPosition() == 0 ||
if (field.getCaretPosition() == 0 ||
field.getSelectionStart() == 0) {
// number not allowed as first digit
event.consume();
}
} else if (ch == KeyEvent.VK_ENTER) {
// Slightly ugly hack that ensures OK button of the dialog consumes
// Slightly ugly hack that ensures OK button of the dialog consumes
// the Enter key event. Since the text field is the default component
// in the dialog, OK doesn't consume Enter key event, by default.
Container parent = field.getParent();
while (!(parent instanceof JOptionPane)) {
parent = parent.getParent();
}
JOptionPane pane = (JOptionPane) parent;
final JPanel pnlBottom = (JPanel)
final JPanel pnlBottom = (JPanel)
pane.getComponent(pane.getComponentCount() - 1);
for (int i = 0; i < pnlBottom.getComponents().length; i++) {
Component component = pnlBottom.getComponents()[i];
if (component instanceof JButton) {
final JButton okButton = (JButton) component;
if (okButton.getText().equalsIgnoreCase("OK")) {
ActionListener[] actionListeners =
ActionListener[] actionListeners =
okButton.getActionListeners();
if (actionListeners.length > 0) {
actionListeners[0].actionPerformed(null);
Expand Down Expand Up @@ -621,12 +623,12 @@ public void handleDeleteCode() {
}

// don't allow if untitled
if (currentIndex == 0 && isUntitled()) {
if (currentIndex == 0 && isUntitled()) {
Base.showMessage(Language.text("delete.messages.cannot_delete"),
Language.text("delete.messages.cannot_delete.description"));
return;
}

// confirm deletion with user, yes/no
Object[] options = { Language.text("prompt.ok"), Language.text("prompt.cancel") };
String prompt = (currentIndex == 0) ?
Expand Down Expand Up @@ -798,7 +800,7 @@ public boolean save() throws IOException {
protected boolean saveAs() throws IOException {
String newParentDir = null;
String newName = null;

final String oldName2 = folder.getName();
// TODO rewrite this to use shared version from PApplet
final String PROMPT = Language.text("save");
Expand Down Expand Up @@ -908,6 +910,7 @@ protected boolean saveAs() throws IOException {
}

File[] copyItems = folder.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
String name = file.getName();
// just in case the OS likes to return these as if they're legit
Expand All @@ -934,21 +937,22 @@ public boolean accept(File file) {
return true;
}
});


final File newFolder2 = newFolder;
final File[] copyItems2 = copyItems;
final String newName2 = newName;
final String newName2 = newName;

// Create a new event dispatch thread- to display ProgressBar
// while Saving As
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new ProgressFrame(copyItems2, newFolder2, oldName2, newName2, editor);
}
});


// save the other tabs to their new location
for (int i = 1; i < codeCount; i++) {
File newFile = new File(newFolder, code[i].getFileName());
Expand All @@ -967,6 +971,7 @@ public void run() {
code[0].saveAs(newFile);

updateInternal(newName, newFolder);
mode.updateTree(newName, newFolder);

// Make sure that it's not an untitled sketch
setUntitled(false);
Expand All @@ -985,7 +990,7 @@ public void run() {
*/
protected void updateInternal(String sketchName, File sketchFolder) {
// reset all the state information for the sketch object
String oldPath = getMainFilePath();
String oldPath = getMainFilePath();
primaryFile = code[0].getFile();
// String newPath = getMainFilePath();
// editor.base.renameRecent(oldPath, newPath);
Expand Down Expand Up @@ -1145,6 +1150,7 @@ public boolean addFile(File sourceFile) {
// Create a new event dispatch thread- to display ProgressBar
// while Saving As
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new ProgressFrame(sourceFile2, destFile2, editor);
}
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.