mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
clean up handling of untitled sketches
This commit is contained in:
@@ -656,8 +656,9 @@ public class Base {
|
||||
"Please save the sketch before changing the mode.",
|
||||
null);
|
||||
} else {
|
||||
boolean untitled = activeEditor.untitled;
|
||||
// boolean untitled = activeEditor.untitled;
|
||||
String mainPath = sketch.getMainFilePath();
|
||||
boolean wasUntitled = sketch.isUntitled();
|
||||
|
||||
// save a mode file into this sketch folder
|
||||
File sketchProps = new File(sketch.getFolder(), "sketch.properties");
|
||||
@@ -684,7 +685,8 @@ public class Base {
|
||||
handleClose(activeEditor, true);
|
||||
|
||||
// re-open the sketch
|
||||
/*Editor editor =*/ handleOpen(mainPath, untitled, state);
|
||||
// /*Editor editor =*/ handleOpen(mainPath, untitled, state);
|
||||
/*Editor editor =*/ handleOpen(mainPath, wasUntitled, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1030,7 +1032,8 @@ public class Base {
|
||||
return null; // Just walk away quietly
|
||||
}
|
||||
|
||||
editor.untitled = untitled;
|
||||
// editor.untitled = untitled;
|
||||
editor.getSketch().setUntitled(untitled);
|
||||
editors.add(editor);
|
||||
handleRecent(editor);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-11 Ben Fry and Casey Reas
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -58,7 +58,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
/**
|
||||
* true if this file has not yet been given a name by the user
|
||||
*/
|
||||
protected boolean untitled;
|
||||
// private boolean untitled;
|
||||
|
||||
private PageFormat pageFormat;
|
||||
private PrinterJob printerJob;
|
||||
@@ -2043,9 +2043,9 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
return false;
|
||||
}
|
||||
header.rebuild();
|
||||
setTitle();
|
||||
updateTitle();
|
||||
// Disable untitled setting from previous document, if any
|
||||
untitled = false;
|
||||
// untitled = false;
|
||||
|
||||
// Store information on who's open and running
|
||||
// (in case there's a crash or something that can't be recovered)
|
||||
@@ -2067,12 +2067,17 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
* Set the title of the PDE window based on the current sketch, i.e.
|
||||
* something like "sketch_070752a - Processing 0126"
|
||||
*/
|
||||
public void setTitle() {
|
||||
public void updateTitle() {
|
||||
setTitle(sketch.getName() + " | Processing " + Base.VERSION_NAME);
|
||||
|
||||
// set current file for OS X
|
||||
File sketchFile = sketch.getMainFile();
|
||||
getRootPane().putClientProperty("Window.documentFile", sketchFile);
|
||||
if (!sketch.isUntitled()) {
|
||||
// set current file for OS X so that cmd-click in title bar works
|
||||
File sketchFile = sketch.getMainFile();
|
||||
getRootPane().putClientProperty("Window.documentFile", sketchFile);
|
||||
} else {
|
||||
// per other applications, don't set this until the file has been saved
|
||||
getRootPane().putClientProperty("Window.documentFile", null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2088,7 +2093,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
public boolean handleSave(boolean immediately) {
|
||||
// handleStop(); // 0136
|
||||
|
||||
if (untitled) {
|
||||
if (sketch.isUntitled()) {
|
||||
return handleSaveAs();
|
||||
// need to get the name, user might also cancel here
|
||||
|
||||
|
||||
@@ -70,6 +70,9 @@ public class Sketch {
|
||||
*/
|
||||
private int codeCount;
|
||||
private SketchCode[] code;
|
||||
|
||||
/** Moved out of Editor and into here for cleaner access. */
|
||||
private boolean untitled;
|
||||
|
||||
// /** Class path determined during build. */
|
||||
// private String classPath;
|
||||
@@ -294,7 +297,7 @@ public class Sketch {
|
||||
// make sure the user didn't hide the sketch folder
|
||||
ensureExistence();
|
||||
|
||||
if (currentIndex == 0 && editor.untitled) {
|
||||
if (currentIndex == 0 && isUntitled()) {
|
||||
Base.showMessage("Sketch is Untitled",
|
||||
"How about saving the sketch first \n" +
|
||||
"before trying to rename it?");
|
||||
@@ -899,7 +902,7 @@ public class Sketch {
|
||||
// Name changed, rebuild the sketch menus
|
||||
calcModified();
|
||||
// System.out.println("modified is now " + modified);
|
||||
editor.setTitle();
|
||||
editor.updateTitle();
|
||||
editor.base.rebuildSketchbookMenus();
|
||||
// editor.header.rebuild();
|
||||
}
|
||||
@@ -1058,13 +1061,13 @@ public class Sketch {
|
||||
}
|
||||
setCurrentCode(filename);
|
||||
editor.header.repaint();
|
||||
if (editor.untitled) { // TODO probably not necessary? problematic?
|
||||
if (isUntitled()) { // TODO probably not necessary? problematic?
|
||||
// Mark the new code as modified so that the sketch is saved
|
||||
current.setModified(true);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (editor.untitled) { // TODO probably not necessary? problematic?
|
||||
if (isUntitled()) { // TODO probably not necessary? problematic?
|
||||
// If a file has been added, mark the main code as modified so
|
||||
// that the sketch is properly saved.
|
||||
code[0].setModified(true);
|
||||
@@ -1390,13 +1393,16 @@ public class Sketch {
|
||||
}
|
||||
|
||||
|
||||
public void setUntitled(boolean u) {
|
||||
editor.untitled = u;
|
||||
public void setUntitled(boolean untitled) {
|
||||
// editor.untitled = u;
|
||||
this.untitled = untitled;
|
||||
editor.updateTitle();
|
||||
}
|
||||
|
||||
|
||||
public boolean isUntitled() {
|
||||
return editor.untitled;
|
||||
// return editor.untitled;
|
||||
return untitled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -530,7 +530,7 @@ public class JavaScriptEditor extends ServingEditor
|
||||
*/
|
||||
public boolean handleSave ( boolean immediately )
|
||||
{
|
||||
if (untitled)
|
||||
if (sketch.isUntitled())
|
||||
{
|
||||
return handleSaveAs();
|
||||
}
|
||||
|
||||
+1
-1
@@ -384,7 +384,7 @@
|
||||
<target name="macosx-run" depends="macosx-build"
|
||||
description="Run Mac OS X version">
|
||||
<exec executable="Processing.app/Contents/MacOS/JavaApplicationStub"
|
||||
dir="macosx/work" spawn="true"/>
|
||||
dir="macosx/work" spawn="false"/>
|
||||
</target>
|
||||
|
||||
<target name="macosx-dist-sign" if="codesign">
|
||||
|
||||
@@ -5,6 +5,9 @@ X make Mode menu into a radio button, so it cannot be de-selected
|
||||
X http://code.google.com/p/processing/issues/detail?id=1227
|
||||
X no response with registerMethod keyEvent when key pressed or released
|
||||
X http://code.google.com/p/processing/issues/detail?id=1225
|
||||
o running at size(7000, 4000) followed by size(100, 100)
|
||||
X http://code.google.com/p/processing/issues/detail?id=1213
|
||||
X won't fix, too hairy and messy
|
||||
|
||||
_ changing the default display does not reset editor location
|
||||
_ so the change appears to have no effect
|
||||
@@ -16,9 +19,6 @@ X to apply to all open editors, not just the first
|
||||
_ "Processing is damaged and should be put in the trash" for 2.0b2
|
||||
_ http://code.google.com/p/processing/issues/detail?id=1226
|
||||
|
||||
_ running at size(7000, 4000) followed by size(100, 100)
|
||||
_ http://code.google.com/p/processing/issues/detail?id=1213
|
||||
|
||||
. . .
|
||||
|
||||
_ try to use appbundler to create a version that includes a JRE (JDK)
|
||||
|
||||
Reference in New Issue
Block a user