Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
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
49 changes: 47 additions & 2 deletions 49 app/src/processing/app/Mode.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
public abstract class Mode {
protected Base base;

protected DefaultTreeModel model;

protected File folder;

protected TokenMarker tokenMarker;
Expand Down Expand Up @@ -1053,6 +1055,40 @@ public DefaultMutableTreeNode buildSketchbookTree(){

protected JFrame sketchbookFrame;

/*
* Function for rebuilding the tree in case user presses SPACE or the
* sketchbook folder is changed in preferences. Also This helps if a sketch is
* deleted not by means of processing application window but externally.
*/
public void rebuildTree() {
if (model != null) {
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
root.removeAllChildren();
try {
base.addSketches(root, Base.getSketchbookFolder());
model.reload(root);
} catch (IOException e) {
e.printStackTrace();
}
}
}

/*
* Function Called to add a sketch in the tree in case the sketch is saved
* Called from updateInernal in Base.java
*/
public void updateTree(String sketchName, File sketchFolder) {
File f = new File(sketchFolder.getAbsolutePath() + "\\" + sketchName
+ ".pde");
if (model != null) {
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
SketchReference reference = new SketchReference(sketchName, f);
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(reference);
root.add(newNode);
model.reload(root);
}
}

public void showSketchbookFrame() {
if (sketchbookFrame == null) {
sketchbookFrame = new JFrame(Language.text("sketchbook"));
Expand All @@ -1064,7 +1100,10 @@ public void actionPerformed(ActionEvent e) {
}
});

final JTree tree = new JTree(buildSketchbookTree());
sketchbookFrame.getContentPane().setLayout(new BorderLayout());
DefaultMutableTreeNode root = buildSketchbookTree();
model = new DefaultTreeModel(root);
final JTree tree = new JTree(model);
tree.getSelectionModel()
.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setShowsRootHandles(true);
Expand Down Expand Up @@ -1104,6 +1143,10 @@ public void keyTyped(KeyEvent e) {
base.handleOpen(sketch.getPath());
}
}

if (e.getKeyChar() == KeyEvent.VK_SPACE) {
rebuildTree();
}
}
});

Expand All @@ -1116,7 +1159,9 @@ public void keyTyped(KeyEvent e) {
JScrollPane treePane = new JScrollPane(tree);
treePane.setPreferredSize(new Dimension(250, 450));
treePane.setBorder(new EmptyBorder(0, 0, 0, 0));
sketchbookFrame.getContentPane().add(treePane);
JLabel refreshLabel = new JLabel("Press SPACE to refresh");
sketchbookFrame.getContentPane().add(refreshLabel, BorderLayout.SOUTH);
sketchbookFrame.getContentPane().add(treePane, BorderLayout.CENTER);
sketchbookFrame.pack();
}

Expand Down
1 change: 1 addition & 0 deletions 1 app/src/processing/app/PreferencesFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,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
40 changes: 21 additions & 19 deletions 40 app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,26 +328,27 @@ 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.
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 +364,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 +622,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 +799,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 @@ -934,21 +935,21 @@ 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() {
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 +968,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 +987,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
Binary file modified BIN +281 KB (300%) build/macosx/appbundler.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions 10 build/shared/lib/defaults.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,22 @@ editor.untitled.suffix=yyMMdd
# GTK isn't for everyone (and KDE users will get Metal or some
# such anyway, so this is now broken out as an option
# Linux is by default even uglier than metal (Motif?).
<<<<<<< HEAD
# Actually, i'm using native menus, so they're even uglier
# and Motif-looking (Lesstif?). Ick. Need to fix this.
# For 0120, trying out the gtk+ look and feel as the default.
# This is available in Java 1.4.2 and later, and it can't possibly
# be any worse than Metal. (Ocean might also work, but that's for
# Java 1.5, and we aren't going there yet)
editor.laf.linux = com.sun.java.swing.plaf.gtk.GTKLookAndFeel
=======
#editor.laf.linux = com.sun.java.swing.plaf.gtk.GTKLookAndFeel
# Trying Nimbus in 3.0a6 because the GTK menus are really dreadful.
# Unfortunately, the Nimbus scrollbars are really gross, but...
# As always, people can override on their own, or the next step
# is to do a Synth LAF that gives us something not awful.
editor.laf.linux = javax.swing.plaf.nimbus.NimbusLookAndFeel
>>>>>>> refs/remotes/upstream/master


# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
4 changes: 4 additions & 0 deletions 4 build/shared/lib/languages/PDE_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ preferences.hide_toolbar_background_image = Hintergrundgrafik der Toolbar ausble
preferences.check_for_updates_on_startup = Prüfung auf Updates bei Programmstart
preferences.run_sketches_on_display = Starte Sketch auf Bildschirm
preferences.run_sketches_on_display.tip = \
<<<<<<< HEAD
Bestimme den Bildschirm auf dem der Sketch dargestellt werden soll.
=======
Bestimme den Bildschirm auf dem der Sketch dargestellt werden soll.\
>>>>>>> refs/remotes/upstream/master
Wenn das Fenster des Sketches auf einen anderen Bildschirm geschoben<br>\
wird, so wird der Sketch an selber Stelle wieder geöffnet. Dabei ist es<br>\
egal, ob der Sketch im Present-Modus (Fullscreen) geöffnet wird.
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.