mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 18:10:43 +01:00
pure madness
This commit is contained in:
@@ -103,8 +103,7 @@ public class PdeEditor extends JPanel {
|
||||
String externalPaths;
|
||||
File externalCode;
|
||||
|
||||
static final int GRID_SIZE = 33;
|
||||
static final int INSET_SIZE = 5;
|
||||
//static final int INSET_SIZE = 5;
|
||||
|
||||
boolean running;
|
||||
boolean presenting;
|
||||
@@ -690,12 +689,12 @@ public class PdeEditor extends JPanel {
|
||||
|
||||
String dataPath = sketchFile.getParent() + File.separator + "data";
|
||||
|
||||
if (dataPath != null) {
|
||||
File dataDir = new File(dataPath);
|
||||
if (dataDir.exists()) {
|
||||
PdeEditor.copyDir(dataDir, buildDir);
|
||||
}
|
||||
//if (dataPath != null) {
|
||||
File dataDir = new File(dataPath);
|
||||
if (dataDir.exists()) {
|
||||
PdeEditor.copyDir(dataDir, buildDir);
|
||||
}
|
||||
//}
|
||||
int numero1 = (int) (Math.random() * 10000);
|
||||
int numero2 = (int) (Math.random() * 10000);
|
||||
String className = TEMP_CLASS + "_" + numero1 + "_" + numero2;
|
||||
@@ -991,26 +990,39 @@ public class PdeEditor extends JPanel {
|
||||
// does all the plumbing to create a new project
|
||||
// then calls handleOpen to load it up
|
||||
|
||||
//File sketchbookDir = new File("sketchbook", userName);
|
||||
File sketchbookDir = PdePreferences.get("sketchbook.path");
|
||||
File sketchDir = null;
|
||||
String sketchName = null;
|
||||
|
||||
int index = 0;
|
||||
//Calendar now = Calendar.getInstance();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd");
|
||||
String purty = formatter.format(new Date());
|
||||
do {
|
||||
sketchName = "sketch_" + purty + ((char) ('a' + index));
|
||||
//int index = (int) (Math.random() * 1000);
|
||||
//sketchName = "sketch_" + pad3(index);
|
||||
sketchDir = new File(sketchbookDir, sketchName);
|
||||
index++;
|
||||
} while (sketchDir.exists());
|
||||
if (PdePreferences.getBoolean("sketchbook.prompt")) {
|
||||
FileDialog fd = new FileDialog(new Frame(),
|
||||
"Save new sketch as:",
|
||||
FileDialog.SAVE);
|
||||
fd.setDirectory(PdePreferences.get("sketchbook.location"));
|
||||
fd.show();
|
||||
|
||||
String sketchParentDir = fd.getDirectory();
|
||||
sketchName = fd.getFile();
|
||||
if (sketchName == null) return;
|
||||
|
||||
sketchDir = new File(sketchParentDir, sketchName);
|
||||
|
||||
} else {
|
||||
String sketchParentDir = PdePreferences.get("sketchbook.location");
|
||||
|
||||
int index = 0;
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd");
|
||||
String purty = formatter.format(new Date());
|
||||
do {
|
||||
sketchName = "sketch_" + purty + ((char) ('a' + index));
|
||||
sketchDir = new File(sketchParentDir, sketchName);
|
||||
index++;
|
||||
} while (sketchDir.exists());
|
||||
}
|
||||
|
||||
// mkdir for new project name
|
||||
sketchDir.mkdirs();
|
||||
new File(sketchDir, "data").mkdirs();
|
||||
|
||||
//new File(sketchDir, "data").mkdirs();
|
||||
|
||||
// make empty pde file
|
||||
File sketchFile = new File(sketchDir, sketchName + ".pde");
|
||||
@@ -1064,6 +1076,8 @@ public class PdeEditor extends JPanel {
|
||||
}
|
||||
|
||||
protected void doOpen2() {
|
||||
// at least set the default dir here to the sketchbook folder
|
||||
|
||||
FileDialog fd = new FileDialog(new Frame(),
|
||||
"Open a PDE program...",
|
||||
FileDialog.LOAD);
|
||||
@@ -1287,6 +1301,7 @@ public class PdeEditor extends JPanel {
|
||||
handleExport(appletDir, sketchName, new File(sketchDir, "data"));
|
||||
}
|
||||
|
||||
/*
|
||||
public void doExport() {
|
||||
message("Exporting for the web...");
|
||||
String s = textarea.getText();
|
||||
@@ -1315,6 +1330,7 @@ public class PdeEditor extends JPanel {
|
||||
}
|
||||
handleExport(new File(directory), project, null);
|
||||
}
|
||||
*/
|
||||
|
||||
protected void handleExport(File appletDir, String exportSketchName,
|
||||
File dataDir) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.zip.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.filechooser.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.undo.*;
|
||||
|
||||
@@ -68,6 +69,7 @@ public class PdePreferences extends JComponent {
|
||||
static final String PROMPT_NO = "No";
|
||||
static final String PROMPT_CANCEL = "Cancel";
|
||||
static final String PROMPT_OK = "OK";
|
||||
static final String PROMPT_BROWSE = "Browse";
|
||||
|
||||
// mac needs it to be 70, windows needs 66, linux needs 76
|
||||
|
||||
@@ -195,11 +197,11 @@ public class PdePreferences extends JComponent {
|
||||
|
||||
// [ ] Prompt for name and folder when creating new sketch
|
||||
|
||||
newSketchPromptBox =
|
||||
new JCheckBox("Prompt for name when creating a new sketch");
|
||||
pain.add(newSketchPromptBox);
|
||||
d = newSketchPromptBox.getPreferredSize();
|
||||
newSketchPromptBox.setBounds(left, top, d.width, d.height);
|
||||
sketchPromptBox =
|
||||
new JCheckBox("Prompt for name when opening or creating a sketch");
|
||||
pain.add(sketchPromptBox);
|
||||
d = sketchPromptBox.getPreferredSize();
|
||||
sketchPromptBox.setBounds(left, top, d.width, d.height);
|
||||
right = Math.max(right, left + d.width);
|
||||
top += d.height + BETWEEN;
|
||||
|
||||
@@ -214,7 +216,25 @@ public class PdePreferences extends JComponent {
|
||||
pain.add(sketchbookLocationField);
|
||||
d2 = sketchbookLocationField.getPreferredSize();
|
||||
|
||||
button = new JButton("Browse");
|
||||
button = new JButton(PROMPT_BROWSE);
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFile(sketchbookLocationField.getText());
|
||||
fc.setFileSectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
|
||||
int returned = fc.showOpenDialog(new JDialog());
|
||||
if (returned == JFileChooser.APPROVE_OPTION) {
|
||||
try {
|
||||
File file = fc.getSelectedFile();
|
||||
sketchbookLocationField.setText(file.getCanonicalPath());
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
pain.add(button);
|
||||
d3 = button.getPreferredSize();
|
||||
|
||||
@@ -360,11 +380,11 @@ public class PdePreferences extends JComponent {
|
||||
public void showFrame() {
|
||||
// reset all settings to their actual status
|
||||
|
||||
newSketchPromptBox.setSelected(getBoolean("sketchbook.prompt"));
|
||||
sketchPromptBox.setSelected(getBoolean("sketchbook.prompt"));
|
||||
|
||||
sketchbookLocation.setText(get("sketchbook.path"));
|
||||
|
||||
newSketchPromptBox.setSelected(getBoolean("editor.external"));
|
||||
externalEditorBox.setSelected(getBoolean("editor.external"));
|
||||
|
||||
frame.show();
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ run.present.bgcolor = #666666
|
||||
# prompt for sketch location when 'new' is hit
|
||||
sketchbook.prompt = false
|
||||
|
||||
#sketchbook.path = sketchbook
|
||||
#sketchbook.location = sketchbook
|
||||
# note that this path should use forward slashes (like unix)
|
||||
# instead of \ on windows or : on windows or whatever else
|
||||
|
||||
|
||||
Reference in New Issue
Block a user