Date: Fri, 19 Jul 2013 12:50:23 -0700
Subject: [PATCH 079/400] notes and doc changes
---
app/src/processing/app/Preferences.java | 17 +++--
app/src/processing/app/Sketch.java | 2 +-
todo.txt | 88 ++++++++++++++-----------
3 files changed, 57 insertions(+), 50 deletions(-)
diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java
index a73a31606..a6686b342 100644
--- a/app/src/processing/app/Preferences.java
+++ b/app/src/processing/app/Preferences.java
@@ -50,15 +50,14 @@ import processing.core.*;
* being lectured by strangers who feel that it doesn't look like what they
* learned in CS class.
*
- * Would also be possible to change this to use the Java Preferences API.
- * Some useful articles
- * here and
- * here.
- * However, haven't implemented this yet for lack of time, but more
- * importantly, because it would entail writing to the registry (on Windows),
- * or an obscure file location (on Mac OS X) and make it far more difficult to
- * find the preferences to tweak them by hand (no! stay out of regedit!)
- * or to reset the preferences by simply deleting the preferences.txt file.
+ * We don't use the Java Preferences API because it would entail writing to
+ * the registry (on Windows), or an obscure file location (on Mac OS X) and
+ * make it far more difficult (impossible) to remove the preferences.txt to
+ * reset them (when they become corrupt), or to find the the file to make
+ * edits for numerous obscure preferences that are not part of the preferences
+ * window. If we added a generic editor (e.g. about:config in Mozilla) for
+ * such things, we could start using the Java Preferences API. But wow, that
+ * sounds like a lot of work. Not unlike writing this paragraph.
*/
public class Preferences {
diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java
index 57fa3fb15..525e85aec 100644
--- a/app/src/processing/app/Sketch.java
+++ b/app/src/processing/app/Sketch.java
@@ -32,7 +32,7 @@ import javax.swing.*;
/**
- * Stores information about files in the current sketch
+ * Stores information about files in the current sketch.
*/
public class Sketch {
private Editor editor;
diff --git a/todo.txt b/todo.txt
index caaa6a41f..c25fa95d8 100644
--- a/todo.txt
+++ b/todo.txt
@@ -12,10 +12,55 @@ o b86 supposed to have some support (not available yet)
o http://jdk8.java.net/download.html
X code with a NUL character causes an error
X https://github.com/processing/processing/issues/1973
+X Add "Processing Foundation" to the Help menu
+X https://github.com/processing/processing/issues/1908
-_ check to see if manager items from the download can be updated
-_ oops, probably not, because they're part of the distribution
-_ and folks won't be able to write to those directories
+cleaning/earlier
+X common error messages
+X with a proper list, we can add links when throwing an error in the PDE
+X Dan started this on the Wiki
+
+manager
+X check to see if manager items from the download can be updated
+X oops, probably not, because they're part of the distribution
+X and folks won't be able to write to those directories
+_ libraries need to support multiple categories
+_ https://github.com/processing/processing/issues/1970
+_ send info on 'check for updates' so we know about libs/modes/etc?
+_ how to disclose to users?
+_ only send for items that are part of the public list
+_ otherwise we're sending private libraries/installs
+_ although this won't pick up old libraries not on the new system
+_ half-installed mode causes a lot of trouble
+_ https://github.com/processing/processing/issues/1875
+_ mode install requires restart *and* still doesn't show as installed
+_ even though it gets added to the modes menu properly after the restart
+_ https://github.com/processing/processing/issues/1782
+_ classpath conflicts..
+_ really need to make sure that a weird core.jar isn't being imported
+_ coffeescript was doing this and breaking the pde
+_ init() not called on tools until later
+_ https://github.com/processing/processing/issues/1859
+
+high
+_ Present Mode trouble on Windows 7 (64-bit) completely broken
+_ https://github.com/processing/processing/issues/1955
+_ move old Google Code SVN back to processing.org
+_ then cull out the old branches/tags from the Github repo
+_ UnsatisfiedLinkError causes huge message...
+_ error report cleanups haven't been fixed yet
+_ reported by Dan
+_ proxy server requirement causes problems
+_ contrib manager, update checks are broken
+_ https://github.com/processing/processing/issues/1476
+_ might be able to fix this with something in preferences.txt?
+_ figure out Android build w/o javac so we can remove tools.jar and javac
+_ also to the p5 repo with just a JRE
+_ remove initRequirements from Base (no longer need JDI)
+_ move this into Android mode?
+
+_ "String index out of range" error
+_ https://github.com/processing/processing/issues/1940
_ appbundler fixes/changes
_ icon location uses path, even when embedded
@@ -31,41 +76,6 @@ _ appears to be line 138 of main.m
_ maybe this is a holdover from OS X Java?
_ bring back the splash screen?
-high
-_ libraries need to support multiple categories
-_ https://github.com/processing/processing/issues/1970
-_ Present Mode trouble on Windows 7 (64-bit) completely broken
-_ https://github.com/processing/processing/issues/1955
-_ Add "Processing Foundation" to the Help menu
-_ https://github.com/processing/processing/issues/1908
-_ move old Google Code SVN back to processing.org
-_ then cull out the old branches/tags from the Github repo
-_ UnsatisfiedLinkError causes huge message...
-_ error report cleanups haven't been fixed yet
-_ reported by Dan
-_ proxy server requirement causes problems
-_ contrib manager, update checks are broken
-_ https://github.com/processing/processing/issues/1476
-_ send info on 'check for updates' so we know about libs/modes/etc?
-_ how to disclose to users?
-_ only send for items that are part of the public list
-_ otherwise we're sending private libraries/installs
-_ although this won't pick up old libraries not on the new system
-_ figure out Android build w/o javac so we can remove tools.jar and javac
-_ also to the p5 repo with just a JRE
-_ remove initRequirements from Base (no longer need JDI)
-_ move this into Android mode?
-_ half-installed mode causes a lot of trouble
-_ https://github.com/processing/processing/issues/1875
-_ mode install requires restart *and* still doesn't show as installed
-_ even though it gets added to the modes menu properly after the restart
-_ https://github.com/processing/processing/issues/1782
-_ classpath conflicts..
-_ really need to make sure that a weird core.jar isn't being imported
-_ coffeescript was doing this and breaking the pde
-_ init() not called on tools until later
-_ https://github.com/processing/processing/issues/1859
-
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -94,8 +104,6 @@ _ go through examples, figure out how to do many on the site w/ js instead
DOC / Write Me
-_ common error messages
-_ with a proper list, we can add links when throwing an error in the PDE
_ stop() to shut down a sketch (but not quit/close window)
_ actually pause/resume
_ MIN_FLOAT, MAX_FLOAT, also the difference from the Java functions
From 133444416fc3e45dca77e0cfd4db789aa648f721 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Fri, 19 Jul 2013 17:40:17 -0400
Subject: [PATCH 080/400] hopefully fix Present mode (#1955), plus minor build
tweaks
---
build/build.xml | 8 ++++++++
core/src/processing/core/PApplet.java | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
mode change 100644 => 100755 core/src/processing/core/PApplet.java
diff --git a/build/build.xml b/build/build.xml
index 6f5b7707f..d03b83816 100755
--- a/build/build.xml
+++ b/build/build.xml
@@ -607,8 +607,10 @@
+
+
diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java
old mode 100644
new mode 100755
index 00d2e49dd..c8de9b75b
--- a/core/src/processing/core/PApplet.java
+++ b/core/src/processing/core/PApplet.java
@@ -54,6 +54,7 @@ import java.util.regex.*;
import java.util.zip.*;
import javax.imageio.ImageIO;
+import javax.swing.JFrame;
import javax.swing.JFileChooser;
@@ -10378,7 +10379,10 @@ public class PApplet extends Applet
displayDevice = environment.getDefaultScreenDevice();
}
- Frame frame = new Frame(displayDevice.getDefaultConfiguration());
+ // Using a JFrame fixes a Windows problem with Present mode.
+ // This might be our error, but usually this is the sort of crap
+ // we usually get from OS X.
+ Frame frame = new JFrame(displayDevice.getDefaultConfiguration());
frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); // default Processing gray
// JFrame frame = new JFrame(displayDevice.getDefaultConfiguration());
/*
@@ -10499,6 +10503,9 @@ public class PApplet extends Applet
// japplemenubar.JAppleMenuBar.hide();
// }
+ // Tried to use this to fix the 'present' mode issue.
+ // Did not help, and the screenRect setup seems to work fine.
+ //frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setUndecorated(true);
if (backgroundColor != null) {
frame.setBackground(backgroundColor);
@@ -10520,6 +10527,7 @@ public class PApplet extends Applet
} else {
frame.pack();
}
+
// insufficient, places the 100x100 sketches offset strangely
//frame.validate();
From 1dd515138307b4b165e975f1653f00ce79f0eda6 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Fri, 19 Jul 2013 14:46:28 -0700
Subject: [PATCH 081/400] more notes regarding #1955
---
core/src/processing/core/PApplet.java | 30 +++++++++------------------
core/todo.txt | 2 ++
todo.txt | 2 --
3 files changed, 12 insertions(+), 22 deletions(-)
diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java
index c8de9b75b..4211a1c83 100755
--- a/core/src/processing/core/PApplet.java
+++ b/core/src/processing/core/PApplet.java
@@ -10379,33 +10379,23 @@ public class PApplet extends Applet
displayDevice = environment.getDefaultScreenDevice();
}
- // Using a JFrame fixes a Windows problem with Present mode.
- // This might be our error, but usually this is the sort of crap
- // we usually get from OS X.
+ // Using a JFrame fixes a Windows problem with Present mode. This might
+ // be our error, but usually this is the sort of crap we usually get from
+ // OS X. It's time for a turnaround: Redmond is thinking different too!
+ // https://github.com/processing/processing/issues/1955
Frame frame = new JFrame(displayDevice.getDefaultConfiguration());
- frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); // default Processing gray
-// JFrame frame = new JFrame(displayDevice.getDefaultConfiguration());
- /*
- Frame frame = null;
- if (displayDevice != null) {
- frame = new Frame(displayDevice.getDefaultConfiguration());
- } else {
- frame = new Frame();
- }
- */
- //Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
-
- // remove the grow box by default
- // users who want it back can call frame.setResizable(true)
-// frame.setResizable(false);
- // moved later (issue #467)
+ // Default Processing gray, which will be replaced below if another
+ // color is specified on the command line (i.e. in the prefs).
+ frame.setBackground(new Color(0xCC, 0xCC, 0xCC));
+ // Cannot call setResizable(false) until later due to OS X (issue #467)
final PApplet applet;
if (constructedApplet != null) {
applet = constructedApplet;
} else {
try {
- Class> c = Thread.currentThread().getContextClassLoader().loadClass(name);
+ Class> c =
+ Thread.currentThread().getContextClassLoader().loadClass(name);
applet = (PApplet) c.newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
diff --git a/core/todo.txt b/core/todo.txt
index f0307606c..a0f15a529 100644
--- a/core/todo.txt
+++ b/core/todo.txt
@@ -11,6 +11,8 @@ X https://github.com/processing/processing/issues/1959
X turns out this is an apple.awt tweak for the exported Info.plist
X getSubset() broken in IntList, StringList, and missing from FloatList
X https://github.com/processing/processing/issues/1979
+X Present Mode trouble on Windows 7 (64-bit) completely broken
+X https://github.com/processing/processing/issues/1955
_ retain blendMode() between frames (get bug #)
diff --git a/todo.txt b/todo.txt
index c25fa95d8..49d968ace 100644
--- a/todo.txt
+++ b/todo.txt
@@ -43,8 +43,6 @@ _ init() not called on tools until later
_ https://github.com/processing/processing/issues/1859
high
-_ Present Mode trouble on Windows 7 (64-bit) completely broken
-_ https://github.com/processing/processing/issues/1955
_ move old Google Code SVN back to processing.org
_ then cull out the old branches/tags from the Github repo
_ UnsatisfiedLinkError causes huge message...
From fdfddd616e66533929fedd3f3961a78948129c93 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sat, 20 Jul 2013 18:57:05 -0400
Subject: [PATCH 082/400] working on platform classes, adding move to trash
option
---
app/src/processing/app/Platform.java | 18 ++++++++++++++++++
app/src/processing/app/macosx/Platform.java | 14 ++++++++++++--
app/src/processing/app/windows/Registry.java | 9 ---------
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/app/src/processing/app/Platform.java b/app/src/processing/app/Platform.java
index 2cf380e66..8c71b3416 100644
--- a/app/src/processing/app/Platform.java
+++ b/app/src/processing/app/Platform.java
@@ -24,6 +24,7 @@ package processing.app;
import java.awt.Desktop;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import javax.swing.UIManager;
@@ -142,6 +143,23 @@ public class Platform {
}
*/
}
+
+
+ /**
+ * Attempts to move to the Trash on OS X, or the Recycle Bin on Windows.
+ * If not possible, just deletes the file or folder instead.
+ * @param file the folder or file to be removed/deleted
+ * @return true if the folder was successfully removed
+ * @throws IOException
+ */
+ public boolean deleteFile(File file) throws IOException {
+ if (file.isDirectory()) {
+ Base.removeDir(file);
+ } else {
+ return file.delete();
+ }
+ return true;
+ }
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
diff --git a/app/src/processing/app/macosx/Platform.java b/app/src/processing/app/macosx/Platform.java
index 406e65987..8cc71a38d 100644
--- a/app/src/processing/app/macosx/Platform.java
+++ b/app/src/processing/app/macosx/Platform.java
@@ -24,6 +24,7 @@ package processing.app.macosx;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.IOException;
import com.apple.eio.FileManager;
@@ -79,8 +80,8 @@ public class Platform extends processing.app.Platform {
}
*/
}
-
-
+
+
public File getSettingsFolder() throws Exception {
return new File(getLibraryFolder(), "Processing");
}
@@ -101,6 +102,15 @@ public class Platform extends processing.app.Platform {
}
*/
}
+
+
+ /**
+ * Moves the specified File object (which might be a file or folder)
+ * to the trash.
+ */
+ public boolean deleteFile(File file) throws IOException {
+ return FileManager.moveToTrash(file);
+ }
/*
diff --git a/app/src/processing/app/windows/Registry.java b/app/src/processing/app/windows/Registry.java
index 06d0e0ed5..dcb719ef8 100644
--- a/app/src/processing/app/windows/Registry.java
+++ b/app/src/processing/app/windows/Registry.java
@@ -21,15 +21,6 @@ public class Registry {
rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WINREG.HKEY_USERS);
}
- /**
- * Testing.
- *
- * @param args arguments
- * @throws java.lang.Exception on error
- */
- public static void main(String[] args) throws Exception {
- }
-
/**
* Gets one of the root keys.
*
From 8201e2b83919668a1d3a61dc17b4b142461cd451 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sat, 20 Jul 2013 21:55:58 -0400
Subject: [PATCH 083/400] report exception even if a clearer version is
available
---
.../processing/mode/java/runner/Runner.java | 26 ++++++++++++++-----
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/app/src/processing/mode/java/runner/Runner.java b/app/src/processing/mode/java/runner/Runner.java
index 76d182afb..c7a0599ff 100644
--- a/app/src/processing/mode/java/runner/Runner.java
+++ b/app/src/processing/mode/java/runner/Runner.java
@@ -814,18 +814,27 @@ public class Runner implements MessageConsumer {
// System.out.println("mess type " + messageValue.type());
//StringReference messageReference = (StringReference) messageValue.type();
-// System.out.println(or.referenceType().fields());
-// if (name.startsWith("java.lang.")) {
-// name = name.substring(10);
- if (!handleCommonErrors(exceptionName, message, listener)) {
- reportException(message, or, event.thread());
- }
+ // First just report the exception and its placement
+ reportException(message, or, event.thread());
+ // Then try to pretty it up with a better message
+ handleCommonErrors(exceptionName, message, listener);
+
if (editor != null) {
editor.deactivateRun();
}
}
+ /**
+ * Provide more useful explanations of common error messages, perhaps with
+ * a short message in the status area, and (if necessary) a longer message
+ * in the console.
+ *
+ * @param exceptionClass Class name causing the error (with full package name)
+ * @param message The message from the exception
+ * @param listener The Editor or command line interface that's listening for errors
+ * @return true if the error was purtified, false otherwise
+ */
public static boolean handleCommonErrors(final String exceptionClass,
final String message,
final RunnerListener listener) {
@@ -845,6 +854,11 @@ public class Runner implements MessageConsumer {
System.err.println("If your sketch uses a lot of memory (for instance if it loads a lot of data files)");
System.err.println("you can increase the memory available to your sketch using the Preferences window.");
}
+ } else if (exceptionClass.equals("java.lang.UnsatisfiedLinkError")) {
+ listener.statusError("A library used by this sketch is not installed properly.");
+ System.err.println("A library relies on native code that's not available.");
+ System.err.println("Or only works properly when the sketch is run as a " +
+ ((Base.getNativeBits() == 32) ? "64-bit " : "32-bit ") + " application.");
} else if (exceptionClass.equals("java.lang.StackOverflowError")) {
listener.statusError("StackOverflowError: This sketch is attempting too much recursion.");
From dbbc6f25b930971a291a296acf0cfbae35c9fa97 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sat, 20 Jul 2013 21:59:58 -0400
Subject: [PATCH 084/400] multiple categories (#1970), stricter categories,
ignore temp folders
---
.../app/contrib/AvailableContribution.java | 10 +-
.../processing/app/contrib/Contribution.java | 69 ++++++++-
.../app/contrib/ContributionListing.java | 135 +++++++++---------
.../app/contrib/ContributionType.java | 47 ++++--
.../app/contrib/LocalContribution.java | 11 +-
.../app/contrib/ModeContribution.java | 14 +-
6 files changed, 184 insertions(+), 102 deletions(-)
diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java
index b30723682..046c49678 100644
--- a/app/src/processing/app/contrib/AvailableContribution.java
+++ b/app/src/processing/app/contrib/AvailableContribution.java
@@ -41,7 +41,8 @@ class AvailableContribution extends Contribution {
this.type = type;
this.link = params.get("download");
- category = ContributionListing.getCategory(params.get("category"));
+ //category = ContributionListing.getCategory(params.get("category"));
+ categories = parseCategories(params.get("category"));
name = params.get("name");
authorList = params.get("authorList");
url = params.get("url");
@@ -65,12 +66,11 @@ class AvailableContribution extends Contribution {
// Unzip the file into the modes, tools, or libraries folder inside the
// sketchbook. Unzipping to /tmp is problematic because it may be on
// another file system, so move/rename operations will break.
- File sketchbookContribFolder = type.getSketchbookFolder();
+// File sketchbookContribFolder = type.getSketchbookFolder();
File tempFolder = null;
try {
- tempFolder =
- Base.createTempFolder(type.toString(), "tmp", sketchbookContribFolder);
+ tempFolder = type.createTempFolder();
} catch (IOException e) {
status.setErrorMessage("Could not create a temporary folder to install.");
return null;
@@ -183,7 +183,7 @@ class AvailableContribution extends Contribution {
PrintWriter writer = PApplet.createWriter(propFile);
writer.println("name=" + getName());
- writer.println("category=" + getCategory());
+ writer.println("category=" + getCategoryStr());
writer.println("authorList=" + getAuthorList());
writer.println("url=" + getUrl());
writer.println("sentence=" + getSentence());
diff --git a/app/src/processing/app/contrib/Contribution.java b/app/src/processing/app/contrib/Contribution.java
index 759b85537..e09098add 100644
--- a/app/src/processing/app/contrib/Contribution.java
+++ b/app/src/processing/app/contrib/Contribution.java
@@ -21,9 +21,21 @@
*/
package processing.app.contrib;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import processing.core.PApplet;
+
abstract public class Contribution {
- protected String category; // "Sound"
+ static final List validCategories =
+ Arrays.asList("3D", "Animation", "Data", "Geometry", "GUI", "Hardware",
+ "I/O", "Math", "Simulation", "Sound", "Typography",
+ "Utilities", "Video & Vision", "Other");
+
+ //protected String category; // "Sound"
+ protected List categories; // "Sound", "Typography"
protected String name; // "pdf" or "PDF Export"
protected String authorList; // Ben Fry
protected String url; // http://processing.org
@@ -34,8 +46,37 @@ abstract public class Contribution {
// "Sound"
- public String getCategory() {
- return category;
+// public String getCategory() {
+// return category;
+// }
+
+
+ // "Sound", "Utilities"... see valid list in ContributionListing
+ protected List getCategories() {
+ return categories;
+ }
+
+
+ protected String getCategoryStr() {
+ StringBuilder sb = new StringBuilder();
+ for (String category : categories) {
+ sb.append(category);
+ sb.append(',');
+ }
+ sb.deleteCharAt(sb.length()-1); // delete last comma
+ return sb.toString();
+ }
+
+
+ protected boolean hasCategory(String category) {
+ if (category != null) {
+ for (String c : categories) {
+ if (category.equalsIgnoreCase(c)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
@@ -105,4 +146,26 @@ abstract public class Contribution {
boolean isDeletionFlagged() {
return false;
}
+
+
+ /**
+ * @return the list of categories that this contribution is part of
+ * (e.g. "Typography / Geometry"). "Unknown" if the category null.
+ */
+ static public List parseCategories(String categoryStr) {
+ List outgoing = new ArrayList();
+
+ if (categoryStr != null) {
+ String[] listing = PApplet.trim(PApplet.split(categoryStr, ','));
+ for (String category : listing) {
+ if (validCategories.contains(category)) {
+ outgoing.add(category);
+ }
+ }
+ }
+ if (outgoing.size() == 0) {
+ outgoing.add("Unknown");
+ }
+ return outgoing;
+ }
}
diff --git a/app/src/processing/app/contrib/ContributionListing.java b/app/src/processing/app/contrib/ContributionListing.java
index f9e211a8c..149cb3fdc 100644
--- a/app/src/processing/app/contrib/ContributionListing.java
+++ b/app/src/processing/app/contrib/ContributionListing.java
@@ -31,8 +31,9 @@ import processing.core.PApplet;
public class ContributionListing {
+ // Stable URL that will redirect to wherever we're hosting the file
static final String LISTING_URL =
- "http://processing.org/contrib_generate/contributions.txt";
+ "http://download.processing.org/contributions.txt";
static ContributionListing singleInstance;
@@ -44,12 +45,6 @@ public class ContributionListing {
boolean hasDownloadedLatestList;
ReentrantLock downloadingListingLock;
- static final String[] validCategories = {
- "3D", "Animation", "Compilations", "Data", "Geometry", "GUI",
- "Hardware", "I/O", "Math", "Simulation", "Sound", "Typography",
- "Utilities", "Video & Vision"
- };
-
private ContributionListing() {
listeners = new ArrayList();
@@ -103,53 +98,57 @@ public class ContributionListing {
protected void replaceContribution(Contribution oldLib, Contribution newLib) {
- if (oldLib == null || newLib == null) {
- return;
- }
+ if (oldLib != null && newLib != null) {
+ for (String category : oldLib.getCategories()) {
+ if (librariesByCategory.containsKey(category)) {
+ List list = librariesByCategory.get(category);
- if (librariesByCategory.containsKey(oldLib.getCategory())) {
- List list = librariesByCategory.get(oldLib.getCategory());
-
- for (int i = 0; i < list.size(); i++) {
- if (list.get(i) == oldLib) {
- list.set(i, newLib);
+ for (int i = 0; i < list.size(); i++) {
+ if (list.get(i) == oldLib) {
+ list.set(i, newLib);
+ }
+ }
}
}
- }
- for (int i = 0; i < allContributions.size(); i++) {
- if (allContributions.get(i) == oldLib) {
- allContributions.set(i, newLib);
+ for (int i = 0; i < allContributions.size(); i++) {
+ if (allContributions.get(i) == oldLib) {
+ allContributions.set(i, newLib);
+ }
}
- }
- notifyChange(oldLib, newLib);
+ notifyChange(oldLib, newLib);
+ }
}
private void addContribution(Contribution contribution) {
- if (librariesByCategory.containsKey(contribution.getCategory())) {
- List list = librariesByCategory.get(contribution.getCategory());
- list.add(contribution);
- Collections.sort(list, nameComparator);
+ for (String category : contribution.getCategories()) {
+ if (librariesByCategory.containsKey(category)) {
+ List list = librariesByCategory.get(category);
+ list.add(contribution);
+ Collections.sort(list, nameComparator);
- } else {
- ArrayList list = new ArrayList();
- list.add(contribution);
- librariesByCategory.put(contribution.getCategory(), list);
+ } else {
+ ArrayList list = new ArrayList();
+ list.add(contribution);
+ librariesByCategory.put(category, list);
+ }
+ allContributions.add(contribution);
+ notifyAdd(contribution);
+ Collections.sort(allContributions, nameComparator);
}
- allContributions.add(contribution);
- notifyAdd(contribution);
- Collections.sort(allContributions, nameComparator);
}
- protected void removeContribution(Contribution info) {
- if (librariesByCategory.containsKey(info.getCategory())) {
- librariesByCategory.get(info.getCategory()).remove(info);
+ protected void removeContribution(Contribution contribution) {
+ for (String category : contribution.getCategories()) {
+ if (librariesByCategory.containsKey(category)) {
+ librariesByCategory.get(category).remove(contribution);
+ }
}
- allContributions.remove(info);
- notifyRemove(info);
+ allContributions.remove(contribution);
+ notifyRemove(contribution);
}
@@ -209,12 +208,14 @@ public class ContributionListing {
protected List getFilteredLibraryList(String category, List filters) {
- ArrayList filteredList = new ArrayList(allContributions);
+ ArrayList filteredList =
+ new ArrayList(allContributions);
Iterator it = filteredList.iterator();
while (it.hasNext()) {
Contribution libInfo = it.next();
- if (category != null && !category.equals(libInfo.getCategory())) {
+ //if (category != null && !category.equals(libInfo.getCategory())) {
+ if (category != null && !libInfo.hasCategory(category)) {
it.remove();
} else {
for (String filter : filters) {
@@ -254,7 +255,7 @@ public class ContributionListing {
return contrib.getAuthorList() != null && contrib.getAuthorList().toLowerCase().matches(filter)
|| contrib.getSentence() != null && contrib.getSentence().toLowerCase().matches(filter)
|| contrib.getParagraph() != null && contrib.getParagraph().toLowerCase().matches(filter)
- || contrib.getCategory() != null && contrib.getCategory().toLowerCase().matches(filter)
+ || contrib.hasCategory(filter)
|| contrib.getName() != null && contrib.getName().toLowerCase().matches(filter);
}
@@ -396,39 +397,39 @@ public class ContributionListing {
}
- /**
- * @return a lowercase string with all non-alphabetic characters removed
- */
- static protected String normalize(String s) {
- return s.toLowerCase().replaceAll("^\\p{Lower}", "");
- }
+// /**
+// * @return a lowercase string with all non-alphabetic characters removed
+// */
+// static protected String normalize(String s) {
+// return s.toLowerCase().replaceAll("^\\p{Lower}", "");
+// }
-
- /**
- * @return the proper, valid name of this category to be displayed in the UI
- * (e.g. "Typography / Geometry"). "Unknown" if the category null.
- */
- static public String getCategory(String category) {
- if (category == null) {
- return "Unknown";
- }
- String normCatName = normalize(category);
-
- for (String validCatName : validCategories) {
- String normValidCatName = normalize(validCatName);
- if (normValidCatName.equals(normCatName)) {
- return validCatName;
- }
- }
- return category;
- }
+
+// /**
+// * @return the proper, valid name of this category to be displayed in the UI
+// * (e.g. "Typography / Geometry"). "Unknown" if the category null.
+// */
+// static public String getCategory(String category) {
+// if (category == null) {
+// return "Unknown";
+// }
+// String normCatName = normalize(category);
+//
+// for (String validCatName : validCategories) {
+// String normValidCatName = normalize(validCatName);
+// if (normValidCatName.equals(normCatName)) {
+// return validCatName;
+// }
+// }
+// return category;
+// }
ArrayList parseContribList(File file) {
ArrayList outgoing = new ArrayList();
if (file != null && file.exists()) {
- String lines[] = PApplet.loadStrings(file);
+ String[] lines = PApplet.loadStrings(file);
int start = 0;
while (start < lines.length) {
diff --git a/app/src/processing/app/contrib/ContributionType.java b/app/src/processing/app/contrib/ContributionType.java
index 4c3b69fee..a2a943665 100644
--- a/app/src/processing/app/contrib/ContributionType.java
+++ b/app/src/processing/app/contrib/ContributionType.java
@@ -23,6 +23,7 @@ package processing.app.contrib;
import java.io.File;
import java.io.FileFilter;
+import java.io.IOException;
import java.util.ArrayList;
import processing.app.Base;
@@ -30,7 +31,6 @@ import processing.app.Editor;
import processing.app.Library;
public enum ContributionType {
-// LIBRARY, LIBRARY_COMPILATION, TOOL, MODE;
LIBRARY, TOOL, MODE;
@@ -38,8 +38,6 @@ public enum ContributionType {
switch (this) {
case LIBRARY:
return "library";
-// case LIBRARY_COMPILATION:
-// return "compilation";
case TOOL:
return "tool";
case MODE:
@@ -49,7 +47,10 @@ public enum ContributionType {
};
- /** Return Mode for mode, Tool for tool, etc. */
+ /**
+ * Get this type name as a purtied up, capitalized version.
+ * @return Mode for mode, Tool for tool, etc.
+ */
public String getTitle() {
String s = toString();
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
@@ -60,8 +61,6 @@ public enum ContributionType {
switch (this) {
case LIBRARY:
return "libraries";
-// case LIBRARY_COMPILATION:
-// return "libraries";
case TOOL:
return "tools";
case MODE:
@@ -69,6 +68,26 @@ public enum ContributionType {
}
return null; // should be unreachable
}
+
+
+ public File createTempFolder() throws IOException {
+ return Base.createTempFolder(toString(), "tmp", getSketchbookFolder());
+ }
+
+
+ public boolean isTempFolderName(String name) {
+ return name.startsWith(toString()) && name.endsWith("tmp");
+ }
+
+
+// public String getTempPrefix() {
+// return toString();
+// }
+//
+//
+// public String getTempSuffix() {
+// return "tmp";
+// }
// public String getPropertiesName() {
@@ -78,16 +97,13 @@ public enum ContributionType {
static public ContributionType fromName(String s) {
if (s != null) {
- if ("library".equals(s.toLowerCase())) {
+ if ("library".equalsIgnoreCase(s)) {
return LIBRARY;
}
-// if ("compilation".equals(s.toLowerCase())) {
-// return LIBRARY_COMPILATION;
-// }
- if ("tool".equals(s.toLowerCase())) {
+ if ("tool".equalsIgnoreCase(s)) {
return TOOL;
}
- if ("mode".equals(s.toLowerCase())) {
+ if ("mode".equalsIgnoreCase(s)) {
return MODE;
}
}
@@ -109,7 +125,9 @@ public enum ContributionType {
boolean isCandidate(File potential) {
- return (potential.isDirectory() && new File(potential, toString()).exists());
+ return (potential.isDirectory() &&
+ new File(potential, toString()).exists() &&
+ !isTempFolderName(potential.getName()));
}
@@ -148,7 +166,8 @@ public enum ContributionType {
LocalContribution load(Base base, File folder) {
switch (this) {
case LIBRARY:
- return new Library(folder);
+ //return new Library(folder);
+ return Library.load(folder);
case TOOL:
return ToolContribution.load(folder);
case MODE:
diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java
index 7bf2878aa..20595a7ba 100644
--- a/app/src/processing/app/contrib/LocalContribution.java
+++ b/app/src/processing/app/contrib/LocalContribution.java
@@ -57,7 +57,7 @@ public abstract class LocalContribution extends Contribution {
name = properties.get("name");
id = properties.get("id");
- category = ContributionListing.getCategory(properties.get("category"));
+ categories = parseCategories(properties.get("category"));
if (name == null) {
name = folder.getName();
}
@@ -71,7 +71,6 @@ public abstract class LocalContribution extends Contribution {
} catch (NumberFormatException e) {
System.err.println("The version number for the “" + name + "” library is not set properly.");
System.err.println("Please contact the library author to fix it according to the guidelines.");
- //e.printStackTrace();
}
prettyVersion = properties.get("prettyVersion");
@@ -185,8 +184,8 @@ public abstract class LocalContribution extends Contribution {
LocalContribution copyAndLoad(Editor editor,
- boolean confirmReplace,
- StatusPanel status) {
+ boolean confirmReplace,
+ StatusPanel status) {
ArrayList oldContribs =
getType().listContributions(editor);
@@ -283,7 +282,7 @@ public abstract class LocalContribution extends Contribution {
if (backupFolder != null) {
String libFolderName = getFolder().getName();
String prefix = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
- final String backupName = prefix + "_" + libFolderName;
+ final String backupName = prefix + " " + libFolderName;
File backupSubFolder = ContributionManager.getUniqueName(backupFolder, backupName);
if (deleteOriginal) {
@@ -505,7 +504,7 @@ public abstract class LocalContribution extends Contribution {
}
- class IgnorableException extends Exception {
+ static protected class IgnorableException extends Exception {
public IgnorableException(String msg) {
super(msg);
}
diff --git a/app/src/processing/app/contrib/ModeContribution.java b/app/src/processing/app/contrib/ModeContribution.java
index 44290d006..a55e2f1d8 100644
--- a/app/src/processing/app/contrib/ModeContribution.java
+++ b/app/src/processing/app/contrib/ModeContribution.java
@@ -94,13 +94,13 @@ public class ModeContribution extends LocalContribution {
File[] potential = ContributionType.MODE.listCandidates(modesFolder);
for (File folder : potential) {
if (!existing.containsKey(folder)) {
- try {
- contribModes.add(new ModeContribution(base, folder, null));
- } catch (IgnorableException ig) {
- Base.log(ig.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- }
+ try {
+ contribModes.add(new ModeContribution(base, folder, null));
+ } catch (IgnorableException ig) {
+ Base.log(ig.getMessage());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
}
}
From f9da91403792c17ebb5ff9c2dd182682e8230216 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sat, 20 Jul 2013 22:01:46 -0400
Subject: [PATCH 085/400] tweaks and cleanups, add new file removal
---
app/src/processing/app/Base.java | 71 +++++++++++++++++++++-----------
1 file changed, 48 insertions(+), 23 deletions(-)
mode change 100755 => 100644 app/src/processing/app/Base.java
diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java
old mode 100755
new mode 100644
index 92fa77111..e0e66e3fb
--- a/app/src/processing/app/Base.java
+++ b/app/src/processing/app/Base.java
@@ -6,9 +6,9 @@
Copyright (c) 2004-13 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
- it under the terms of the GNU General Public License version 2
- as published by the Free Software 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, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -1640,22 +1640,22 @@ public class Base {
//return PApplet.platform == PConstants.MACOSX;
return System.getProperty("os.name").indexOf("Mac") != -1; //$NON-NLS-1$ //$NON-NLS-2$
}
-
-
+
+
static private Boolean usableOracleJava;
-
+
// Make sure this is Oracle Java 7u40 or later. This is temporary.
static public boolean isUsableOracleJava() {
if (usableOracleJava == null) {
usableOracleJava = false;
-
- if (Base.isMacOS() &&
+
+ if (Base.isMacOS() &&
System.getProperty("java.vendor").contains("Oracle")) {
String version = System.getProperty("java.version"); // 1.7.0_40
String[] m = PApplet.match(version, "1.(\\d).*_(\\d+)");
-
- if (m != null &&
- PApplet.parseInt(m[1]) >= 7 &&
+
+ if (m != null &&
+ PApplet.parseInt(m[1]) >= 7 &&
PApplet.parseInt(m[2]) >= 40) {
usableOracleJava = true;
}
@@ -2340,9 +2340,9 @@ public class Base {
String decodedPath = PApplet.urlDecode(path);
// The .jar file will be in the lib folder
File jarFolder = new File(decodedPath).getParentFile();
- if (jarFolder.getName().equals("lib")) {
+ if (jarFolder.getName().equals("lib")) {
// The main Processing installation directory.
- // This works for Windows, Linux, and Apple's Java 6 on OS X.
+ // This works for Windows, Linux, and Apple's Java 6 on OS X.
processingRoot = jarFolder.getParentFile();
} else if (Base.isMacOS()) {
// This works for Java 7 on OS X.
@@ -2350,8 +2350,8 @@ public class Base {
}
if (processingRoot == null || !processingRoot.exists()) {
// Try working directory instead (user.dir, different from user.home)
- Base.log("Could not find lib folder via " +
- jarFolder.getAbsolutePath() +
+ Base.log("Could not find lib folder via " +
+ jarFolder.getAbsolutePath() +
", switching to user.dir");
processingRoot = new File(System.getProperty("user.dir"));
}
@@ -2459,12 +2459,21 @@ public class Base {
}
- static public void readSettings(String filename, String lines[],
+ /**
+ * Parse a String array that contains attribute/value pairs separated
+ * by = (the equals sign). The # (hash) symbol is used to denote comments.
+ * Comments can be anywhere on a line. Blank lines are ignored.
+ */
+ static public void readSettings(String filename, String[] lines,
HashMap settings) {
- for (int i = 0; i < lines.length; i++) {
- int hash = lines[i].indexOf('#');
- String line = (hash == -1) ?
- lines[i].trim() : lines[i].substring(0, hash).trim();
+ for (String line : lines) {
+ // Remove comments
+ int commentMarker = line.indexOf('#');
+ if (commentMarker != -1) {
+ line = line.substring(0, commentMarker);
+ }
+ // Remove extra whitespace
+ line = line.trim();
if (line.length() != 0) {
int equals = line.indexOf('=');
@@ -2574,10 +2583,25 @@ public class Base {
}
+ /**
+ * Remove a File object (a file or directory) from the system by placing it
+ * in the Trash or Recycle Bin (if available) or simply deleting it (if not).
+ *
+ * When the file/folder is on another file system, it may simply be removed
+ * immediately, without additional warning. So only use this if you want to,
+ * you know, "remove" the subject in question.
+ *
+ * @param file the victim
+ * @return true if all ends well
+ * @throws IOException what went wrong
+ */
+ static public boolean removeFile(File file) throws IOException {
+ return platform.deleteFile(file);
+ }
+
+
/**
* Remove all files in a directory and the directory itself.
- * TODO implement cross-platform "move to trash" instead of deleting,
- * since this is potentially scary if there's a bug.
*/
static public void removeDir(File dir) {
if (dir.exists()) {
@@ -2630,7 +2654,8 @@ public class Base {
if (files == null) return -1;
for (int i = 0; i < files.length; i++) {
- if (files[i].equals(".") || (files[i].equals("..")) ||
+ if (files[i].equals(".") ||
+ files[i].equals("..") ||
files[i].equals(".DS_Store")) continue;
File fella = new File(folder, files[i]);
if (fella.isDirectory()) {
From 1e4b3a4bc7e5b0a848c9933f23154ad01301a22f Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sat, 20 Jul 2013 22:02:10 -0400
Subject: [PATCH 086/400] fix permissions
---
app/src/processing/app/EditorHeader.java | 0
app/src/processing/app/Toolkit.java | 0
2 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 app/src/processing/app/EditorHeader.java
mode change 100755 => 100644 app/src/processing/app/Toolkit.java
diff --git a/app/src/processing/app/EditorHeader.java b/app/src/processing/app/EditorHeader.java
old mode 100755
new mode 100644
diff --git a/app/src/processing/app/Toolkit.java b/app/src/processing/app/Toolkit.java
old mode 100755
new mode 100644
From 9a21e8cb448bc18307636d22c272ea7ecda3dbc0 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sat, 20 Jul 2013 22:02:41 -0400
Subject: [PATCH 087/400] no special treatment for core.jar (also gives us
error message for bad libs)
---
app/src/processing/mode/java/JavaMode.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/app/src/processing/mode/java/JavaMode.java b/app/src/processing/mode/java/JavaMode.java
index 4e7aff444..1a5bb3d30 100644
--- a/app/src/processing/mode/java/JavaMode.java
+++ b/app/src/processing/mode/java/JavaMode.java
@@ -99,8 +99,13 @@ public class JavaMode extends Mode {
public Library getCoreLibrary() {
if (coreLibrary == null) {
- File coreFolder = Base.getContentFile("core");
- coreLibrary = new Library(coreFolder);
+// File coreFolder = Base.getContentFile("core");
+// coreLibrary = new Library(coreFolder);
+ try {
+ coreLibrary = getLibrary("processing.core");
+ } catch (SketchException e) {
+ Base.log("Serious problem while locating processing.core", e);
+ }
}
return coreLibrary;
}
From 454ea047879899a3fc63cfb5dd1294a1acc6e9bd Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sat, 20 Jul 2013 22:03:14 -0400
Subject: [PATCH 088/400] bring Library more in line with other contribs
---
app/src/processing/app/Library.java | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/app/src/processing/app/Library.java b/app/src/processing/app/Library.java
index 2520bea15..18910d8ba 100644
--- a/app/src/processing/app/Library.java
+++ b/app/src/processing/app/Library.java
@@ -17,7 +17,8 @@ public class Library extends LocalContribution {
/**
* Subfolder for grouping libraries in a menu. Basic subfolder support
- * is provided so that basic organization can be done in the import menu.
+ * is provided so that some organization can be done in the import menu.
+ * (This is the replacement for the "library compilation" type.)
*/
protected String group;
@@ -83,12 +84,24 @@ public class Library extends LocalContribution {
};
- public Library(File folder) {
+ static public Library load(File folder) {
+ try {
+ return new Library(folder);
+// } catch (IgnorableException ig) {
+// Base.log(ig.getMessage());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
+ private Library(File folder) {
this(folder, null);
}
- public Library(File folder, String groupName) {
+ private Library(File folder, String groupName) {
super(folder);
this.group = groupName;
@@ -196,7 +209,6 @@ public class Library extends LocalContribution {
// get the path for all .jar files in this code folder
packageList = Base.packageListFromClassPath(getClassPath());
-
}
From 810d3025c801fbfab3a8cdd560b6283319258540 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sat, 20 Jul 2013 22:04:15 -0400
Subject: [PATCH 089/400] update JNA to 3.5.2, add platform, remove some custom
code, add Trash/Recycle Bin support
---
app/src/processing/app/windows/Advapi32.java | 335 -------------------
app/src/processing/app/windows/Options.java | 27 --
app/src/processing/app/windows/Platform.java | 313 +++++++++++------
app/src/processing/app/windows/Registry.java | 299 ++++++++++-------
app/src/processing/app/windows/WINBASE.java | 43 ---
app/src/processing/app/windows/WINERROR.java | 22 --
app/src/processing/app/windows/WINNT.java | 73 ----
app/src/processing/app/windows/WINREG.java | 21 --
core/todo.txt | 7 +-
todo.txt | 29 +-
10 files changed, 420 insertions(+), 749 deletions(-)
delete mode 100644 app/src/processing/app/windows/Advapi32.java
delete mode 100644 app/src/processing/app/windows/Options.java
delete mode 100644 app/src/processing/app/windows/WINBASE.java
delete mode 100644 app/src/processing/app/windows/WINERROR.java
delete mode 100644 app/src/processing/app/windows/WINNT.java
delete mode 100644 app/src/processing/app/windows/WINREG.java
diff --git a/app/src/processing/app/windows/Advapi32.java b/app/src/processing/app/windows/Advapi32.java
deleted file mode 100644
index 716983ea3..000000000
--- a/app/src/processing/app/windows/Advapi32.java
+++ /dev/null
@@ -1,335 +0,0 @@
-package processing.app.windows;
-
-/*
- * Advapi32.java
- *
- * Created on 6. August 2007, 11:24
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-import com.sun.jna.*;
-import com.sun.jna.ptr.*;
-import com.sun.jna.win32.*;
-
-/**
- *
- * @author TB
- */
-public interface Advapi32 extends StdCallLibrary {
- Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS); //$NON-NLS-1$
-
-/*
-BOOL WINAPI LookupAccountName(
- LPCTSTR lpSystemName,
- LPCTSTR lpAccountName,
- PSID Sid,
- LPDWORD cbSid,
- LPTSTR ReferencedDomainName,
- LPDWORD cchReferencedDomainName,
- PSID_NAME_USE peUse
-);*/
- public boolean LookupAccountName(String lpSystemName, String lpAccountName,
- byte[] Sid, IntByReference cbSid, char[] ReferencedDomainName,
- IntByReference cchReferencedDomainName, PointerByReference peUse);
-
-/*
-BOOL WINAPI LookupAccountSid(
- LPCTSTR lpSystemName,
- PSID lpSid,
- LPTSTR lpName,
- LPDWORD cchName,
- LPTSTR lpReferencedDomainName,
- LPDWORD cchReferencedDomainName,
- PSID_NAME_USE peUse
-);*/
- public boolean LookupAccountSid(String lpSystemName, byte[] Sid,
- char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
- IntByReference cchReferencedDomainName, PointerByReference peUse);
-
-/*
-BOOL ConvertSidToStringSid(
- PSID Sid,
- LPTSTR* StringSid
-);*/
- public boolean ConvertSidToStringSid(byte[] Sid, PointerByReference StringSid);
-
-/*
-BOOL WINAPI ConvertStringSidToSid(
- LPCTSTR StringSid,
- PSID* Sid
-);*/
- public boolean ConvertStringSidToSid(String StringSid, PointerByReference Sid);
-
-/*
-SC_HANDLE WINAPI OpenSCManager(
- LPCTSTR lpMachineName,
- LPCTSTR lpDatabaseName,
- DWORD dwDesiredAccess
-);*/
- public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName, int dwDesiredAccess);
-
-/*
-BOOL WINAPI CloseServiceHandle(
- SC_HANDLE hSCObject
-);*/
- public boolean CloseServiceHandle(Pointer hSCObject);
-
-/*
-SC_HANDLE WINAPI OpenService(
- SC_HANDLE hSCManager,
- LPCTSTR lpServiceName,
- DWORD dwDesiredAccess
-);*/
- public Pointer OpenService(Pointer hSCManager, String lpServiceName, int dwDesiredAccess);
-
-/*
-BOOL WINAPI StartService(
- SC_HANDLE hService,
- DWORD dwNumServiceArgs,
- LPCTSTR* lpServiceArgVectors
-);*/
- public boolean StartService(Pointer hService, int dwNumServiceArgs, char[] lpServiceArgVectors);
-
-/*
-BOOL WINAPI ControlService(
- SC_HANDLE hService,
- DWORD dwControl,
- LPSERVICE_STATUS lpServiceStatus
-);*/
- public boolean ControlService(Pointer hService, int dwControl, SERVICE_STATUS lpServiceStatus);
-
-/*
-BOOL WINAPI StartServiceCtrlDispatcher(
- const SERVICE_TABLE_ENTRY* lpServiceTable
-);*/
- public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
-
-/*
-SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler(
- LPCTSTR lpServiceName,
- LPHANDLER_FUNCTION lpHandlerProc
-);*/
- public Pointer RegisterServiceCtrlHandler(String lpServiceName, Handler lpHandlerProc);
-
-/*
-SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
- LPCTSTR lpServiceName,
- LPHANDLER_FUNCTION_EX lpHandlerProc,
- LPVOID lpContext
-);*/
- public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName, HandlerEx lpHandlerProc, Pointer lpContext);
-
-/*
-BOOL WINAPI SetServiceStatus(
- SERVICE_STATUS_HANDLE hServiceStatus,
- LPSERVICE_STATUS lpServiceStatus
-);*/
- public boolean SetServiceStatus(Pointer hServiceStatus, SERVICE_STATUS lpServiceStatus);
-
-/*
-SC_HANDLE WINAPI CreateService(
- SC_HANDLE hSCManager,
- LPCTSTR lpServiceName,
- LPCTSTR lpDisplayName,
- DWORD dwDesiredAccess,
- DWORD dwServiceType,
- DWORD dwStartType,
- DWORD dwErrorControl,
- LPCTSTR lpBinaryPathName,
- LPCTSTR lpLoadOrderGroup,
- LPDWORD lpdwTagId,
- LPCTSTR lpDependencies,
- LPCTSTR lpServiceStartName,
- LPCTSTR lpPassword
-);*/
- public Pointer CreateService(Pointer hSCManager, String lpServiceName, String lpDisplayName,
- int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl,
- String lpBinaryPathName, String lpLoadOrderGroup, IntByReference lpdwTagId,
- String lpDependencies, String lpServiceStartName, String lpPassword);
-
-/*
-BOOL WINAPI DeleteService(
- SC_HANDLE hService
-);*/
- public boolean DeleteService(Pointer hService);
-
-/*
-BOOL WINAPI ChangeServiceConfig2(
- SC_HANDLE hService,
- DWORD dwInfoLevel,
- LPVOID lpInfo
-);*/
- public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
-
-/*
-LONG WINAPI RegOpenKeyEx(
- HKEY hKey,
- LPCTSTR lpSubKey,
- DWORD ulOptions,
- REGSAM samDesired,
- PHKEY phkResult
-);*/
- public int RegOpenKeyEx(int hKey, String lpSubKey, int ulOptions, int samDesired, IntByReference phkResult);
-
-/*
-LONG WINAPI RegQueryValueEx(
- HKEY hKey,
- LPCTSTR lpValueName,
- LPDWORD lpReserved,
- LPDWORD lpType,
- LPBYTE lpData,
- LPDWORD lpcbData
-);*/
- public int RegQueryValueEx(int hKey, String lpValueName, IntByReference lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData);
-
-/*
-LONG WINAPI RegCloseKey(
- HKEY hKey
-);*/
- public int RegCloseKey(int hKey);
-
-/*
-LONG WINAPI RegDeleteValue(
- HKEY hKey,
- LPCTSTR lpValueName
-);*/
- public int RegDeleteValue(int hKey, String lpValueName);
-
-/*
-LONG WINAPI RegSetValueEx(
- HKEY hKey,
- LPCTSTR lpValueName,
- DWORD Reserved,
- DWORD dwType,
- const BYTE* lpData,
- DWORD cbData
-);*/
- public int RegSetValueEx(int hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData);
-
-/*
-LONG WINAPI RegCreateKeyEx(
- HKEY hKey,
- LPCTSTR lpSubKey,
- DWORD Reserved,
- LPTSTR lpClass,
- DWORD dwOptions,
- REGSAM samDesired,
- LPSECURITY_ATTRIBUTES lpSecurityAttributes,
- PHKEY phkResult,
- LPDWORD lpdwDisposition
-);*/
- public int RegCreateKeyEx(int hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions,
- int samDesired, WINBASE.SECURITY_ATTRIBUTES lpSecurityAttributes, IntByReference phkResult,
- IntByReference lpdwDisposition);
-
-/*
-LONG WINAPI RegDeleteKey(
- HKEY hKey,
- LPCTSTR lpSubKey
-);*/
- public int RegDeleteKey(int hKey, String name);
-
-/*
-LONG WINAPI RegEnumKeyEx(
- HKEY hKey,
- DWORD dwIndex,
- LPTSTR lpName,
- LPDWORD lpcName,
- LPDWORD lpReserved,
- LPTSTR lpClass,
- LPDWORD lpcClass,
- PFILETIME lpftLastWriteTime
-);*/
- public int RegEnumKeyEx(int hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved,
- char[] lpClass, IntByReference lpcClass, WINBASE.FILETIME lpftLastWriteTime);
-
-/*
-LONG WINAPI RegEnumValue(
- HKEY hKey,
- DWORD dwIndex,
- LPTSTR lpValueName,
- LPDWORD lpcchValueName,
- LPDWORD lpReserved,
- LPDWORD lpType,
- LPBYTE lpData,
- LPDWORD lpcbData
-);*/
- public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved,
- IntByReference lpType, byte[] lpData, IntByReference lpcbData);
-
- interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
- /*
- VOID WINAPI ServiceMain(
- DWORD dwArgc,
- LPTSTR* lpszArgv
- );*/
- public void callback(int dwArgc, Pointer lpszArgv);
- }
-
- interface Handler extends StdCallCallback {
- /*
- VOID WINAPI Handler(
- DWORD fdwControl
- );*/
- public void callback(int fdwControl);
- }
-
- interface HandlerEx extends StdCallCallback {
- /*
- DWORD WINAPI HandlerEx(
- DWORD dwControl,
- DWORD dwEventType,
- LPVOID lpEventData,
- LPVOID lpContext
- );*/
- public void callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext);
- }
-
-/*
-typedef struct _SERVICE_STATUS {
- DWORD dwServiceType;
- DWORD dwCurrentState;
- DWORD dwControlsAccepted;
- DWORD dwWin32ExitCode;
- DWORD dwServiceSpecificExitCode;
- DWORD dwCheckPoint;
- DWORD dwWaitHint;
-} SERVICE_STATUS,
- *LPSERVICE_STATUS;*/
- public static class SERVICE_STATUS extends Structure {
- public int dwServiceType;
- public int dwCurrentState;
- public int dwControlsAccepted;
- public int dwWin32ExitCode;
- public int dwServiceSpecificExitCode;
- public int dwCheckPoint;
- public int dwWaitHint;
- }
-
-/*
-typedef struct _SERVICE_TABLE_ENTRY {
- LPTSTR lpServiceName;
- LPSERVICE_MAIN_FUNCTION lpServiceProc;
-} SERVICE_TABLE_ENTRY,
- *LPSERVICE_TABLE_ENTRY;*/
- public static class SERVICE_TABLE_ENTRY extends Structure {
- public String lpServiceName;
- public SERVICE_MAIN_FUNCTION lpServiceProc;
- }
-
- public static class ChangeServiceConfig2Info extends Structure {
- }
-
-/*
- typedef struct _SERVICE_DESCRIPTION {
- LPTSTR lpDescription;
-} SERVICE_DESCRIPTION,
- *LPSERVICE_DESCRIPTION;*/
- public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
- public String lpDescription;
- }
-}
-
-
diff --git a/app/src/processing/app/windows/Options.java b/app/src/processing/app/windows/Options.java
deleted file mode 100644
index f5cff2888..000000000
--- a/app/src/processing/app/windows/Options.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Options.java
- *
- * Created on 8. August 2007, 17:07
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-import static com.sun.jna.Library.*;
-import com.sun.jna.win32.*;
-import java.util.*;
-
-/**
- *
- * @author TB
- */
-public interface Options {
- Map UNICODE_OPTIONS = new HashMap() {
- {
- put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
- put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
- }
- };
-}
diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java
index a6c228f17..c5325fb17 100644
--- a/app/src/processing/app/windows/Platform.java
+++ b/app/src/processing/app/windows/Platform.java
@@ -3,13 +3,12 @@
/*
Part of the Processing project - http://processing.org
- Copyright (c) 2012 The Processing Foundation
+ Copyright (c) 2012-2013 The Processing Foundation
Copyright (c) 2008-2012 Ben Fry and Casey Reas
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,16 +23,20 @@
package processing.app.windows;
import java.io.File;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Map;
import com.sun.jna.Library;
import com.sun.jna.Native;
-import com.sun.jna.NativeMapped;
-import com.sun.jna.PointerType;
-import com.sun.jna.win32.W32APIFunctionMapper;
-import com.sun.jna.win32.W32APITypeMapper;
+import com.sun.jna.WString;
+import com.sun.jna.platform.win32.Kernel32Util;
+import com.sun.jna.platform.win32.Shell32;
+import com.sun.jna.platform.win32.ShellAPI;
+import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT;
+import com.sun.jna.platform.win32.ShlObj;
+import com.sun.jna.platform.win32.WinDef;
+import com.sun.jna.platform.win32.WinError;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
import processing.app.Base;
import processing.app.Preferences;
@@ -41,13 +44,28 @@ import processing.app.windows.Registry.REGISTRY_ROOT_KEY;
import processing.core.PApplet;
+/**
+ * Platform-specific glue for Windows.
+ *
+ * This is a bit of a hodgepodge of JNA examples and StackOverflow answers,
+ * and as a result, is not the prettiest piece of code in this code base.
+ * In fact, an honest man might call it ugly.
+ *
+ * Classes like Advapi32, WINNT, etc could be removed in favor of the
+ * jna-platform.jar, but that would require 1) some cleanup and extensive
+ * testing (across Windows XP, 7, and 8) to make sure everything was still
+ * working. It would also require adding the new .jar file, and making sure
+ * that it was included with the distribution across all of the platforms.
+ */
public class Platform extends processing.app.Platform {
-
+
static final String openCommand =
System.getProperty("user.dir").replace('/', '\\') +
"\\processing.exe \"%1\"";
static final String DOC = "Processing.Document";
// static final String DOC = "Processing.exe";
+
+ static final String APP_NAME = "Processing";
public void init(Base base) {
@@ -56,6 +74,16 @@ public class Platform extends processing.app.Platform {
//checkQuickTime();
checkPath();
+ /*
+ File f = new File("C:\\recycle-test.txt");
+ System.out.println(f.getAbsolutePath());
+ java.io.PrintWriter writer = PApplet.createWriter(f);
+ writer.println("blah");
+ writer.flush();
+ writer.close();
+ deleteFile(f);
+ */
+
//findJDK();
/*
new Thread(new Runnable() {
@@ -173,34 +201,6 @@ public class Platform extends processing.app.Platform {
}
- /**
- * Find QuickTime for Java installation.
- */
-// protected void checkQuickTime() {
-// // http://developer.apple.com/documentation/QuickTime/Conceptual/QT7Win_Update_Guide/Chapter03/chapter_3_section_1.html
-// // HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\QuickTime\QTSysDir
-// try {
-// String qtsystemPath =
-// Registry.getStringValue(REGISTRY_ROOT_KEY.LOCAL_MACHINE,
-// "Software\\Apple Computer, Inc.\\QuickTime",
-// "QTSysDir");
-// // Could show a warning message here if QT not installed, but that
-// // would annoy people who don't want anything to do with QuickTime.
-// if (qtsystemPath != null) {
-// File qtjavaZip = new File(qtsystemPath, "QTJava.zip");
-// if (qtjavaZip.exists()) {
-// String qtjavaZipPath = qtjavaZip.getAbsolutePath();
-// String cp = System.getProperty("java.class.path");
-// System.setProperty("java.class.path",
-// cp + File.pathSeparator + qtjavaZipPath);
-// }
-// }
-// } catch (UnsupportedEncodingException e) {
-// e.printStackTrace();
-// }
-// }
-
-
/**
* Remove extra quotes, slashes, and garbage from the Windows PATH.
*/
@@ -238,6 +238,15 @@ public class Platform extends processing.app.Platform {
// looking for Documents and Settings/blah/Application Data/Processing
public File getSettingsFolder() throws Exception {
+ String appData = getAppDataPath();
+ if (appData != null) {
+ return new File(appData, APP_NAME);
+ }
+ return null;
+ }
+
+
+ static private String getAppDataPath() throws Exception {
// HKEY_CURRENT_USER\Software\Microsoft
// \Windows\CurrentVersion\Explorer\Shell Folders
// Value Name: AppData
@@ -254,26 +263,37 @@ public class Platform extends processing.app.Platform {
// Java 1.6 doesn't provide a good workaround (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519127)
// Using JNA and SHGetFolderPath instead.
- char[] pszPath = new char[Shell32.MAX_PATH]; // this will be contain the path if SHGetFolderPath is successful
- int hResult = Shell32.INSTANCE.SHGetFolderPath(null, Shell32.CSIDL_APPDATA, null, Shell32.SHGFP_TYPE_CURRENT, pszPath);
+ // this will be contain the path if SHGetFolderPath is successful
+ char[] pszPath = new char[WinDef.MAX_PATH];
+ HRESULT hResult =
+ Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_APPDATA,
+ null, ShlObj.SHGFP_TYPE_CURRENT,
+ pszPath);
- if (Shell32.S_OK != hResult){
- throw new Exception("Problem city, population your computer");
+ if (!hResult.equals(WinError.S_OK)) {
+ System.err.println(Kernel32Util.formatMessageFromHR(hResult));
+ throw new Exception("Problem city, population: your computer.");
}
String appDataPath = new String(pszPath);
int len = appDataPath.indexOf("\0");
- appDataPath = appDataPath.substring(0, len);
-
- // DEBUG
- //throw new Exception("win: " + appDataPath);
- return new File(appDataPath, "Processing");
+// appDataPath = appDataPath.substring(0, len);
+// return new File(appDataPath, "Processing");
+ return appDataPath.substring(0, len);
}
// looking for Documents and Settings/blah/My Documents/Processing
public File getDefaultSketchbookFolder() throws Exception {
+ String documentsPath = getDocumentsPath();
+ if (documentsPath != null) {
+ return new File(documentsPath, APP_NAME);
+ }
+ return null;
+ }
+
+ static private String getDocumentsPath() throws Exception {
// http://support.microsoft.com/?kbid=221837&sd=RMVP
// http://support.microsoft.com/kb/242557/en-us
@@ -297,22 +317,110 @@ public class Platform extends processing.app.Platform {
// "The "Shell Folders" key exists solely to permit four programs written
// in 1994 to continue running on the RTM version of Windows 95." -- Raymond Chen, MSDN
- char[] pszPath = new char[Shell32.MAX_PATH]; // this will be contain the path if SHGetFolderPath is successful
- int hResult = Shell32.INSTANCE.SHGetFolderPath(null, Shell32.CSIDL_PERSONAL, null, Shell32.SHGFP_TYPE_CURRENT, pszPath);
+ char[] pszPath = new char[WinDef.MAX_PATH]; // this will be contain the path if SHGetFolderPath is successful
+ HRESULT hResult = Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_PERSONAL, null, ShlObj.SHGFP_TYPE_CURRENT, pszPath);
- if (Shell32.S_OK != hResult){
- throw new Exception("Problem city, population your computer");
+ if (!hResult.equals(WinError.S_OK)) {
+ System.err.println(Kernel32Util.formatMessageFromHR(hResult));
+ throw new Exception("Problem city, population: your computer.");
}
String personalPath = new String(pszPath);
int len = personalPath.indexOf("\0");
- personalPath = personalPath.substring(0, len);
-
- // DEBUG
- //throw new Exception("win: " + personalPath);
- return new File(personalPath, "Processing");
+// personalPath = personalPath.substring(0, len);
+// return new File(personalPath, "Processing");
+ return personalPath.substring(0, len);
}
-
+
+
+ @Override
+ public boolean deleteFile(File file) {
+ try {
+ moveToTrash(new File[] { file });
+ } catch (IOException e) {
+ e.printStackTrace();
+ Base.log("Could not move " + file.getAbsolutePath() + " to the trash.", e);
+ return false;
+ }
+ return true;
+ }
+
+
+ /**
+ * Move files/folders to the trash. If this file is on another file system
+ * or on a shared network directory, it will simply be deleted without any
+ * additional confirmation. Take that.
+ *
+ * Based on JNA source for com.sun.jna.platform.win32.W32FileUtils
+ *
+ * @param files array of File objects to be removed
+ * @return true if no error codes returned
+ * @throws IOException if something bad happened along the way
+ */
+ static private boolean moveToTrash(File[] files) throws IOException {
+ Shell32 shell = Shell32.INSTANCE;
+ SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
+ fileop.wFunc = ShellAPI.FO_DELETE;
+ String[] paths = new String[files.length];
+ for (int i = 0; i < paths.length; i++) {
+ paths[i] = files[i].getAbsolutePath();
+ System.out.println(paths[i]);
+ }
+ fileop.pFrom = new WString(fileop.encodePaths(paths));
+ fileop.fFlags = ShellAPI.FOF_ALLOWUNDO | ShellAPI.FOF_NO_UI;
+ int ret = shell.SHFileOperation(fileop);
+ if (ret != 0) {
+ throw new IOException("Move to trash failed: " +
+ fileop.pFrom + ": error code " + ret);
+// throw new IOException("Move to trash failed: " + fileop.pFrom + ": " +
+// Kernel32Util.formatMessageFromLastErrorCode(ret));
+ }
+ if (fileop.fAnyOperationsAborted) {
+ throw new IOException("Move to trash aborted");
+ }
+ return true;
+ }
+
+
+// /**
+// * Ported from ShellAPI.h in the Microsoft Windows SDK 6.0A.
+// * Modified (bastardized) version from the JNA "platform" classes.
+// * @author dblock[at]dblock.org
+// */
+// public interface ShellAPI extends StdCallLibrary {
+//
+// int STRUCTURE_ALIGNMENT = com.sun.jna.Platform.is64Bit() ?
+// Structure.ALIGN_DEFAULT : Structure.ALIGN_NONE;
+//
+// int FO_MOVE = 0x0001;
+// int FO_COPY = 0x0002;
+// int FO_DELETE = 0x0003;
+// int FO_RENAME = 0x0004;
+//
+// int FOF_MULTIDESTFILES = 0x0001;
+// int FOF_CONFIRMMOUSE = 0x0002;
+// int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still)
+// int FOF_RENAMEONCOLLISION = 0x0008; // automatically rename the source files to avoid the collisions
+// int FOF_NOCONFIRMATION = 0x0010; // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not
+// int FOF_WANTMAPPINGHANDLE = 0x0020; // Fill in SHFILEOPSTRUCT.hNameMappings
+// int FOF_ALLOWUNDO = 0x0040; // enable undo including Recycle behavior for IFileOperation::Delete()
+// int FOF_FILESONLY = 0x0080; // only operate on the files (non folders), both files and folders are assumed without this
+// int FOF_SIMPLEPROGRESS = 0x0100; // means don't show names of files
+// int FOF_NOCONFIRMMKDIR = 0x0200; // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases
+// int FOF_NOERRORUI = 0x0400; // don't put up error UI, other UI may be displayed, progress, confirmations
+// int FOF_NOCOPYSECURITYATTRIBS = 0x0800; // dont copy file security attributes (ACLs)
+// int FOF_NORECURSION = 0x1000; // don't recurse into directories for operations that would recurse
+// int FOF_NO_CONNECTED_ELEMENTS = 0x2000; // don't operate on connected elements ("xxx_files" folders that go with .htm files)
+// int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
+// int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts)
+// int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all
+//
+// int PO_DELETE = 0x0013; // printer is being deleted
+// int PO_RENAME = 0x0014; // printer is being renamed
+// int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed
+// int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time.
+// }
+
/*
public void openURL(String url) throws Exception {
@@ -399,46 +507,59 @@ public class Platform extends processing.app.Platform {
return clib._putenv(variable + "=");
}
+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
// JNA code for using SHGetFolderPath to fix Issue 410
+ // https://code.google.com/p/processing/issues/detail?id=410
// Based on answer provided by McDowell at
- // http://stackoverflow.com/questions/585534/
- // what-is-the-best-way-to-find-the-users-home-directory-in-java/586917#586917
-
- private static Map OPTIONS = new HashMap();
-
- static{
- OPTIONS.put(Library.OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
- OPTIONS.put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
- }
-
- static class HANDLE extends PointerType implements NativeMapped{}
-
- static class HWND extends HANDLE {}
-
- public interface Shell32 extends Library{
-
- public static final int MAX_PATH = 260;
- public static final int SHGFP_TYPE_CURRENT = 0;
- public static final int SHGFP_TYPE_DEFAULT = 1;
- public static final int S_OK = 0;
-
- // KNOWNFOLDERIDs are preferred to CSDIL values
- // but Windows XP only supports CSDIL so thats what we have to use
- public static final int CSIDL_APPDATA = 0x001a; // "Application Data"
- public static final int CSIDL_PERSONAL = 0x0005; // "My Documents"
-
- static Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class, OPTIONS);
-
- /**
- * see http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx
- *
- * HRESULT SHGetFolderPath( HWND hwndOwner, int nFolder, HANDLE hToken,
- * DWORD dwFlags, LPTSTR pszPath);
- */
- public int SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken,
- int dwFlags, char[] pszPath);
- }
+ // http://stackoverflow.com/questions/585534/what-is-the-best-way-to-find-the-users-home-directory-in-java/586917#586917
+// private static Map OPTIONS = new HashMap();
+//
+// static {
+// OPTIONS.put(Library.OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
+// OPTIONS.put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
+// }
+//
+//
+// static class HANDLE extends PointerType implements NativeMapped {
+// public HANDLE() { }
+// }
+//
+// static class HWND extends HANDLE { }
+//
+//
+// public interface Shell32 extends Library {
+//
+// public static final int MAX_PATH = 260;
+// public static final int SHGFP_TYPE_CURRENT = 0;
+// public static final int SHGFP_TYPE_DEFAULT = 1;
+// public static final int S_OK = 0;
+//
+// // KNOWNFOLDERIDs are preferred to CSDIL values
+// // but Windows XP only supports CSDIL so thats what we have to use
+// public static final int CSIDL_APPDATA = 0x001a; // "Application Data"
+// public static final int CSIDL_PERSONAL = 0x0005; // "My Documents"
+//
+// static Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class, OPTIONS);
+//
+// /**
+// * see http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx
+// *
+// * HRESULT SHGetFolderPath( HWND hwndOwner, int nFolder, HANDLE hToken,
+// * DWORD dwFlags, LPTSTR pszPath);
+// */
+// public int SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken,
+// int dwFlags, char[] pszPath);
+//
+// /**
+// * This function can be used to copy, move, rename,
+// * or delete a file system object.
+// * @param fileop Address of an SHFILEOPSTRUCT structure that contains
+// * information this function needs to carry out the specified operation.
+// * @return Returns zero if successful, or nonzero otherwise.
+// */
+// public int SHFileOperation(SHFILEOPSTRUCT fileop);
+// }
}
diff --git a/app/src/processing/app/windows/Registry.java b/app/src/processing/app/windows/Registry.java
index dcb719ef8..5509ca481 100644
--- a/app/src/processing/app/windows/Registry.java
+++ b/app/src/processing/app/windows/Registry.java
@@ -5,42 +5,61 @@ import java.util.HashMap;
import java.util.TreeMap;
import java.util.TreeSet;
+import com.sun.jna.platform.win32.Advapi32;
+import com.sun.jna.platform.win32.WinBase;
+import com.sun.jna.platform.win32.WinError;
+import com.sun.jna.platform.win32.WinNT;
+import com.sun.jna.platform.win32.WinReg;
+import com.sun.jna.platform.win32.WinReg.HKEY;
+import com.sun.jna.platform.win32.WinReg.HKEYByReference;
import com.sun.jna.ptr.IntByReference;
+
/**
- * Methods for accessing the Windows Registry. Only String and DWORD values supported at the moment.
+ * Methods for accessing the Windows Registry. Only String and DWORD values
+ * supported at the moment.
+ *
+ * Not sure of where this code came from originally, but it was hacked on
+ * 20 July 2013 to make updates for use with JNA 3.5.2's platform classes.
*/
public class Registry {
- public static enum REGISTRY_ROOT_KEY{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, USERS};
- private final static HashMap rootKeyMap = new HashMap();
+ static public enum REGISTRY_ROOT_KEY{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, USERS};
+ //private final static HashMap rootKeyMap = new HashMap();
+ private final static HashMap rootKeyMap =
+ new HashMap();
static {
- rootKeyMap.put(REGISTRY_ROOT_KEY.CLASSES_ROOT, WINREG.HKEY_CLASSES_ROOT);
- rootKeyMap.put(REGISTRY_ROOT_KEY.CURRENT_USER, WINREG.HKEY_CURRENT_USER);
- rootKeyMap.put(REGISTRY_ROOT_KEY.LOCAL_MACHINE, WINREG.HKEY_LOCAL_MACHINE);
- rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WINREG.HKEY_USERS);
+ rootKeyMap.put(REGISTRY_ROOT_KEY.CLASSES_ROOT, WinReg.HKEY_CLASSES_ROOT);
+ rootKeyMap.put(REGISTRY_ROOT_KEY.CURRENT_USER, WinReg.HKEY_CURRENT_USER);
+ rootKeyMap.put(REGISTRY_ROOT_KEY.LOCAL_MACHINE, WinReg.HKEY_LOCAL_MACHINE);
+ rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WinReg.HKEY_USERS);
}
+
/**
* Gets one of the root keys.
*
* @param key key type
* @return root key
*/
- private static int getRegistryRootKey(REGISTRY_ROOT_KEY key) {
+ private static HKEY getRegistryRootKey(REGISTRY_ROOT_KEY key) {
Advapi32 advapi32;
- IntByReference pHandle;
- int handle = 0;
+ //IntByReference pHandle;
+ HKEYByReference pHandle;
+ //int handle = 0;
+ HKEY handle = null;
advapi32 = Advapi32.INSTANCE;
- pHandle = new IntByReference();
+// pHandle = new IntByReference();
+ pHandle = new WinReg.HKEYByReference();
- if(advapi32.RegOpenKeyEx(rootKeyMap.get(key), null, 0, 0, pHandle) == WINERROR.ERROR_SUCCESS) {
+ if (advapi32.RegOpenKeyEx(rootKeyMap.get(key), null, 0, 0, pHandle) == WinError.ERROR_SUCCESS) {
handle = pHandle.getValue();
}
- return(handle);
+ return handle;
}
+
/**
* Opens a key.
*
@@ -49,23 +68,24 @@ public class Registry {
* @param access access mode
* @return handle to the key or 0
*/
- private static int openKey(REGISTRY_ROOT_KEY rootKey, String subKeyName, int access) {
- Advapi32 advapi32;
- IntByReference pHandle;
- int rootKeyHandle;
+ private static HKEY openKey(REGISTRY_ROOT_KEY rootKey, String subKeyName, int access) {
+ //Advapi32 advapi32;
+ //IntByReference pHandle;
+ //int rootKeyHandle;
- advapi32 = Advapi32.INSTANCE;
- rootKeyHandle = getRegistryRootKey(rootKey);
- pHandle = new IntByReference();
-
- if(advapi32.RegOpenKeyEx(rootKeyHandle, subKeyName, 0, access, pHandle) == WINERROR.ERROR_SUCCESS) {
- return(pHandle.getValue());
+ Advapi32 advapi32 = Advapi32.INSTANCE;
+ HKEY rootKeyHandle = getRegistryRootKey(rootKey);
+ //pHandle = new IntByReference();
+ HKEYByReference pHandle = new HKEYByReference();
+ if (advapi32.RegOpenKeyEx(rootKeyHandle, subKeyName, 0, access, pHandle) == WinError.ERROR_SUCCESS) {
+ return pHandle.getValue();
} else {
- return(0);
+ return null;
}
}
+
/**
* Converts a Windows buffer to a Java String.
*
@@ -74,9 +94,10 @@ public class Registry {
* @return String
*/
private static String convertBufferToString(byte[] buf) throws UnsupportedEncodingException {
- return(new String(buf, 0, buf.length - 2, "UTF-16LE"));
+ return new String(buf, 0, buf.length - 2, "UTF-16LE");
}
+
/**
* Converts a Windows buffer to an int.
*
@@ -84,9 +105,13 @@ public class Registry {
* @return int
*/
private static int convertBufferToInt(byte[] buf) {
- return((buf[0] & 0xff) + ((buf[1] & 0xff) << 8) + ((buf[2] & 0xff) << 16) + ((buf[3] & 0xff) << 24));
+ return ((buf[0] & 0xff) +
+ ((buf[1] & 0xff) << 8) +
+ ((buf[2] & 0xff) << 16) +
+ ((buf[3] & 0xff) << 24));
}
+
/**
* Read a String value.
*
@@ -96,32 +121,35 @@ public class Registry {
* @throws java.io.UnsupportedEncodingException on error
* @return String or null
*/
- public static String getStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) throws UnsupportedEncodingException {
- Advapi32 advapi32;
- IntByReference pType, lpcbData;
+ static public String getStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) throws UnsupportedEncodingException {
+ //Advapi32 advapi32;
+ //IntByReference pType, lpcbData;
byte[] lpData = new byte[1];
- int handle = 0;
+ //int handle = 0;
String ret = null;
- advapi32 = Advapi32.INSTANCE;
- pType = new IntByReference();
- lpcbData = new IntByReference();
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
+ Advapi32 advapi32 = Advapi32.INSTANCE;
+ IntByReference pType = new IntByReference();
+ IntByReference lpcbData = new IntByReference();
+ HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ);
- if(handle != 0) {
-
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA) {
+ //if (handle != 0) {
+ if (handle != null) {
+ //if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) {
+ if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) {
lpData = new byte[lpcbData.getValue()];
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS) {
+ //if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_SUCCESS) {
+ if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) == WinError.ERROR_SUCCESS) {
ret = convertBufferToString(lpData);
}
}
advapi32.RegCloseKey(handle);
}
- return(ret);
+ return ret;
}
+
/**
* Read an int value.
*
@@ -131,32 +159,37 @@ public class Registry {
* @param subKeyName key name
* @param name value name
*/
- public static int getIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
+ static public int getIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
Advapi32 advapi32;
- IntByReference pType, lpcbData;
+ IntByReference pType;
+ IntByReference lpcbData;
byte[] lpData = new byte[1];
- int handle = 0;
+ //int handle = 0;
+ HKEY handle = null;
int ret = 0;
advapi32 = Advapi32.INSTANCE;
pType = new IntByReference();
lpcbData = new IntByReference();
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
+ handle = openKey(rootKey, subKeyName, WinNT.KEY_READ);
- if(handle != 0) {
-
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA) {
+ //if(handle != 0) {
+ if (handle != null) {
+ //if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) {
+ if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) {
lpData = new byte[lpcbData.getValue()];
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS) {
+ //if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_SUCCESS) {
+ if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) == WinError.ERROR_SUCCESS) {
ret = convertBufferToInt(lpData);
}
}
advapi32.RegCloseKey(handle);
}
- return(ret);
+ return ret;
}
+
/**
* Delete a value.
*
@@ -165,24 +198,24 @@ public class Registry {
* @param name value name
* @return true on success
*/
- public static boolean deleteValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
- Advapi32 advapi32;
- int handle;
+ static public boolean deleteValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
+ Advapi32 advapi32 = Advapi32.INSTANCE;
+ //int handle;
boolean ret = true;
- advapi32 = Advapi32.INSTANCE;
+ HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ | WinNT.KEY_WRITE);
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);
-
- if(handle != 0) {
- if(advapi32.RegDeleteValue(handle, name) == WINERROR.ERROR_SUCCESS) {
+ //if(handle != 0) {
+ if (handle != null) {
+ if (advapi32.RegDeleteValue(handle, name) == WinError.ERROR_SUCCESS) {
ret = true;
}
advapi32.RegCloseKey(handle);
}
- return(ret);
+ return ret;
}
+
/**
* Writes a String value.
*
@@ -193,9 +226,8 @@ public class Registry {
* @throws java.io.UnsupportedEncodingException on error
* @return true on success
*/
- public static boolean setStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, String value) throws UnsupportedEncodingException {
- Advapi32 advapi32;
- int handle;
+ static public boolean setStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, String value) throws UnsupportedEncodingException {
+ //int handle;
byte[] data;
boolean ret = false;
@@ -205,18 +237,20 @@ public class Registry {
byte[] src = value.getBytes("UTF-16LE");
System.arraycopy(src, 0, data, 0, src.length);
- advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);
+ Advapi32 advapi32 = Advapi32.INSTANCE;
+ HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ | WinNT.KEY_WRITE);
- if(handle != 0) {
- if(advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_SZ, data, data.length) == WINERROR.ERROR_SUCCESS) {
+ //if(handle != 0) {
+ if (handle != null) {
+ if (advapi32.RegSetValueEx(handle, name, 0, WinNT.REG_SZ, data, data.length) == WinError.ERROR_SUCCESS) {
ret = true;
}
advapi32.RegCloseKey(handle);
}
- return(ret);
+ return ret;
}
+
/**
* Writes an int value.
*
@@ -227,9 +261,9 @@ public class Registry {
* @param name value name
* @param value value
*/
- public static boolean setIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, int value) {
+ static public boolean setIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, int value) {
Advapi32 advapi32;
- int handle;
+ //int handle;
byte[] data;
boolean ret = false;
@@ -239,18 +273,19 @@ public class Registry {
data[2] = (byte)((value >> 16) & 0xff);
data[3] = (byte)((value >> 24) & 0xff);
advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);
+ HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ | WinNT.KEY_WRITE);
- if(handle != 0) {
-
- if(advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_DWORD, data, data.length) == WINERROR.ERROR_SUCCESS) {
+ //if(handle != 0) {
+ if (handle != null) {
+ if (advapi32.RegSetValueEx(handle, name, 0, WinNT.REG_DWORD, data, data.length) == WinError.ERROR_SUCCESS) {
ret = true;
}
advapi32.RegCloseKey(handle);
}
- return(ret);
+ return ret;
}
+
/**
* Check for existence of a value.
*
@@ -259,21 +294,22 @@ public class Registry {
* @param name value name
* @return true if exists
*/
- public static boolean valueExists(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
- Advapi32 advapi32;
+ static public boolean valueExists(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
+ //Advapi32 advapi32;
IntByReference pType, lpcbData;
byte[] lpData = new byte[1];
- int handle = 0;
+ //int handle = 0;
boolean ret = false;
- advapi32 = Advapi32.INSTANCE;
+ Advapi32 advapi32 = Advapi32.INSTANCE;
pType = new IntByReference();
lpcbData = new IntByReference();
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
+ HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ);
- if(handle != 0) {
-
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) != WINERROR.ERROR_FILE_NOT_FOUND) {
+ //if(handle != 0) {
+ if (handle != null) {
+ //if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) != WinError.ERROR_FILE_NOT_FOUND) {
+ if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) != WinError.ERROR_FILE_NOT_FOUND) {
ret = true;
} else {
@@ -281,9 +317,10 @@ public class Registry {
}
advapi32.RegCloseKey(handle);
}
- return(ret);
+ return ret;
}
+
/**
* Create a new key.
*
@@ -292,21 +329,22 @@ public class Registry {
* @param name key name
* @return true on success
*/
- public static boolean createKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) {
- Advapi32 advapi32;
- IntByReference hkResult, dwDisposition;
- int handle = 0;
+ static public boolean createKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) {
+ //Advapi32 advapi32;
+ //IntByReference hkResult, dwDisposition;
+ //int handle = 0;
boolean ret = false;
- advapi32 = Advapi32.INSTANCE;
- hkResult = new IntByReference();
- dwDisposition = new IntByReference();
- handle = openKey(rootKey, parent, WINNT.KEY_READ);
+ Advapi32 advapi32 = Advapi32.INSTANCE;
+ //IntByReference hkResult = new IntByReference();
+ HKEYByReference hkResult = new HKEYByReference();
+ IntByReference dwDisposition = new IntByReference();
+ HKEY handle = openKey(rootKey, parent, WinNT.KEY_READ);
- if(handle != 0) {
-
- if(advapi32.RegCreateKeyEx(handle, name, 0, null, WINNT.REG_OPTION_NON_VOLATILE, WINNT.KEY_READ, null,
- hkResult, dwDisposition) == WINERROR.ERROR_SUCCESS) {
+ //if(handle != 0) {
+ if (handle != null) {
+ if (advapi32.RegCreateKeyEx(handle, name, 0, null, WinNT.REG_OPTION_NON_VOLATILE, WinNT.KEY_READ, null,
+ hkResult, dwDisposition) == WinError.ERROR_SUCCESS) {
ret = true;
advapi32.RegCloseKey(hkResult.getValue());
@@ -315,9 +353,10 @@ public class Registry {
}
advapi32.RegCloseKey(handle);
}
- return(ret);
+ return ret;
}
+
/**
* Delete a key.
*
@@ -326,17 +365,17 @@ public class Registry {
* @param name key name
* @return true on success
*/
- public static boolean deleteKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) {
- Advapi32 advapi32;
- int handle = 0;
+ static public boolean deleteKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) {
+ //Advapi32 advapi32;
+ //int handle = 0;
boolean ret = false;
- advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, parent, WINNT.KEY_READ);
+ Advapi32 advapi32 = Advapi32.INSTANCE;
+ HKEY handle = openKey(rootKey, parent, WinNT.KEY_READ);
- if(handle != 0) {
-
- if(advapi32.RegDeleteKey(handle, name) == WINERROR.ERROR_SUCCESS) {
+ //if(handle != 0) {
+ if (handle != null) {
+ if (advapi32.RegDeleteKey(handle, name) == WinError.ERROR_SUCCESS) {
ret = true;
} else {
@@ -344,9 +383,10 @@ public class Registry {
}
advapi32.RegCloseKey(handle);
}
- return(ret);
+ return ret;
}
+
/**
* Get all sub keys of a key.
*
@@ -354,35 +394,36 @@ public class Registry {
* @param parent key name
* @return array with all sub key names
*/
- public static String[] getSubKeys(REGISTRY_ROOT_KEY rootKey, String parent) {
- Advapi32 advapi32;
- int handle = 0, dwIndex;
+ static public String[] getSubKeys(REGISTRY_ROOT_KEY rootKey, String parent) {
+ //Advapi32 advapi32;
+ //int handle = 0, dwIndex;
char[] lpName;
IntByReference lpcName;
- WINBASE.FILETIME lpftLastWriteTime;
+ WinBase.FILETIME lpftLastWriteTime;
TreeSet subKeys = new TreeSet();
- advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, parent, WINNT.KEY_READ);
+ Advapi32 advapi32 = Advapi32.INSTANCE;
+ HKEY handle = openKey(rootKey, parent, WinNT.KEY_READ);
lpName = new char[256];
lpcName = new IntByReference(256);
- lpftLastWriteTime = new WINBASE.FILETIME();
+ lpftLastWriteTime = new WinBase.FILETIME();
- if(handle != 0) {
- dwIndex = 0;
+ //if(handle != 0) {
+ if (handle != null) {
+ int dwIndex = 0;
while(advapi32.RegEnumKeyEx(handle, dwIndex, lpName, lpcName, null,
- null, null, lpftLastWriteTime) == WINERROR.ERROR_SUCCESS) {
+ null, null, lpftLastWriteTime) == WinError.ERROR_SUCCESS) {
subKeys.add(new String(lpName, 0, lpcName.getValue()));
lpcName.setValue(256);
dwIndex++;
}
advapi32.RegCloseKey(handle);
}
-
- return(subKeys.toArray(new String[]{}));
+ return subKeys.toArray(new String[] { });
}
+
/**
* Get all values under a key.
*
@@ -391,45 +432,47 @@ public class Registry {
* @throws java.io.UnsupportedEncodingException on error
* @return TreeMap with name and value pairs
*/
- public static TreeMap getValues(REGISTRY_ROOT_KEY rootKey, String key) throws UnsupportedEncodingException {
- Advapi32 advapi32;
- int handle = 0, dwIndex, result = 0;
+ static public TreeMap getValues(REGISTRY_ROOT_KEY rootKey, String key) throws UnsupportedEncodingException {
+ //Advapi32 advapi32;
+ //int handle = 0, dwIndex, result = 0;
char[] lpValueName;
byte[] lpData;
IntByReference lpcchValueName, lpType, lpcbData;
String name;
TreeMap values = new TreeMap(String.CASE_INSENSITIVE_ORDER);
- advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, key, WINNT.KEY_READ);
+ Advapi32 advapi32 = Advapi32.INSTANCE;
+ HKEY handle = openKey(rootKey, key, WinNT.KEY_READ);
lpValueName = new char[16384];
lpcchValueName = new IntByReference(16384);
lpType = new IntByReference();
lpData = new byte[1];
lpcbData = new IntByReference();
- if(handle != 0) {
- dwIndex = 0;
+ //if(handle != 0) {
+ if (handle != null) {
+ int dwIndex = 0;
+ int result = 0;
do {
lpcbData.setValue(0);
result = advapi32.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null,
lpType, lpData, lpcbData);
- if(result == WINERROR.ERROR_MORE_DATA) {
+ if (result == WinError.ERROR_MORE_DATA) {
lpData = new byte[lpcbData.getValue()];
lpcchValueName = new IntByReference(16384);
result = advapi32.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null,
lpType, lpData, lpcbData);
- if(result == WINERROR.ERROR_SUCCESS) {
+ if (result == WinError.ERROR_SUCCESS) {
name = new String(lpValueName, 0, lpcchValueName.getValue());
switch(lpType.getValue()) {
- case WINNT.REG_SZ:
+ case WinNT.REG_SZ:
values.put(name, convertBufferToString(lpData));
break;
- case WINNT.REG_DWORD:
+ case WinNT.REG_DWORD:
values.put(name, convertBufferToInt(lpData));
break;
default:
@@ -438,10 +481,10 @@ public class Registry {
}
}
dwIndex++;
- } while(result == WINERROR.ERROR_SUCCESS);
+ } while (result == WinError.ERROR_SUCCESS);
advapi32.RegCloseKey(handle);
}
- return(values);
+ return values;
}
}
diff --git a/app/src/processing/app/windows/WINBASE.java b/app/src/processing/app/windows/WINBASE.java
deleted file mode 100644
index c4807cc90..000000000
--- a/app/src/processing/app/windows/WINBASE.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * WINBASE.java
- *
- * Created on 5. September 2007, 11:24
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-import com.sun.jna.Pointer;
-import com.sun.jna.Structure;
-
-/**
- *
- * @author TB
- */
-public interface WINBASE {
-/*
-typedef struct _SECURITY_ATTRIBUTES {
- DWORD nLength;
- LPVOID lpSecurityDescriptor;
- BOOL bInheritHandle;
-} SECURITY_ATTRIBUTES,
- *PSECURITY_ATTRIBUTES,
- *LPSECURITY_ATTRIBUTES;*/
- public static class SECURITY_ATTRIBUTES extends Structure {
- public int nLength;
- public Pointer lpSecurityDescriptor;
- public boolean bInheritHandle;
- }
-
-/*
-typedef struct _FILETIME {
- DWORD dwLowDateTime;
- DWORD dwHighDateTime;
-} FILETIME, *PFILETIME, *LPFILETIME;*/
- public static class FILETIME extends Structure {
- public int dwLowDateTime;
- public int dwHighDateTime;
- }
-}
diff --git a/app/src/processing/app/windows/WINERROR.java b/app/src/processing/app/windows/WINERROR.java
deleted file mode 100644
index 3e1146e93..000000000
--- a/app/src/processing/app/windows/WINERROR.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * WINERROR.java
- *
- * Created on 7. August 2007, 08:09
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-
-/**
- *
- * @author TB
- */
-public interface WINERROR {
- public final static int ERROR_SUCCESS = 0;
- public final static int NO_ERROR = 0;
- public final static int ERROR_FILE_NOT_FOUND = 2;
- public final static int ERROR_MORE_DATA = 234;
-}
diff --git a/app/src/processing/app/windows/WINNT.java b/app/src/processing/app/windows/WINNT.java
deleted file mode 100644
index 89aa36168..000000000
--- a/app/src/processing/app/windows/WINNT.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * WINNT.java
- *
- * Created on 8. August 2007, 13:41
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-/**
- *
- * @author TB
- */
-public interface WINNT {
- public final static int DELETE = 0x00010000;
- public final static int READ_CONTROL = 0x00020000;
- public final static int WRITE_DAC = 0x00040000;
- public final static int WRITE_OWNER = 0x00080000;
- public final static int SYNCHRONIZE = 0x00100000;
-
- public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
-
- public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
- public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
- public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
-
- public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
-
- public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
-
- public final static int GENERIC_EXECUTE = 0x20000000;
-
- public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
-
- public final static int KEY_QUERY_VALUE = 0x0001;
- public final static int KEY_SET_VALUE = 0x0002;
- public final static int KEY_CREATE_SUB_KEY = 0x0004;
- public final static int KEY_ENUMERATE_SUB_KEYS = 0x0008;
- public final static int KEY_NOTIFY = 0x0010;
- public final static int KEY_CREATE_LINK = 0x0020;
-
- public final static int KEY_READ = ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE));
- public final static int KEY_WRITE = ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE));
-
- public final static int REG_NONE = 0; // No value type
- public final static int REG_SZ = 1; // Unicode nul terminated string
- public final static int REG_EXPAND_SZ = 2; // Unicode nul terminated string
- // (with environment variable references)
- public final static int REG_BINARY = 3; // Free form binary
- public final static int REG_DWORD = 4; // 32-bit number
- public final static int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD)
- public final static int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number
- public final static int REG_LINK = 6; // Symbolic Link (unicode)
- public final static int REG_MULTI_SZ = 7; // Multiple Unicode strings
- public final static int REG_RESOURCE_LIST = 8; // Resource list in the resource map
- public final static int REG_FULL_RESOURCE_DESCRIPTOR = 9; // Resource list in the hardware description
- public final static int REG_RESOURCE_REQUIREMENTS_LIST = 10;
-
- public final static int REG_OPTION_RESERVED = 0x00000000; // Parameter is reserved
- public final static int REG_OPTION_NON_VOLATILE = 0x00000000; // Key is preserved
- // when system is rebooted
- public final static int REG_OPTION_VOLATILE = 0x00000001; // Key is not preserved
- // when system is rebooted
- public final static int REG_OPTION_CREATE_LINK = 0x00000002; // Created key is a
- // symbolic link
- public final static int REG_OPTION_BACKUP_RESTORE = 0x00000004; // open for backup or restore
- // special access rules
- // privilege required
- public final static int REG_OPTION_OPEN_LINK = 0x00000008; // Open symbolic link
-
-}
diff --git a/app/src/processing/app/windows/WINREG.java b/app/src/processing/app/windows/WINREG.java
deleted file mode 100644
index 988f7ef36..000000000
--- a/app/src/processing/app/windows/WINREG.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * WINREG.java
- *
- * Created on 17. August 2007, 14:32
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-/**
- *
- * @author TB
- */
-public interface WINREG {
- public final static int HKEY_CLASSES_ROOT = 0x80000000;
- public final static int HKEY_CURRENT_USER = 0x80000001;
- public final static int HKEY_LOCAL_MACHINE = 0x80000002;
- public final static int HKEY_USERS = 0x80000003;
-}
diff --git a/core/todo.txt b/core/todo.txt
index a0f15a529..59562aa52 100644
--- a/core/todo.txt
+++ b/core/todo.txt
@@ -11,11 +11,14 @@ X https://github.com/processing/processing/issues/1959
X turns out this is an apple.awt tweak for the exported Info.plist
X getSubset() broken in IntList, StringList, and missing from FloatList
X https://github.com/processing/processing/issues/1979
-X Present Mode trouble on Windows 7 (64-bit) completely broken
+X Present Mode does not work properly on Windows
X https://github.com/processing/processing/issues/1955
-
+_
_ retain blendMode() between frames (get bug #)
+_ this should actually be in the code..
+_ maybe not working on OS X/retina?
+_ perhaps it's a getGraphics() issue?
andres
X pixels[] array not updated with Capture and P2D/P3D
diff --git a/todo.txt b/todo.txt
index 49d968ace..a66bec76c 100644
--- a/todo.txt
+++ b/todo.txt
@@ -24,25 +24,50 @@ manager
X check to see if manager items from the download can be updated
X oops, probably not, because they're part of the distribution
X and folks won't be able to write to those directories
-_ libraries need to support multiple categories
-_ https://github.com/processing/processing/issues/1970
+X changed manager to go to download.processing.org/latest.txt
+X and uses a redirect from there (hopeully that's followed?)
+X libraries need to support multiple categories
+X https://github.com/processing/processing/issues/1970
+
+_ we shouldn't use .properties for modes et al
+_ because a .properties file is iso8859-1
+_ remove "Compilations" category for libraries
+_ make note that .properties file *must* be utf-8
+_ if not it'll make things gross (andre sier flob library)
+_ restrict library categories to the ones in the document
+_ if it's not correct, shows up as 'other'
+_ argh.. the 'old' folder is really poorly done
+_ attempt to install multiple will cause havoc (fail because 'old' exists)
+_ modes and tools require restart (per ContributionType class)
+_ but no message is provided anywhere?
+_ why wasn't Library moved to LibraryContribution?
_ send info on 'check for updates' so we know about libs/modes/etc?
_ how to disclose to users?
_ only send for items that are part of the public list
_ otherwise we're sending private libraries/installs
_ although this won't pick up old libraries not on the new system
_ half-installed mode causes a lot of trouble
+_ maybe it's reading from tmp folders?
_ https://github.com/processing/processing/issues/1875
_ mode install requires restart *and* still doesn't show as installed
_ even though it gets added to the modes menu properly after the restart
_ https://github.com/processing/processing/issues/1782
_ classpath conflicts..
+_ getPackageList.. from Library... maybe others?
_ really need to make sure that a weird core.jar isn't being imported
_ coffeescript was doing this and breaking the pde
_ init() not called on tools until later
_ https://github.com/processing/processing/issues/1859
+_ contrib library examples are not read-only
+_ another point for doing .zip files to prevent overwriting
+_ add BookContribution?
+_ will offer to open the contrib manager even though it's already open
+_ though this was looking at libraries, and there may have been modes
+_ update only showing up when selected is awkward
+_ "update all" would be useful
high
+_ add .bat file to lib on windows so that we can get better debugging info
_ move old Google Code SVN back to processing.org
_ then cull out the old branches/tags from the Github repo
_ UnsatisfiedLinkError causes huge message...
From bae0c17cb18c962129248d7d34125acd2edbf972 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sat, 20 Jul 2013 22:22:46 -0400
Subject: [PATCH 090/400] remove more custom code
---
app/src/processing/app/Platform.java | 13 ++-
app/src/processing/app/macosx/Platform.java | 15 ++-
app/src/processing/app/windows/Platform.java | 101 +++++++++----------
3 files changed, 67 insertions(+), 62 deletions(-)
diff --git a/app/src/processing/app/Platform.java b/app/src/processing/app/Platform.java
index 8c71b3416..b4b07b2a7 100644
--- a/app/src/processing/app/Platform.java
+++ b/app/src/processing/app/Platform.java
@@ -31,6 +31,7 @@ import javax.swing.UIManager;
import com.sun.jna.Library;
import com.sun.jna.Native;
+import com.sun.jna.platform.FileUtils;
/**
@@ -152,13 +153,19 @@ public class Platform {
* @return true if the folder was successfully removed
* @throws IOException
*/
- public boolean deleteFile(File file) throws IOException {
- if (file.isDirectory()) {
+ final public boolean deleteFile(File file) throws IOException {
+ FileUtils fu = FileUtils.getInstance();
+ if (fu.hasTrash()) {
+ fu.moveToTrash(new File[] { file });
+ return true;
+
+ } else if (file.isDirectory()) {
Base.removeDir(file);
+ return true;
+
} else {
return file.delete();
}
- return true;
}
diff --git a/app/src/processing/app/macosx/Platform.java b/app/src/processing/app/macosx/Platform.java
index 8cc71a38d..c09f2b55a 100644
--- a/app/src/processing/app/macosx/Platform.java
+++ b/app/src/processing/app/macosx/Platform.java
@@ -24,7 +24,6 @@ package processing.app.macosx;
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.IOException;
import com.apple.eio.FileManager;
@@ -104,13 +103,13 @@ public class Platform extends processing.app.Platform {
}
- /**
- * Moves the specified File object (which might be a file or folder)
- * to the trash.
- */
- public boolean deleteFile(File file) throws IOException {
- return FileManager.moveToTrash(file);
- }
+// /**
+// * Moves the specified File object (which might be a file or folder)
+// * to the trash.
+// */
+// public boolean deleteFile(File file) throws IOException {
+// return FileManager.moveToTrash(file);
+// }
/*
diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java
index c5325fb17..a47662c38 100644
--- a/app/src/processing/app/windows/Platform.java
+++ b/app/src/processing/app/windows/Platform.java
@@ -28,11 +28,8 @@ import java.io.UnsupportedEncodingException;
import com.sun.jna.Library;
import com.sun.jna.Native;
-import com.sun.jna.WString;
import com.sun.jna.platform.win32.Kernel32Util;
import com.sun.jna.platform.win32.Shell32;
-import com.sun.jna.platform.win32.ShellAPI;
-import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT;
import com.sun.jna.platform.win32.ShlObj;
import com.sun.jna.platform.win32.WinDef;
import com.sun.jna.platform.win32.WinError;
@@ -74,15 +71,17 @@ public class Platform extends processing.app.Platform {
//checkQuickTime();
checkPath();
- /*
File f = new File("C:\\recycle-test.txt");
System.out.println(f.getAbsolutePath());
java.io.PrintWriter writer = PApplet.createWriter(f);
writer.println("blah");
writer.flush();
writer.close();
- deleteFile(f);
- */
+ try {
+ deleteFile(f);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
//findJDK();
/*
@@ -333,53 +332,53 @@ public class Platform extends processing.app.Platform {
}
- @Override
- public boolean deleteFile(File file) {
- try {
- moveToTrash(new File[] { file });
- } catch (IOException e) {
- e.printStackTrace();
- Base.log("Could not move " + file.getAbsolutePath() + " to the trash.", e);
- return false;
- }
- return true;
- }
+// @Override
+// public boolean deleteFile(File file) {
+// try {
+// moveToTrash(new File[] { file });
+// } catch (IOException e) {
+// e.printStackTrace();
+// Base.log("Could not move " + file.getAbsolutePath() + " to the trash.", e);
+// return false;
+// }
+// return true;
+// }
- /**
- * Move files/folders to the trash. If this file is on another file system
- * or on a shared network directory, it will simply be deleted without any
- * additional confirmation. Take that.
- *
- * Based on JNA source for com.sun.jna.platform.win32.W32FileUtils
- *
- * @param files array of File objects to be removed
- * @return true if no error codes returned
- * @throws IOException if something bad happened along the way
- */
- static private boolean moveToTrash(File[] files) throws IOException {
- Shell32 shell = Shell32.INSTANCE;
- SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
- fileop.wFunc = ShellAPI.FO_DELETE;
- String[] paths = new String[files.length];
- for (int i = 0; i < paths.length; i++) {
- paths[i] = files[i].getAbsolutePath();
- System.out.println(paths[i]);
- }
- fileop.pFrom = new WString(fileop.encodePaths(paths));
- fileop.fFlags = ShellAPI.FOF_ALLOWUNDO | ShellAPI.FOF_NO_UI;
- int ret = shell.SHFileOperation(fileop);
- if (ret != 0) {
- throw new IOException("Move to trash failed: " +
- fileop.pFrom + ": error code " + ret);
-// throw new IOException("Move to trash failed: " + fileop.pFrom + ": " +
-// Kernel32Util.formatMessageFromLastErrorCode(ret));
- }
- if (fileop.fAnyOperationsAborted) {
- throw new IOException("Move to trash aborted");
- }
- return true;
- }
+// /**
+// * Move files/folders to the trash. If this file is on another file system
+// * or on a shared network directory, it will simply be deleted without any
+// * additional confirmation. Take that.
+// *
+// * Based on JNA source for com.sun.jna.platform.win32.W32FileUtils
+// *
+// * @param files array of File objects to be removed
+// * @return true if no error codes returned
+// * @throws IOException if something bad happened along the way
+// */
+// static private boolean moveToTrash(File[] files) throws IOException {
+// Shell32 shell = Shell32.INSTANCE;
+// SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
+// fileop.wFunc = ShellAPI.FO_DELETE;
+// String[] paths = new String[files.length];
+// for (int i = 0; i < paths.length; i++) {
+// paths[i] = files[i].getAbsolutePath();
+// System.out.println(paths[i]);
+// }
+// fileop.pFrom = new WString(fileop.encodePaths(paths));
+// fileop.fFlags = ShellAPI.FOF_ALLOWUNDO | ShellAPI.FOF_NO_UI;
+// int ret = shell.SHFileOperation(fileop);
+// if (ret != 0) {
+// throw new IOException("Move to trash failed: " +
+// fileop.pFrom + ": error code " + ret);
+//// throw new IOException("Move to trash failed: " + fileop.pFrom + ": " +
+//// Kernel32Util.formatMessageFromLastErrorCode(ret));
+// }
+// if (fileop.fAnyOperationsAborted) {
+// throw new IOException("Move to trash aborted");
+// }
+// return true;
+// }
// /**
From 9ecc1ed5a71699315b5f2a7d629ef424c57df18d Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 01:14:22 -0400
Subject: [PATCH 091/400] foiled again on the reg keys, back at it
---
app/src/processing/app/windows/Platform.java | 110 ++++++++++---------
todo.txt | 17 +--
2 files changed, 68 insertions(+), 59 deletions(-)
diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java
index a47662c38..2424a2e29 100644
--- a/app/src/processing/app/windows/Platform.java
+++ b/app/src/processing/app/windows/Platform.java
@@ -6,8 +6,8 @@
Copyright (c) 2012-2013 The Processing Foundation
Copyright (c) 2008-2012 Ben Fry and Casey Reas
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
@@ -43,25 +43,25 @@ import processing.core.PApplet;
/**
* Platform-specific glue for Windows.
- *
+ *
* This is a bit of a hodgepodge of JNA examples and StackOverflow answers,
- * and as a result, is not the prettiest piece of code in this code base.
- * In fact, an honest man might call it ugly.
- *
- * Classes like Advapi32, WINNT, etc could be removed in favor of the
- * jna-platform.jar, but that would require 1) some cleanup and extensive
- * testing (across Windows XP, 7, and 8) to make sure everything was still
+ * and as a result, is not the prettiest piece of code in this code base.
+ * In fact, an honest man might call it ugly.
+ *
+ * Classes like Advapi32, WINNT, etc could be removed in favor of the
+ * jna-platform.jar, but that would require 1) some cleanup and extensive
+ * testing (across Windows XP, 7, and 8) to make sure everything was still
* working. It would also require adding the new .jar file, and making sure
- * that it was included with the distribution across all of the platforms.
+ * that it was included with the distribution across all of the platforms.
*/
public class Platform extends processing.app.Platform {
-
+
static final String openCommand =
System.getProperty("user.dir").replace('/', '\\') +
"\\processing.exe \"%1\"";
static final String DOC = "Processing.Document";
// static final String DOC = "Processing.exe";
-
+
static final String APP_NAME = "Processing";
@@ -82,7 +82,7 @@ public class Platform extends processing.app.Platform {
} catch (IOException e) {
e.printStackTrace();
}
-
+
//findJDK();
/*
new Thread(new Runnable() {
@@ -141,13 +141,6 @@ public class Platform extends processing.app.Platform {
* Make sure that .pde files are associated with processing.exe.
*/
protected void checkAssociations() {
-// HKEY_CLASSES_ROOT
-// MyProgram.exe
-// shell
-// open
-// command
-// (Default) = C:\MyDir\MyProgram.exe "%1"
-
try {
String knownCommand =
Registry.getStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
@@ -173,6 +166,19 @@ public class Platform extends processing.app.Platform {
* Associate .pde files with this version of Processing.
*/
protected void setAssociations() throws UnsupportedEncodingException {
+ // http://support.microsoft.com/kb/184082
+ // http://msdn.microsoft.com/en-us/library/cc144175%28v=VS.85%29.aspx
+ // http://msdn.microsoft.com/en-us/library/cc144104%28v=VS.85%29.aspx
+ // http://msdn.microsoft.com/en-us/library/cc144067%28v=VS.85%29.aspx
+ // msdn.microsoft.com/en-us/library/windows/desktop/ms724475(v=vs.85).aspx
+
+// HKEY_CLASSES_ROOT
+// MyProgram.exe
+// shell
+// open
+// command
+// (Default) = C:\MyDir\MyProgram.exe "%1"
+
if (Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
"", ".pde") &&
Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
@@ -243,8 +249,8 @@ public class Platform extends processing.app.Platform {
}
return null;
}
-
-
+
+
static private String getAppDataPath() throws Exception {
// HKEY_CURRENT_USER\Software\Microsoft
// \Windows\CurrentVersion\Explorer\Shell Folders
@@ -263,10 +269,10 @@ public class Platform extends processing.app.Platform {
// Using JNA and SHGetFolderPath instead.
// this will be contain the path if SHGetFolderPath is successful
- char[] pszPath = new char[WinDef.MAX_PATH];
- HRESULT hResult =
- Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_APPDATA,
- null, ShlObj.SHGFP_TYPE_CURRENT,
+ char[] pszPath = new char[WinDef.MAX_PATH];
+ HRESULT hResult =
+ Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_APPDATA,
+ null, ShlObj.SHGFP_TYPE_CURRENT,
pszPath);
if (!hResult.equals(WinError.S_OK)) {
@@ -291,7 +297,7 @@ public class Platform extends processing.app.Platform {
return null;
}
-
+
static private String getDocumentsPath() throws Exception {
// http://support.microsoft.com/?kbid=221837&sd=RMVP
// http://support.microsoft.com/kb/242557/en-us
@@ -330,8 +336,8 @@ public class Platform extends processing.app.Platform {
// return new File(personalPath, "Processing");
return personalPath.substring(0, len);
}
-
-
+
+
// @Override
// public boolean deleteFile(File file) {
// try {
@@ -343,15 +349,15 @@ public class Platform extends processing.app.Platform {
// }
// return true;
// }
-
-
-// /**
+
+
+// /**
// * Move files/folders to the trash. If this file is on another file system
-// * or on a shared network directory, it will simply be deleted without any
+// * or on a shared network directory, it will simply be deleted without any
// * additional confirmation. Take that.
// *
// * Based on JNA source for com.sun.jna.platform.win32.W32FileUtils
-// *
+// *
// * @param files array of File objects to be removed
// * @return true if no error codes returned
// * @throws IOException if something bad happened along the way
@@ -369,9 +375,9 @@ public class Platform extends processing.app.Platform {
// fileop.fFlags = ShellAPI.FOF_ALLOWUNDO | ShellAPI.FOF_NO_UI;
// int ret = shell.SHFileOperation(fileop);
// if (ret != 0) {
-// throw new IOException("Move to trash failed: " +
+// throw new IOException("Move to trash failed: " +
// fileop.pFrom + ": error code " + ret);
-//// throw new IOException("Move to trash failed: " + fileop.pFrom + ": " +
+//// throw new IOException("Move to trash failed: " + fileop.pFrom + ": " +
//// Kernel32Util.formatMessageFromLastErrorCode(ret));
// }
// if (fileop.fAnyOperationsAborted) {
@@ -379,23 +385,23 @@ public class Platform extends processing.app.Platform {
// }
// return true;
// }
-
-
+
+
// /**
// * Ported from ShellAPI.h in the Microsoft Windows SDK 6.0A.
-// * Modified (bastardized) version from the JNA "platform" classes.
+// * Modified (bastardized) version from the JNA "platform" classes.
// * @author dblock[at]dblock.org
// */
// public interface ShellAPI extends StdCallLibrary {
//
-// int STRUCTURE_ALIGNMENT = com.sun.jna.Platform.is64Bit() ?
+// int STRUCTURE_ALIGNMENT = com.sun.jna.Platform.is64Bit() ?
// Structure.ALIGN_DEFAULT : Structure.ALIGN_NONE;
-//
+//
// int FO_MOVE = 0x0001;
// int FO_COPY = 0x0002;
// int FO_DELETE = 0x0003;
// int FO_RENAME = 0x0004;
-//
+//
// int FOF_MULTIDESTFILES = 0x0001;
// int FOF_CONFIRMMOUSE = 0x0002;
// int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still)
@@ -413,13 +419,13 @@ public class Platform extends processing.app.Platform {
// int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
// int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts)
// int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all
-//
+//
// int PO_DELETE = 0x0013; // printer is being deleted
// int PO_RENAME = 0x0014; // printer is being renamed
// int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed
// int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time.
// }
-
+
/*
public void openURL(String url) throws Exception {
@@ -506,7 +512,7 @@ public class Platform extends processing.app.Platform {
return clib._putenv(variable + "=");
}
-
+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
// JNA code for using SHGetFolderPath to fix Issue 410
@@ -521,14 +527,14 @@ public class Platform extends processing.app.Platform {
// OPTIONS.put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
// }
//
-//
-// static class HANDLE extends PointerType implements NativeMapped {
+//
+// static class HANDLE extends PointerType implements NativeMapped {
// public HANDLE() { }
// }
//
// static class HWND extends HANDLE { }
//
-//
+//
// public interface Shell32 extends Library {
//
// public static final int MAX_PATH = 260;
@@ -551,12 +557,12 @@ public class Platform extends processing.app.Platform {
// */
// public int SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken,
// int dwFlags, char[] pszPath);
-//
+//
// /**
-// * This function can be used to copy, move, rename,
+// * This function can be used to copy, move, rename,
// * or delete a file system object.
-// * @param fileop Address of an SHFILEOPSTRUCT structure that contains
-// * information this function needs to carry out the specified operation.
+// * @param fileop Address of an SHFILEOPSTRUCT structure that contains
+// * information this function needs to carry out the specified operation.
// * @return Returns zero if successful, or nonzero otherwise.
// */
// public int SHFileOperation(SHFILEOPSTRUCT fileop);
diff --git a/todo.txt b/todo.txt
index a66bec76c..1f9d1818d 100644
--- a/todo.txt
+++ b/todo.txt
@@ -14,6 +14,14 @@ X code with a NUL character causes an error
X https://github.com/processing/processing/issues/1973
X Add "Processing Foundation" to the Help menu
X https://github.com/processing/processing/issues/1908
+X Update JNA from 3.2.4 to 3.5.2
+X https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/3.5.2/jna-3.5.2.jar
+X https://maven.java.net/content/repositories/releases/net/java/dev/jna/platform/3.5.2/platform-3.5.2.jar
+X problem with associating .pde files
+_ https://github.com/processing/processing/issues/286
+X http://code.google.com/p/processing/issues/detail?id=247
+o In regedit: Navigate to Computer\HKEY_CLASSES_ROOT\Applications and find your .exe name. Navigate under its name to shell>open>command. In the Default change its location to the actual location of the executable, hit okay and then try and reassociate the file type as you normally would.
+X Add methods to move files to Trash/Recycle Bin where available
cleaning/earlier
X common error messages
@@ -827,20 +835,15 @@ _ https://github.com/processing/processing/issues/1633
_ updated launch4j 3.1 beta
_ http://sourceforge.net/projects/launch4j/files/launch4j-3/
_ does launching p5 from inside the .zip folder cause it to quit immediately?
+_ how can we provide an error message here?
_ exe instead of bat to make exported apps run in 64-bit
_ http://code.google.com/p/processing/issues/detail?id=885
_ might not be necessary with new launch4j!
_ how to handle double-clicked files on windows?
_ big deal for psk and others
+_ this may already work with SingleInstance stuff
_ Update Windows icons for multiple sizes, implement them in the PDE
_ http://code.google.com/p/processing/issues/detail?id=632
-_ problem with associating .pde files
-_ http://code.google.com/p/processing/issues/detail?id=247
-_ http://support.microsoft.com/kb/184082
-_ http://msdn.microsoft.com/en-us/library/cc144175%28v=VS.85%29.aspx
-_ http://msdn.microsoft.com/en-us/library/cc144104%28v=VS.85%29.aspx
-_ http://msdn.microsoft.com/en-us/library/cc144067%28v=VS.85%29.aspx
-_ In regedit: Navigate to Computer\HKEY_CLASSES_ROOT\Applications and find your .exe name. Navigate under its name to shell>open>command. In the Default change its location to the actual location of the executable, hit okay and then try and reassociate the file type as you normally would.
DIST / Mac OS X
From 2f3758f6a6269ca8d8892155930793def54b0448 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 01:17:12 -0400
Subject: [PATCH 092/400] debugging Windows 7 issues
---
app/src/processing/app/windows/Platform.java | 93 ++++++++++----------
1 file changed, 47 insertions(+), 46 deletions(-)
mode change 100644 => 100755 app/src/processing/app/windows/Platform.java
diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java
old mode 100644
new mode 100755
index a47662c38..25fb666fc
--- a/app/src/processing/app/windows/Platform.java
+++ b/app/src/processing/app/windows/Platform.java
@@ -6,8 +6,8 @@
Copyright (c) 2012-2013 The Processing Foundation
Copyright (c) 2008-2012 Ben Fry and Casey Reas
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
@@ -43,25 +43,25 @@ import processing.core.PApplet;
/**
* Platform-specific glue for Windows.
- *
+ *
* This is a bit of a hodgepodge of JNA examples and StackOverflow answers,
- * and as a result, is not the prettiest piece of code in this code base.
- * In fact, an honest man might call it ugly.
- *
- * Classes like Advapi32, WINNT, etc could be removed in favor of the
- * jna-platform.jar, but that would require 1) some cleanup and extensive
- * testing (across Windows XP, 7, and 8) to make sure everything was still
+ * and as a result, is not the prettiest piece of code in this code base.
+ * In fact, an honest man might call it ugly.
+ *
+ * Classes like Advapi32, WINNT, etc could be removed in favor of the
+ * jna-platform.jar, but that would require 1) some cleanup and extensive
+ * testing (across Windows XP, 7, and 8) to make sure everything was still
* working. It would also require adding the new .jar file, and making sure
- * that it was included with the distribution across all of the platforms.
+ * that it was included with the distribution across all of the platforms.
*/
public class Platform extends processing.app.Platform {
-
+
static final String openCommand =
System.getProperty("user.dir").replace('/', '\\') +
"\\processing.exe \"%1\"";
static final String DOC = "Processing.Document";
// static final String DOC = "Processing.exe";
-
+
static final String APP_NAME = "Processing";
@@ -71,7 +71,8 @@ public class Platform extends processing.app.Platform {
//checkQuickTime();
checkPath();
- File f = new File("C:\\recycle-test.txt");
+ File f = new File(System.getProperty("user.dir"), "recycle-test.txt");
+ //File f = new File("C:\\recycle-test.txt");
System.out.println(f.getAbsolutePath());
java.io.PrintWriter writer = PApplet.createWriter(f);
writer.println("blah");
@@ -82,7 +83,7 @@ public class Platform extends processing.app.Platform {
} catch (IOException e) {
e.printStackTrace();
}
-
+
//findJDK();
/*
new Thread(new Runnable() {
@@ -243,8 +244,8 @@ public class Platform extends processing.app.Platform {
}
return null;
}
-
-
+
+
static private String getAppDataPath() throws Exception {
// HKEY_CURRENT_USER\Software\Microsoft
// \Windows\CurrentVersion\Explorer\Shell Folders
@@ -263,10 +264,10 @@ public class Platform extends processing.app.Platform {
// Using JNA and SHGetFolderPath instead.
// this will be contain the path if SHGetFolderPath is successful
- char[] pszPath = new char[WinDef.MAX_PATH];
- HRESULT hResult =
- Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_APPDATA,
- null, ShlObj.SHGFP_TYPE_CURRENT,
+ char[] pszPath = new char[WinDef.MAX_PATH];
+ HRESULT hResult =
+ Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_APPDATA,
+ null, ShlObj.SHGFP_TYPE_CURRENT,
pszPath);
if (!hResult.equals(WinError.S_OK)) {
@@ -291,7 +292,7 @@ public class Platform extends processing.app.Platform {
return null;
}
-
+
static private String getDocumentsPath() throws Exception {
// http://support.microsoft.com/?kbid=221837&sd=RMVP
// http://support.microsoft.com/kb/242557/en-us
@@ -330,8 +331,8 @@ public class Platform extends processing.app.Platform {
// return new File(personalPath, "Processing");
return personalPath.substring(0, len);
}
-
-
+
+
// @Override
// public boolean deleteFile(File file) {
// try {
@@ -343,15 +344,15 @@ public class Platform extends processing.app.Platform {
// }
// return true;
// }
-
-
-// /**
+
+
+// /**
// * Move files/folders to the trash. If this file is on another file system
-// * or on a shared network directory, it will simply be deleted without any
+// * or on a shared network directory, it will simply be deleted without any
// * additional confirmation. Take that.
// *
// * Based on JNA source for com.sun.jna.platform.win32.W32FileUtils
-// *
+// *
// * @param files array of File objects to be removed
// * @return true if no error codes returned
// * @throws IOException if something bad happened along the way
@@ -369,9 +370,9 @@ public class Platform extends processing.app.Platform {
// fileop.fFlags = ShellAPI.FOF_ALLOWUNDO | ShellAPI.FOF_NO_UI;
// int ret = shell.SHFileOperation(fileop);
// if (ret != 0) {
-// throw new IOException("Move to trash failed: " +
+// throw new IOException("Move to trash failed: " +
// fileop.pFrom + ": error code " + ret);
-//// throw new IOException("Move to trash failed: " + fileop.pFrom + ": " +
+//// throw new IOException("Move to trash failed: " + fileop.pFrom + ": " +
//// Kernel32Util.formatMessageFromLastErrorCode(ret));
// }
// if (fileop.fAnyOperationsAborted) {
@@ -379,23 +380,23 @@ public class Platform extends processing.app.Platform {
// }
// return true;
// }
-
-
+
+
// /**
// * Ported from ShellAPI.h in the Microsoft Windows SDK 6.0A.
-// * Modified (bastardized) version from the JNA "platform" classes.
+// * Modified (bastardized) version from the JNA "platform" classes.
// * @author dblock[at]dblock.org
// */
// public interface ShellAPI extends StdCallLibrary {
//
-// int STRUCTURE_ALIGNMENT = com.sun.jna.Platform.is64Bit() ?
+// int STRUCTURE_ALIGNMENT = com.sun.jna.Platform.is64Bit() ?
// Structure.ALIGN_DEFAULT : Structure.ALIGN_NONE;
-//
+//
// int FO_MOVE = 0x0001;
// int FO_COPY = 0x0002;
// int FO_DELETE = 0x0003;
// int FO_RENAME = 0x0004;
-//
+//
// int FOF_MULTIDESTFILES = 0x0001;
// int FOF_CONFIRMMOUSE = 0x0002;
// int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still)
@@ -413,13 +414,13 @@ public class Platform extends processing.app.Platform {
// int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
// int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts)
// int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all
-//
+//
// int PO_DELETE = 0x0013; // printer is being deleted
// int PO_RENAME = 0x0014; // printer is being renamed
// int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed
// int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time.
// }
-
+
/*
public void openURL(String url) throws Exception {
@@ -506,7 +507,7 @@ public class Platform extends processing.app.Platform {
return clib._putenv(variable + "=");
}
-
+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
// JNA code for using SHGetFolderPath to fix Issue 410
@@ -521,14 +522,14 @@ public class Platform extends processing.app.Platform {
// OPTIONS.put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
// }
//
-//
-// static class HANDLE extends PointerType implements NativeMapped {
+//
+// static class HANDLE extends PointerType implements NativeMapped {
// public HANDLE() { }
// }
//
// static class HWND extends HANDLE { }
//
-//
+//
// public interface Shell32 extends Library {
//
// public static final int MAX_PATH = 260;
@@ -551,12 +552,12 @@ public class Platform extends processing.app.Platform {
// */
// public int SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken,
// int dwFlags, char[] pszPath);
-//
+//
// /**
-// * This function can be used to copy, move, rename,
+// * This function can be used to copy, move, rename,
// * or delete a file system object.
-// * @param fileop Address of an SHFILEOPSTRUCT structure that contains
-// * information this function needs to carry out the specified operation.
+// * @param fileop Address of an SHFILEOPSTRUCT structure that contains
+// * information this function needs to carry out the specified operation.
// * @return Returns zero if successful, or nonzero otherwise.
// */
// public int SHFileOperation(SHFILEOPSTRUCT fileop);
From 74c652b59344399b6932349a62b44d1e97c7ff5a Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 01:30:08 -0400
Subject: [PATCH 093/400] this isn't going to work with eclipse
---
app/src/processing/app/windows/Platform.java | 3 +++
app/src/processing/app/windows/Registry.java | 4 +++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java
index a029aa25e..a2eeade81 100755
--- a/app/src/processing/app/windows/Platform.java
+++ b/app/src/processing/app/windows/Platform.java
@@ -179,6 +179,9 @@ public class Platform extends processing.app.Platform {
// open
// command
// (Default) = C:\MyDir\MyProgram.exe "%1"
+
+ REGISTRY_ROOT_KEY rootKey = REGISTRY_ROOT_KEY.CLASSES_ROOT;
+ String parentKey = "";
if (Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
"", ".pde") &&
diff --git a/app/src/processing/app/windows/Registry.java b/app/src/processing/app/windows/Registry.java
index 5509ca481..11f78980a 100644
--- a/app/src/processing/app/windows/Registry.java
+++ b/app/src/processing/app/windows/Registry.java
@@ -23,7 +23,9 @@ import com.sun.jna.ptr.IntByReference;
* 20 July 2013 to make updates for use with JNA 3.5.2's platform classes.
*/
public class Registry {
- static public enum REGISTRY_ROOT_KEY{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, USERS};
+ static public enum REGISTRY_ROOT_KEY {
+ CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, USERS
+ };
//private final static HashMap rootKeyMap = new HashMap();
private final static HashMap rootKeyMap =
new HashMap();
From c52cb2147b17ef28dc00b0333cecb4431e51bce4 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 02:09:54 -0400
Subject: [PATCH 094/400] fixing up and finishing the Windows reg issues
---
app/src/processing/app/windows/Platform.java | 91 +++++++++++---------
1 file changed, 50 insertions(+), 41 deletions(-)
diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java
index a2eeade81..8cb6403e4 100755
--- a/app/src/processing/app/windows/Platform.java
+++ b/app/src/processing/app/windows/Platform.java
@@ -42,27 +42,16 @@ import processing.core.PApplet;
/**
- * Platform-specific glue for Windows.
+ * Platform-specific glue for Windows.
*
- * This is a bit of a hodgepodge of JNA examples and StackOverflow answers,
- * and as a result, is not the prettiest piece of code in this code base.
- * In fact, an honest man might call it ugly.
- *
- * Classes like Advapi32, WINNT, etc could be removed in favor of the
- * jna-platform.jar, but that would require 1) some cleanup and extensive
- * testing (across Windows XP, 7, and 8) to make sure everything was still
- * working. It would also require adding the new .jar file, and making sure
- * that it was included with the distribution across all of the platforms.
*/
public class Platform extends processing.app.Platform {
- static final String openCommand =
- System.getProperty("user.dir").replace('/', '\\') +
- "\\processing.exe \"%1\"";
- static final String DOC = "Processing.Document";
-// static final String DOC = "Processing.exe";
-
static final String APP_NAME = "Processing";
+ static final String REG_OPEN_COMMAND =
+ System.getProperty("user.dir").replace('/', '\\') +
+ "\\" + APP_NAME.toLowerCase() + ".exe \"%1\"";
+ static final String REG_DOC = APP_NAME + ".Document";
public void init(Base base) {
@@ -143,17 +132,13 @@ public class Platform extends processing.app.Platform {
*/
protected void checkAssociations() {
try {
- String knownCommand =
- Registry.getStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
- DOC + "\\shell\\open\\command", "");
- if (knownCommand == null) {
- if (Preferences.getBoolean("platform.auto_file_type_associations")) {
- setAssociations();
- }
-
- } else if (!knownCommand.equals(openCommand)) {
- // If the value is set differently, just change the registry setting.
- if (Preferences.getBoolean("platform.auto_file_type_associations")) {
+ if (Preferences.getBoolean("platform.auto_file_type_associations")) {
+ // Check the key that should be set by a previous run of Processing
+ String knownCommand =
+ Registry.getStringValue(REGISTRY_ROOT_KEY.CURRENT_USER,
+ "Software\\Classes\\" + REG_DOC + "\\shell\\open\\command", "");
+ // If the association hasn't been set, or it's not correct, set it.
+ if (knownCommand == null || !knownCommand.equals(REG_OPEN_COMMAND)) {
setAssociations();
}
}
@@ -164,7 +149,9 @@ public class Platform extends processing.app.Platform {
/**
- * Associate .pde files with this version of Processing.
+ * Associate .pde files with this version of Processing. After 2.0.1,
+ * this was changed to only set the values for the current user, so that
+ * it would no longer silently fail on systems that have UAC turned on.
*/
protected void setAssociations() throws UnsupportedEncodingException {
// http://support.microsoft.com/kb/184082
@@ -179,37 +166,59 @@ public class Platform extends processing.app.Platform {
// open
// command
// (Default) = C:\MyDir\MyProgram.exe "%1"
-
- REGISTRY_ROOT_KEY rootKey = REGISTRY_ROOT_KEY.CLASSES_ROOT;
- String parentKey = "";
- if (Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
+/*
+ REGISTRY_ROOT_KEY rootKey = REGISTRY_ROOT_KEY.CLASSES_ROOT;
+ if (Registry.createKey(rootKey,
"", ".pde") &&
- Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
+ Registry.setStringValue(rootKey,
".pde", "", DOC) &&
- Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT, "", DOC) &&
- Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT, DOC, "",
+ Registry.createKey(rootKey, "", DOC) &&
+ Registry.setStringValue(rootKey, DOC, "",
"Processing Source Code") &&
- Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
+ Registry.createKey(rootKey,
DOC, "shell") &&
- Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
+ Registry.createKey(rootKey,
DOC + "\\shell", "open") &&
- Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
+ Registry.createKey(rootKey,
DOC + "\\shell\\open", "command") &&
- Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
+ Registry.setStringValue(rootKey,
DOC + "\\shell\\open\\command", "",
openCommand)) {
+*/
+
+ // "To change the settings for the interactive user, store the changes
+ // under HKEY_CURRENT_USER\Software\Classes rather than HKEY_CLASSES_ROOT."
+ // msdn.microsoft.com/en-us/library/windows/desktop/ms724475(v=vs.85).aspx
+ final REGISTRY_ROOT_KEY rootKey = REGISTRY_ROOT_KEY.CURRENT_USER;
+ final String docPrefix = "Software\\Classes\\" + REG_DOC;
+
+ // First create the .pde association
+ if (Registry.createKey(rootKey, "Software\\Classes", ".pde") &&
+ Registry.setStringValue(rootKey, "Software\\Classes\\.pde", "", REG_DOC) &&
+
+ // Now give files with a .pde extension a name for the explorer
+ Registry.createKey(rootKey, "Software\\Classes", REG_DOC) &&
+ Registry.setStringValue(rootKey, docPrefix, "", APP_NAME + " Source Code") &&
+
+ // Now associate the 'open' command with the current processing.exe
+ Registry.createKey(rootKey, docPrefix, "shell") &&
+ Registry.createKey(rootKey, docPrefix + "\\shell", "open") &&
+ Registry.createKey(rootKey, docPrefix + "\\shell\\open", "command") &&
+ Registry.setStringValue(rootKey, docPrefix + "\\shell\\open\\command", "", REG_OPEN_COMMAND)) {
+
// everything ok
// hooray!
} else {
+ Base.log("Could not associate files, turning off auto-associate pref.");
Preferences.setBoolean("platform.auto_file_type_associations", false);
}
}
-
-
+
+
/**
* Remove extra quotes, slashes, and garbage from the Windows PATH.
*/
From 37bdc7a40a6e2b88be9e09abd2c492988e59cca2 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 02:14:51 -0400
Subject: [PATCH 095/400] todo notes/organizing
---
todo.txt | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/todo.txt b/todo.txt
index 1f9d1818d..9e9296af2 100644
--- a/todo.txt
+++ b/todo.txt
@@ -18,15 +18,22 @@ X Update JNA from 3.2.4 to 3.5.2
X https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/3.5.2/jna-3.5.2.jar
X https://maven.java.net/content/repositories/releases/net/java/dev/jna/platform/3.5.2/platform-3.5.2.jar
X problem with associating .pde files
-_ https://github.com/processing/processing/issues/286
+X https://github.com/processing/processing/issues/286
X http://code.google.com/p/processing/issues/detail?id=247
o In regedit: Navigate to Computer\HKEY_CLASSES_ROOT\Applications and find your .exe name. Navigate under its name to shell>open>command. In the Default change its location to the actual location of the executable, hit okay and then try and reassociate the file type as you normally would.
X Add methods to move files to Trash/Recycle Bin where available
+X UnsatisfiedLinkError causes huge message...
+X error report cleanups haven't been fixed yet
+X reported by Dan
+X this should be better now
cleaning/earlier
X common error messages
X with a proper list, we can add links when throwing an error in the PDE
X Dan started this on the Wiki
+o build is currently broken for fresh checkout due to changes to file layout
+o something that gets fixed by 'make clean'
+o also test on windows and linux
manager
X check to see if manager items from the download can be updated
@@ -36,19 +43,19 @@ X changed manager to go to download.processing.org/latest.txt
X and uses a redirect from there (hopeully that's followed?)
X libraries need to support multiple categories
X https://github.com/processing/processing/issues/1970
-
+X restrict library categories to the ones in the document
+X if it's not correct, shows up as 'other'
_ we shouldn't use .properties for modes et al
_ because a .properties file is iso8859-1
_ remove "Compilations" category for libraries
_ make note that .properties file *must* be utf-8
_ if not it'll make things gross (andre sier flob library)
-_ restrict library categories to the ones in the document
-_ if it's not correct, shows up as 'other'
_ argh.. the 'old' folder is really poorly done
_ attempt to install multiple will cause havoc (fail because 'old' exists)
_ modes and tools require restart (per ContributionType class)
_ but no message is provided anywhere?
_ why wasn't Library moved to LibraryContribution?
+_ or that LibraryContribution needs to be a wrapper around it?
_ send info on 'check for updates' so we know about libs/modes/etc?
_ how to disclose to users?
_ only send for items that are part of the public list
@@ -71,16 +78,15 @@ _ another point for doing .zip files to prevent overwriting
_ add BookContribution?
_ will offer to open the contrib manager even though it's already open
_ though this was looking at libraries, and there may have been modes
-_ update only showing up when selected is awkward
+_ is there an "all" view for the mgr that shows libs, modes, etc?
+_ update button only showing up when item is selected feels awkward
_ "update all" would be useful
+_ "Update 4 items" as a button name
high
_ add .bat file to lib on windows so that we can get better debugging info
_ move old Google Code SVN back to processing.org
_ then cull out the old branches/tags from the Github repo
-_ UnsatisfiedLinkError causes huge message...
-_ error report cleanups haven't been fixed yet
-_ reported by Dan
_ proxy server requirement causes problems
_ contrib manager, update checks are broken
_ https://github.com/processing/processing/issues/1476
@@ -89,7 +95,6 @@ _ figure out Android build w/o javac so we can remove tools.jar and javac
_ also to the p5 repo with just a JRE
_ remove initRequirements from Base (no longer need JDI)
_ move this into Android mode?
-
_ "String index out of range" error
_ https://github.com/processing/processing/issues/1940
@@ -993,9 +998,6 @@ _ i.e. don't mess with Sketch menu, put it in the mode menu
_ add notes to build instructions re: building core with eclipse
_ update the build instructions page
_ http://code.google.com/p/processing/wiki/BuildInstructions
-_ build is currently broken for fresh checkout due to changes to file layout
-_ something that gets fixed by 'make clean'
-_ also test on windows and linux
_ p5 assets need to be licensed differently from the source
From ee889e4539e55e86426f5f6a9bb2d28815c8c824 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 02:24:02 -0400
Subject: [PATCH 096/400] disable the recycle test and add some error-proofing
---
app/src/processing/app/Library.java | 27 ++++++++++---------
.../app/contrib/ModeContribution.java | 11 +++++---
.../app/contrib/ToolContribution.java | 9 ++++---
app/src/processing/app/windows/Platform.java | 14 +++++-----
4 files changed, 36 insertions(+), 25 deletions(-)
mode change 100644 => 100755 app/src/processing/app/Library.java
mode change 100644 => 100755 app/src/processing/app/contrib/ModeContribution.java
mode change 100644 => 100755 app/src/processing/app/contrib/ToolContribution.java
diff --git a/app/src/processing/app/Library.java b/app/src/processing/app/Library.java
old mode 100644
new mode 100755
index 18910d8ba..10ca21cbe
--- a/app/src/processing/app/Library.java
+++ b/app/src/processing/app/Library.java
@@ -15,9 +15,9 @@ public class Library extends LocalContribution {
protected File examplesFolder; // shortname/examples
protected File referenceFile; // shortname/reference/index.html
- /**
- * Subfolder for grouping libraries in a menu. Basic subfolder support
- * is provided so that some organization can be done in the import menu.
+ /**
+ * Subfolder for grouping libraries in a menu. Basic subfolder support
+ * is provided so that some organization can be done in the import menu.
* (This is the replacement for the "library compilation" type.)
*/
protected String group;
@@ -89,13 +89,16 @@ public class Library extends LocalContribution {
return new Library(folder);
// } catch (IgnorableException ig) {
// Base.log(ig.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (Error err) {
+ // Handles UnsupportedClassVersionError and others
+ err.printStackTrace();
+ } catch (Exception ex) {
+ ex.printStackTrace();
}
return null;
}
-
-
+
+
private Library(File folder) {
this(folder, null);
}
@@ -432,14 +435,14 @@ public class Library extends LocalContribution {
}
};
-
+
static public ArrayList discover(File folder) {
ArrayList libraries = new ArrayList();
discover(folder, libraries);
return libraries;
}
-
+
static public void discover(File folder, ArrayList libraries) {
String[] list = folder.list(junkFolderFilter);
@@ -474,14 +477,14 @@ public class Library extends LocalContribution {
}
}
-
+
static protected ArrayList list(File folder) {
ArrayList libraries = new ArrayList();
list(folder, libraries);
return libraries;
}
-
+
static protected void list(File folder, ArrayList libraries) {
ArrayList librariesFolders = new ArrayList();
discover(folder, librariesFolders);
@@ -507,7 +510,7 @@ public class Library extends LocalContribution {
}
}
-
+
public ContributionType getType() {
return ContributionType.LIBRARY;
}
diff --git a/app/src/processing/app/contrib/ModeContribution.java b/app/src/processing/app/contrib/ModeContribution.java
old mode 100644
new mode 100755
index a55e2f1d8..4a927c895
--- a/app/src/processing/app/contrib/ModeContribution.java
+++ b/app/src/processing/app/contrib/ModeContribution.java
@@ -15,7 +15,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along
+ You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -39,18 +39,21 @@ public class ModeContribution extends LocalContribution {
}
- static public ModeContribution load(Base base, File folder,
+ static public ModeContribution load(Base base, File folder,
String searchName) {
try {
return new ModeContribution(base, folder, searchName);
} catch (IgnorableException ig) {
Base.log(ig.getMessage());
+ } catch (Error err) {
+ // Handles UnsupportedClassVersionError and others
+ err.printStackTrace();
} catch (Exception e) {
if (searchName == null) {
e.printStackTrace();
} else {
- // For the built-in modes, don't print the exception, just log it
- // for debugging. This should be impossible for most users to reach,
+ // For the built-in modes, don't print the exception, just log it
+ // for debugging. This should be impossible for most users to reach,
// but it helps us load experimental mode when it's available.
Base.log("ModeContribution.load() failed for " + searchName, e);
}
diff --git a/app/src/processing/app/contrib/ToolContribution.java b/app/src/processing/app/contrib/ToolContribution.java
old mode 100644
new mode 100755
index 94715497e..978e95f49
--- a/app/src/processing/app/contrib/ToolContribution.java
+++ b/app/src/processing/app/contrib/ToolContribution.java
@@ -15,7 +15,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along
+ You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -40,8 +40,11 @@ public class ToolContribution extends LocalContribution implements Tool {
return new ToolContribution(folder);
} catch (IgnorableException ig) {
Base.log(ig.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (Error err) {
+ // Handles UnsupportedClassVersionError and others
+ err.printStackTrace();
+ } catch (Exception ex) {
+ ex.printStackTrace();
}
return null;
}
diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java
index 8cb6403e4..6c3ac3917 100755
--- a/app/src/processing/app/windows/Platform.java
+++ b/app/src/processing/app/windows/Platform.java
@@ -42,14 +42,14 @@ import processing.core.PApplet;
/**
- * Platform-specific glue for Windows.
+ * Platform-specific glue for Windows.
*
*/
public class Platform extends processing.app.Platform {
static final String APP_NAME = "Processing";
static final String REG_OPEN_COMMAND =
- System.getProperty("user.dir").replace('/', '\\') +
+ System.getProperty("user.dir").replace('/', '\\') +
"\\" + APP_NAME.toLowerCase() + ".exe \"%1\"";
static final String REG_DOC = APP_NAME + ".Document";
@@ -60,6 +60,7 @@ public class Platform extends processing.app.Platform {
//checkQuickTime();
checkPath();
+ /*
File f = new File(System.getProperty("user.dir"), "recycle-test.txt");
//File f = new File("C:\\recycle-test.txt");
System.out.println(f.getAbsolutePath());
@@ -72,6 +73,7 @@ public class Platform extends processing.app.Platform {
} catch (IOException e) {
e.printStackTrace();
}
+ */
//findJDK();
/*
@@ -149,8 +151,8 @@ public class Platform extends processing.app.Platform {
/**
- * Associate .pde files with this version of Processing. After 2.0.1,
- * this was changed to only set the values for the current user, so that
+ * Associate .pde files with this version of Processing. After 2.0.1,
+ * this was changed to only set the values for the current user, so that
* it would no longer silently fail on systems that have UAC turned on.
*/
protected void setAssociations() throws UnsupportedEncodingException {
@@ -217,8 +219,8 @@ public class Platform extends processing.app.Platform {
Preferences.setBoolean("platform.auto_file_type_associations", false);
}
}
-
-
+
+
/**
* Remove extra quotes, slashes, and garbage from the Windows PATH.
*/
From 3b08db7fdb4e68042e02a78624b8556829115eb0 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 02:25:25 -0400
Subject: [PATCH 097/400] more notes
---
todo.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/todo.txt b/todo.txt
index 9e9296af2..7a26127d3 100644
--- a/todo.txt
+++ b/todo.txt
@@ -45,6 +45,8 @@ X libraries need to support multiple categories
X https://github.com/processing/processing/issues/1970
X restrict library categories to the ones in the document
X if it's not correct, shows up as 'other'
+X catch Error (not just Exception) objects during load
+X handles UnsupportedClassVersionError and others
_ we shouldn't use .properties for modes et al
_ because a .properties file is iso8859-1
_ remove "Compilations" category for libraries
@@ -84,6 +86,7 @@ _ "update all" would be useful
_ "Update 4 items" as a button name
high
+_ MovieMaker needs to be compiling as 1.6
_ add .bat file to lib on windows so that we can get better debugging info
_ move old Google Code SVN back to processing.org
_ then cull out the old branches/tags from the Github repo
From 0e599a673f7bac2ca886b85db20c595bef13dfff Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 11:57:18 -0400
Subject: [PATCH 098/400] remove NUL characters from files just loaded
---
app/src/processing/app/SketchCode.java | 133 ++++++++++--------
.../processing/app/syntax/JEditTextArea.java | 80 ++++++-----
todo.txt | 1 +
3 files changed, 114 insertions(+), 100 deletions(-)
diff --git a/app/src/processing/app/SketchCode.java b/app/src/processing/app/SketchCode.java
index 0a37efd20..8deaedbe7 100644
--- a/app/src/processing/app/SketchCode.java
+++ b/app/src/processing/app/SketchCode.java
@@ -31,7 +31,7 @@ import javax.swing.undo.*;
/**
- * Represents a single tab of a sketch.
+ * Represents a single tab of a sketch.
*/
public class SketchCode {
/** Pretty name (no extension), not the full file name */
@@ -40,12 +40,12 @@ public class SketchCode {
/** File object for where this code is located */
private File file;
- /** Extension for this file (no dots, and in lowercase). */
+ /** Extension for this file (no dots, and in lowercase). */
private String extension;
/** Text of the program text for this tab */
private String program;
-
+
/** Last version of the program on disk. */
private String savedProgram;
@@ -54,15 +54,15 @@ public class SketchCode {
/** Last time this tab was visited */
long visited;
-
+
/**
* Undo Manager for this tab, each tab keeps track of their own
* Editor.undo will be set to this object when this code is the tab
* that's currently the front.
*/
private UndoManager undo = new UndoManager();
-
- /** What was on top of the undo stack when last saved. */
+
+ /** What was on top of the undo stack when last saved. */
// private UndoableEdit lastEdit;
// saved positions from last time this tab was used
@@ -73,9 +73,9 @@ public class SketchCode {
private boolean modified;
/** name of .java file after preproc */
-// private String preprocName;
+// private String preprocName;
/** where this code starts relative to the concat'd code */
- private int preprocOffset;
+ private int preprocOffset;
public SketchCode(File file, String extension) {
@@ -102,23 +102,23 @@ public class SketchCode {
public File getFile() {
return file;
}
-
-
+
+
protected boolean fileExists() {
return file.exists();
}
-
-
+
+
protected boolean fileReadOnly() {
return !file.canWrite();
}
-
-
+
+
protected boolean deleteFile() {
return file.delete();
}
-
-
+
+
protected boolean renameTo(File what, String ext) {
// System.out.println("renaming " + file);
// System.out.println(" to " + what);
@@ -130,32 +130,32 @@ public class SketchCode {
}
return success;
}
-
-
+
+
public void copyTo(File dest) throws IOException {
Base.saveFile(program, dest);
}
-
+
public String getFileName() {
return file.getName();
}
-
-
+
+
public String getPrettyName() {
return prettyName;
}
-
-
+
+
public String getExtension() {
return extension;
}
-
-
+
+
public boolean isExtension(String what) {
return extension.equals(what);
}
-
+
/** get the current text for this tab */
public String getProgram() {
@@ -174,12 +174,12 @@ public class SketchCode {
return savedProgram;
}
-
+
public int getLineCount() {
return Base.countLines(program);
}
-
-
+
+
public void setModified(boolean modified) {
this.modified = modified;
}
@@ -208,8 +208,8 @@ public class SketchCode {
public int getPreprocOffset() {
return preprocOffset;
}
-
-
+
+
public void addPreprocOffset(int extra) {
preprocOffset += extra;
}
@@ -218,72 +218,81 @@ public class SketchCode {
public Document getDocument() {
return document;
}
-
-
+
+
public void setDocument(Document d) {
document = d;
}
-
-
+
+
public UndoManager getUndo() {
return undo;
}
-
-
- // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
+
+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
+
+
// TODO these could probably be handled better, since it's a general state
// issue that's read/write from only one location in Editor (on tab switch.)
-
-
+
+
public int getSelectionStart() {
return selectionStart;
}
-
-
+
+
public int getSelectionStop() {
return selectionStop;
}
-
-
+
+
public int getScrollPosition() {
return scrollPosition;
}
-
-
+
+
protected void setState(String p, int start, int stop, int pos) {
program = p;
selectionStart = start;
selectionStop = stop;
scrollPosition = pos;
}
-
+
public long lastVisited() {
return visited;
}
-
-
- // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
-
+
+
+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
+
+
/**
* Load this piece of code from a file.
*/
public void load() throws IOException {
program = Base.loadFile(file);
+
+ // Remove NUL characters because they'll cause problems,
+ // and their presence is very difficult to debug.
+ // https://github.com/processing/processing/issues/1973
+ if (program.indexOf('\0') != -1) {
+ program = program.replaceAll("\0", "");
+ }
savedProgram = program;
+ // This used to be the "Fix Encoding and Reload" warning, but since that
+ // tool has been removed, it just rambles about text editors and encodings.
if (program.indexOf('\uFFFD') != -1) {
- System.err.println(file.getName() + " contains unrecognized characters.");
- System.err.println("If this code was created with an older version of Processing,");
- System.err.println("you may need to use Tools -> Fix Encoding & Reload to update");
- System.err.println("the sketch to use UTF-8 encoding. If not, you may need to");
+ System.err.println(file.getName() + " contains unrecognized characters.");
+ System.err.println("You should re-open " + file.getName() +
+ " with a text editor,");
+ System.err.println("and re-save it in UTF-8 format. Otherwise, you can");
System.err.println("delete the bad characters to get rid of this warning.");
System.err.println();
}
-
+
setModified(false);
}
@@ -312,11 +321,11 @@ public class SketchCode {
makePrettyName();
setModified(false);
}
-
-
+
+
/**
- * Called when the sketch folder name/location has changed. Called when
- * renaming tab 0, the main code.
+ * Called when the sketch folder name/location has changed. Called when
+ * renaming tab 0, the main code.
*/
public void setFolder(File sketchFolder) {
file = new File(sketchFolder, file.getName());
diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java
index f052a0989..89b77502f 100644
--- a/app/src/processing/app/syntax/JEditTextArea.java
+++ b/app/src/processing/app/syntax/JEditTextArea.java
@@ -78,7 +78,7 @@ public class JEditTextArea extends JComponent
private InputMethodSupport inputMethodSupport = null;
private Brackets bracketHelper = new Brackets();
-
+
/**
* Creates a new JEditTextArea with the specified settings.
@@ -156,8 +156,8 @@ public class JEditTextArea extends JComponent
// System.out.println(" mods extext = " + mods + " " + mods.length() + " " + PApplet.hex(mods.charAt(0)));
// }
// System.out.println(" " + e);
-
- // inertia scrolling on OS X will fire several shift-wheel events
+
+ // inertia scrolling on OS X will fire several shift-wheel events
// that are negative values.. this makes the scrolling area jump.
boolean skip = Base.isMacOS() && e.isShiftDown();
//if (ex == 0) {
@@ -187,7 +187,7 @@ public class JEditTextArea extends JComponent
return null;
}
-
+
/**
* Get current position of the vertical scroll bar. [fry]
*/
@@ -211,7 +211,7 @@ public class JEditTextArea extends JComponent
return painter;
}
-
+
/**
* Returns the input handler.
*/
@@ -219,7 +219,7 @@ public class JEditTextArea extends JComponent
return inputHandler;
}
-
+
/**
* Sets the input handler.
* @param inputHandler The new input handler
@@ -228,7 +228,7 @@ public class JEditTextArea extends JComponent
this.inputHandler = inputHandler;
}
-
+
/**
* Returns true if the caret is blinking, false otherwise.
*/
@@ -236,7 +236,7 @@ public class JEditTextArea extends JComponent
return caretBlinks;
}
-
+
/**
* Toggles caret blinking.
* @param caretBlinks True if the caret should blink, false otherwise
@@ -249,7 +249,7 @@ public class JEditTextArea extends JComponent
painter.invalidateSelectedLines();
}
-
+
/**
* Returns true if the caret is visible, false otherwise.
*/
@@ -257,7 +257,7 @@ public class JEditTextArea extends JComponent
return (!caretBlinks || blink) && caretVisible;
}
-
+
/**
* Sets if the caret should be visible.
* @param caretVisible True if the caret should be visible, false
@@ -270,7 +270,7 @@ public class JEditTextArea extends JComponent
painter.invalidateSelectedLines();
}
-
+
/**
* Blinks the caret.
*/
@@ -283,7 +283,7 @@ public class JEditTextArea extends JComponent
}
}
-
+
/**
* Returns the number of lines from the top and button of the
* text area that are always visible.
@@ -292,7 +292,7 @@ public class JEditTextArea extends JComponent
return electricScroll;
}
-
+
/**
* Sets the number of lines from the top and bottom of the text
* area that are always visible
@@ -349,7 +349,7 @@ public class JEditTextArea extends JComponent
}
}
-
+
/**
* Returns the line displayed at the text area's origin.
*/
@@ -357,7 +357,7 @@ public class JEditTextArea extends JComponent
return firstLine;
}
-
+
/**
* Sets the line displayed at the text area's origin without
* updating the scroll bars.
@@ -371,15 +371,15 @@ public class JEditTextArea extends JComponent
}
painter.repaint();
}
-
-
- /**
- * Convenience for checking what's on-screen. [fry]
+
+
+ /**
+ * Convenience for checking what's on-screen. [fry]
*/
public final int getLastLine() {
return getFirstLine() + getVisibleLines();
}
-
+
/**
* Returns the number of lines visible in this text area.
@@ -388,7 +388,7 @@ public class JEditTextArea extends JComponent
return visibleLines;
}
-
+
/**
* Recalculates the number of visible lines. This should not
* be called directly.
@@ -402,7 +402,7 @@ public class JEditTextArea extends JComponent
updateScrollBars();
}
-
+
/**
* Returns the horizontal offset of drawn lines.
*/
@@ -410,7 +410,7 @@ public class JEditTextArea extends JComponent
return horizontalOffset;
}
-
+
/**
* Sets the horizontal offset of drawn lines. This can be used to
* implement horizontal scrolling.
@@ -427,7 +427,7 @@ public class JEditTextArea extends JComponent
painter.repaint();
}
-
+
/**
* A fast way of changing both the first line and horizontal
* offset.
@@ -442,12 +442,12 @@ public class JEditTextArea extends JComponent
this.horizontalOffset = horizontalOffset;
changed = true;
}
-
+
if (firstLine != this.firstLine) {
this.firstLine = firstLine;
changed = true;
}
-
+
if (changed) {
updateScrollBars();
painter.repaint();
@@ -455,7 +455,7 @@ public class JEditTextArea extends JComponent
return changed;
}
-
+
/**
* Ensures that the caret is visible by scrolling the text area if
* necessary.
@@ -471,7 +471,7 @@ public class JEditTextArea extends JComponent
return scrollTo(line,offset);
}
-
+
/**
* Ensures that the specified line and offset is visible by scrolling
* the text area if necessary.
@@ -516,7 +516,7 @@ public class JEditTextArea extends JComponent
return setOrigin(newFirstLine,newHorizontalOffset);
}
-
+
/**
* Converts a line index to a y co-ordinate.
* @param line The line
@@ -527,7 +527,7 @@ public class JEditTextArea extends JComponent
- (fm.getLeading() + fm.getMaxDescent());
}
-
+
/**
* Converts a y co-ordinate to a line index.
* @param y The y co-ordinate
@@ -539,7 +539,7 @@ public class JEditTextArea extends JComponent
y / height + firstLine));
}
-
+
/**
* Converts an offset in a line into an x co-ordinate. This is a
* slow version that can be used any time.
@@ -552,7 +552,7 @@ public class JEditTextArea extends JComponent
return _offsetToX(line,offset);
}
-
+
/**
* Converts an offset in a line into an x coordinate. This is a
* fast version that should only be used if no changes were made
@@ -575,9 +575,9 @@ public class JEditTextArea extends JComponent
if (tokenMarker == null) {
lineSegment.count = offset;
return x + Utilities.getTabbedTextWidth(lineSegment, fm, x, painter, 0);
-
+
} else {
- // If syntax coloring is enabled, we have to do this
+ // If syntax coloring is enabled, we have to do this
// because tokens can vary in width
Token tokens;
if (painter.currentLineIndex == line && painter.currentLineTokens != null) {
@@ -1884,11 +1884,15 @@ public class JEditTextArea extends JComponent
// Seen often on Mac OS X when pasting from Safari. [fry 030929]
selection = selection.replace('\u00A0', ' ');
- // Remove ASCII NUL characters. Reported when pasting from
- // Acrobat Reader and PDF documents. [fry 130719]
+ // Remove ASCII NUL characters. Reported when pasting from
+ // Acrobat Reader and PDF documents. [fry 130719]
// https://github.com/processing/processing/issues/1973
if (selection.indexOf('\0') != -1) {
+ //System.out.println("found NUL charaacters");
+ //int before = selection.length();
selection = selection.replaceAll("\0", "");
+ //int after = selection.length();
+ //System.out.println(before + " " + after);
}
int repeatCount = inputHandler.getRepeatCount();
@@ -2329,8 +2333,8 @@ public class JEditTextArea extends JComponent
}
}
-
- class DragHandler implements MouseMotionListener
+
+ class DragHandler implements MouseMotionListener
{
public void mouseDragged(MouseEvent evt) {
if (popup != null && popup.isVisible()) return;
diff --git a/todo.txt b/todo.txt
index 7a26127d3..ae0cfdf85 100644
--- a/todo.txt
+++ b/todo.txt
@@ -12,6 +12,7 @@ o b86 supposed to have some support (not available yet)
o http://jdk8.java.net/download.html
X code with a NUL character causes an error
X https://github.com/processing/processing/issues/1973
+X also remove NUL characters when loading a file
X Add "Processing Foundation" to the Help menu
X https://github.com/processing/processing/issues/1908
X Update JNA from 3.2.4 to 3.5.2
From 52d25b3efbb6eaf531e8f09403c932a790770657 Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 12:26:08 -0400
Subject: [PATCH 099/400] remove an unused import
---
app/src/processing/app/windows/Platform.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java
index 6c3ac3917..4405d008f 100755
--- a/app/src/processing/app/windows/Platform.java
+++ b/app/src/processing/app/windows/Platform.java
@@ -23,7 +23,6 @@
package processing.app.windows;
import java.io.File;
-import java.io.IOException;
import java.io.UnsupportedEncodingException;
import com.sun.jna.Library;
From 2b3345061fafae96cd03b11dcbd646bbf02318fc Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 12:27:55 -0400
Subject: [PATCH 100/400] Moving platform classes to new names/packages
---
.../{Platform.java => LinuxPlatform.java} | 2 +-
.../MacPlatform.java} | 4 ++--
.../{macosx => platform}/ThinkDifferent.java | 2 +-
.../{Platform.java => WindowsPlatform.java} | 22 +++++++++----------
.../{Registry.java => WindowsRegistry.java} | 2 +-
5 files changed, 16 insertions(+), 16 deletions(-)
rename app/src/processing/app/linux/{Platform.java => LinuxPlatform.java} (98%)
rename app/src/processing/app/{macosx/Platform.java => platform/MacPlatform.java} (98%)
rename app/src/processing/app/{macosx => platform}/ThinkDifferent.java (99%)
rename app/src/processing/app/windows/{Platform.java => WindowsPlatform.java} (96%)
rename app/src/processing/app/windows/{Registry.java => WindowsRegistry.java} (99%)
diff --git a/app/src/processing/app/linux/Platform.java b/app/src/processing/app/linux/LinuxPlatform.java
similarity index 98%
rename from app/src/processing/app/linux/Platform.java
rename to app/src/processing/app/linux/LinuxPlatform.java
index 2a5415b82..b484f69e7 100644
--- a/app/src/processing/app/linux/Platform.java
+++ b/app/src/processing/app/linux/LinuxPlatform.java
@@ -28,7 +28,7 @@ import processing.app.Base;
import processing.app.Preferences;
-public class Platform extends processing.app.Platform {
+public class LinuxPlatform extends processing.app.Platform {
public void init(Base base) {
super.init(base);
diff --git a/app/src/processing/app/macosx/Platform.java b/app/src/processing/app/platform/MacPlatform.java
similarity index 98%
rename from app/src/processing/app/macosx/Platform.java
rename to app/src/processing/app/platform/MacPlatform.java
index c09f2b55a..b8038290e 100644
--- a/app/src/processing/app/macosx/Platform.java
+++ b/app/src/processing/app/platform/MacPlatform.java
@@ -20,7 +20,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-package processing.app.macosx;
+package processing.app.platform;
import java.io.File;
import java.io.FileNotFoundException;
@@ -33,7 +33,7 @@ import processing.app.Base;
/**
* Platform handler for Mac OS X.
*/
-public class Platform extends processing.app.Platform {
+public class MacPlatform extends processing.app.Platform {
// Removing for 2.0b8 because Quaqua doesn't have OS X 10.8 version.
/*
diff --git a/app/src/processing/app/macosx/ThinkDifferent.java b/app/src/processing/app/platform/ThinkDifferent.java
similarity index 99%
rename from app/src/processing/app/macosx/ThinkDifferent.java
rename to app/src/processing/app/platform/ThinkDifferent.java
index f65038279..bc7a8808f 100644
--- a/app/src/processing/app/macosx/ThinkDifferent.java
+++ b/app/src/processing/app/platform/ThinkDifferent.java
@@ -19,7 +19,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-package processing.app.macosx;
+package processing.app.platform;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/WindowsPlatform.java
similarity index 96%
rename from app/src/processing/app/windows/Platform.java
rename to app/src/processing/app/windows/WindowsPlatform.java
index 4405d008f..059c7833a 100755
--- a/app/src/processing/app/windows/Platform.java
+++ b/app/src/processing/app/windows/WindowsPlatform.java
@@ -36,7 +36,7 @@ import com.sun.jna.platform.win32.WinNT.HRESULT;
import processing.app.Base;
import processing.app.Preferences;
-import processing.app.windows.Registry.REGISTRY_ROOT_KEY;
+import processing.app.windows.WindowsRegistry.REGISTRY_ROOT_KEY;
import processing.core.PApplet;
@@ -44,7 +44,7 @@ import processing.core.PApplet;
* Platform-specific glue for Windows.
*
*/
-public class Platform extends processing.app.Platform {
+public class WindowsPlatform extends processing.app.Platform {
static final String APP_NAME = "Processing";
static final String REG_OPEN_COMMAND =
@@ -136,7 +136,7 @@ public class Platform extends processing.app.Platform {
if (Preferences.getBoolean("platform.auto_file_type_associations")) {
// Check the key that should be set by a previous run of Processing
String knownCommand =
- Registry.getStringValue(REGISTRY_ROOT_KEY.CURRENT_USER,
+ WindowsRegistry.getStringValue(REGISTRY_ROOT_KEY.CURRENT_USER,
"Software\\Classes\\" + REG_DOC + "\\shell\\open\\command", "");
// If the association hasn't been set, or it's not correct, set it.
if (knownCommand == null || !knownCommand.equals(REG_OPEN_COMMAND)) {
@@ -197,18 +197,18 @@ public class Platform extends processing.app.Platform {
final String docPrefix = "Software\\Classes\\" + REG_DOC;
// First create the .pde association
- if (Registry.createKey(rootKey, "Software\\Classes", ".pde") &&
- Registry.setStringValue(rootKey, "Software\\Classes\\.pde", "", REG_DOC) &&
+ if (WindowsRegistry.createKey(rootKey, "Software\\Classes", ".pde") &&
+ WindowsRegistry.setStringValue(rootKey, "Software\\Classes\\.pde", "", REG_DOC) &&
// Now give files with a .pde extension a name for the explorer
- Registry.createKey(rootKey, "Software\\Classes", REG_DOC) &&
- Registry.setStringValue(rootKey, docPrefix, "", APP_NAME + " Source Code") &&
+ WindowsRegistry.createKey(rootKey, "Software\\Classes", REG_DOC) &&
+ WindowsRegistry.setStringValue(rootKey, docPrefix, "", APP_NAME + " Source Code") &&
// Now associate the 'open' command with the current processing.exe
- Registry.createKey(rootKey, docPrefix, "shell") &&
- Registry.createKey(rootKey, docPrefix + "\\shell", "open") &&
- Registry.createKey(rootKey, docPrefix + "\\shell\\open", "command") &&
- Registry.setStringValue(rootKey, docPrefix + "\\shell\\open\\command", "", REG_OPEN_COMMAND)) {
+ WindowsRegistry.createKey(rootKey, docPrefix, "shell") &&
+ WindowsRegistry.createKey(rootKey, docPrefix + "\\shell", "open") &&
+ WindowsRegistry.createKey(rootKey, docPrefix + "\\shell\\open", "command") &&
+ WindowsRegistry.setStringValue(rootKey, docPrefix + "\\shell\\open\\command", "", REG_OPEN_COMMAND)) {
// everything ok
// hooray!
diff --git a/app/src/processing/app/windows/Registry.java b/app/src/processing/app/windows/WindowsRegistry.java
similarity index 99%
rename from app/src/processing/app/windows/Registry.java
rename to app/src/processing/app/windows/WindowsRegistry.java
index 11f78980a..49c614eed 100644
--- a/app/src/processing/app/windows/Registry.java
+++ b/app/src/processing/app/windows/WindowsRegistry.java
@@ -22,7 +22,7 @@ import com.sun.jna.ptr.IntByReference;
* Not sure of where this code came from originally, but it was hacked on
* 20 July 2013 to make updates for use with JNA 3.5.2's platform classes.
*/
-public class Registry {
+public class WindowsRegistry {
static public enum REGISTRY_ROOT_KEY {
CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, USERS
};
From 177a6b5d2868c13d8e103d0fc5ffe06ecd24849b Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 12:28:27 -0400
Subject: [PATCH 101/400] changing package for these guys
---
app/src/processing/app/{linux => platform}/LinuxPlatform.java | 2 +-
.../processing/app/{windows => platform}/WindowsPlatform.java | 4 ++--
.../processing/app/{windows => platform}/WindowsRegistry.java | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
rename app/src/processing/app/{linux => platform}/LinuxPlatform.java (99%)
rename app/src/processing/app/{windows => platform}/WindowsPlatform.java (99%)
rename app/src/processing/app/{windows => platform}/WindowsRegistry.java (99%)
diff --git a/app/src/processing/app/linux/LinuxPlatform.java b/app/src/processing/app/platform/LinuxPlatform.java
similarity index 99%
rename from app/src/processing/app/linux/LinuxPlatform.java
rename to app/src/processing/app/platform/LinuxPlatform.java
index b484f69e7..8a506804e 100644
--- a/app/src/processing/app/linux/LinuxPlatform.java
+++ b/app/src/processing/app/platform/LinuxPlatform.java
@@ -20,7 +20,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-package processing.app.linux;
+package processing.app.platform;
import java.io.File;
diff --git a/app/src/processing/app/windows/WindowsPlatform.java b/app/src/processing/app/platform/WindowsPlatform.java
similarity index 99%
rename from app/src/processing/app/windows/WindowsPlatform.java
rename to app/src/processing/app/platform/WindowsPlatform.java
index 059c7833a..1372d9c9b 100755
--- a/app/src/processing/app/windows/WindowsPlatform.java
+++ b/app/src/processing/app/platform/WindowsPlatform.java
@@ -20,7 +20,7 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-package processing.app.windows;
+package processing.app.platform;
import java.io.File;
import java.io.UnsupportedEncodingException;
@@ -36,7 +36,7 @@ import com.sun.jna.platform.win32.WinNT.HRESULT;
import processing.app.Base;
import processing.app.Preferences;
-import processing.app.windows.WindowsRegistry.REGISTRY_ROOT_KEY;
+import processing.app.platform.WindowsRegistry.REGISTRY_ROOT_KEY;
import processing.core.PApplet;
diff --git a/app/src/processing/app/windows/WindowsRegistry.java b/app/src/processing/app/platform/WindowsRegistry.java
similarity index 99%
rename from app/src/processing/app/windows/WindowsRegistry.java
rename to app/src/processing/app/platform/WindowsRegistry.java
index 49c614eed..8c08f7d92 100644
--- a/app/src/processing/app/windows/WindowsRegistry.java
+++ b/app/src/processing/app/platform/WindowsRegistry.java
@@ -1,4 +1,4 @@
-package processing.app.windows;
+package processing.app.platform;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
From 046724af949d956c5f075811055c465cbee7b9ab Mon Sep 17 00:00:00 2001
From: Ben Fry
Date: Sun, 21 Jul 2013 12:43:22 -0400
Subject: [PATCH 102/400] change location of platform classes, more Windows
cleanups
---
app/src/processing/app/Base.java | 6 +-
.../app/platform/LinuxPlatform.java | 13 ++-
.../processing/app/platform/MacPlatform.java | 13 ++-
.../app/platform/ThinkDifferent.java | 9 +-
.../app/platform/WindowsPlatform.java | 4 +-
.../app/platform/WindowsRegistry.java | 110 +++++++++---------
6 files changed, 76 insertions(+), 79 deletions(-)
diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java
index e0e66e3fb..21d0df712 100644
--- a/app/src/processing/app/Base.java
+++ b/app/src/processing/app/Base.java
@@ -220,11 +220,11 @@ public class Base {
try {
Class> platformClass = Class.forName("processing.app.Platform"); //$NON-NLS-1$
if (Base.isMacOS()) {
- platformClass = Class.forName("processing.app.macosx.Platform"); //$NON-NLS-1$
+ platformClass = Class.forName("processing.app.platform.MacPlatform"); //$NON-NLS-1$
} else if (Base.isWindows()) {
- platformClass = Class.forName("processing.app.windows.Platform"); //$NON-NLS-1$
+ platformClass = Class.forName("processing.app.platform.WindowsPlatform"); //$NON-NLS-1$
} else if (Base.isLinux()) {
- platformClass = Class.forName("processing.app.linux.Platform"); //$NON-NLS-1$
+ platformClass = Class.forName("processing.app.platform.LinuxPlatform"); //$NON-NLS-1$
}
platform = (Platform) platformClass.newInstance();
} catch (Exception e) {
diff --git a/app/src/processing/app/platform/LinuxPlatform.java b/app/src/processing/app/platform/LinuxPlatform.java
index 8a506804e..8e9ee7c71 100644
--- a/app/src/processing/app/platform/LinuxPlatform.java
+++ b/app/src/processing/app/platform/LinuxPlatform.java
@@ -3,12 +3,12 @@
/*
Part of the Processing project - http://processing.org
- Copyright (c) 2008 Ben Fry and Casey Reas
+ Copyright (c) 2012-2013 The Processing Foundation
+ Copyright (c) 2008-2012 Ben Fry and Casey Reas
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,10 +25,11 @@ package processing.app.platform;
import java.io.File;
import processing.app.Base;
+import processing.app.Platform;
import processing.app.Preferences;
-public class LinuxPlatform extends processing.app.Platform {
+public class LinuxPlatform extends Platform {
public void init(Base base) {
super.init(base);
diff --git a/app/src/processing/app/platform/MacPlatform.java b/app/src/processing/app/platform/MacPlatform.java
index b8038290e..0407fdc6f 100644
--- a/app/src/processing/app/platform/MacPlatform.java
+++ b/app/src/processing/app/platform/MacPlatform.java
@@ -3,12 +3,12 @@
/*
Part of the Processing project - http://processing.org
- Copyright (c) 2008 Ben Fry and Casey Reas
+ Copyright (c) 2012-2013 The Processing Foundation
+ Copyright (c) 2008-2012 Ben Fry and Casey Reas
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -28,12 +28,13 @@ import java.io.FileNotFoundException;
import com.apple.eio.FileManager;
import processing.app.Base;
+import processing.app.Platform;
/**
* Platform handler for Mac OS X.
*/
-public class MacPlatform extends processing.app.Platform {
+public class MacPlatform extends Platform {
// Removing for 2.0b8 because Quaqua doesn't have OS X 10.8 version.
/*
diff --git a/app/src/processing/app/platform/ThinkDifferent.java b/app/src/processing/app/platform/ThinkDifferent.java
index bc7a8808f..79caaa338 100644
--- a/app/src/processing/app/platform/ThinkDifferent.java
+++ b/app/src/processing/app/platform/ThinkDifferent.java
@@ -3,11 +3,12 @@
/*
Part of the Processing project - http://processing.org
- Copyright (c) 2007-2010 Ben Fry and Casey Reas
+ Copyright (c) 2012-2013 The Processing Foundation
+ Copyright (c) 2007-2012 Ben Fry and Casey Reas
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, version 2.
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/app/src/processing/app/platform/WindowsPlatform.java b/app/src/processing/app/platform/WindowsPlatform.java
index 1372d9c9b..0c14b5ead 100755
--- a/app/src/processing/app/platform/WindowsPlatform.java
+++ b/app/src/processing/app/platform/WindowsPlatform.java
@@ -35,6 +35,7 @@ import com.sun.jna.platform.win32.WinError;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import processing.app.Base;
+import processing.app.Platform;
import processing.app.Preferences;
import processing.app.platform.WindowsRegistry.REGISTRY_ROOT_KEY;
import processing.core.PApplet;
@@ -42,9 +43,8 @@ import processing.core.PApplet;
/**
* Platform-specific glue for Windows.
- *
*/
-public class WindowsPlatform extends processing.app.Platform {
+public class WindowsPlatform extends Platform {
static final String APP_NAME = "Processing";
static final String REG_OPEN_COMMAND =
diff --git a/app/src/processing/app/platform/WindowsRegistry.java b/app/src/processing/app/platform/WindowsRegistry.java
index 8c08f7d92..dd2581cd5 100644
--- a/app/src/processing/app/platform/WindowsRegistry.java
+++ b/app/src/processing/app/platform/WindowsRegistry.java
@@ -19,8 +19,10 @@ import com.sun.jna.ptr.IntByReference;
* Methods for accessing the Windows Registry. Only String and DWORD values
* supported at the moment.
*
- * Not sure of where this code came from originally, but it was hacked on
- * 20 July 2013 to make updates for use with JNA 3.5.2's platform classes.
+ * Not sure where this code came from originally (if you know the reference,
+ * please get in touch so that we can add a proper citation). Several changes
+ * were made to update it for JNA 3.5.2's platform classes and clean up the
+ * syntax to make it less like a C program. [fry 130720]
*/
public class WindowsRegistry {
static public enum REGISTRY_ROOT_KEY {
@@ -45,16 +47,15 @@ public class WindowsRegistry {
* @return root key
*/
private static HKEY getRegistryRootKey(REGISTRY_ROOT_KEY key) {
- Advapi32 advapi32;
+ //Advapi32 advapi32;
//IntByReference pHandle;
- HKEYByReference pHandle;
//int handle = 0;
- HKEY handle = null;
- advapi32 = Advapi32.INSTANCE;
+ Advapi32 advapi32 = Advapi32.INSTANCE;
// pHandle = new IntByReference();
- pHandle = new WinReg.HKEYByReference();
+ HKEYByReference pHandle = new WinReg.HKEYByReference();
+ HKEY handle = null;
if (advapi32.RegOpenKeyEx(rootKeyMap.get(key), null, 0, 0, pHandle) == WinError.ERROR_SUCCESS) {
handle = pHandle.getValue();
}
@@ -128,13 +129,13 @@ public class WindowsRegistry {
//IntByReference pType, lpcbData;
byte[] lpData = new byte[1];
//int handle = 0;
- String ret = null;
Advapi32 advapi32 = Advapi32.INSTANCE;
IntByReference pType = new IntByReference();
IntByReference lpcbData = new IntByReference();
HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ);
+ String ret = null;
//if (handle != 0) {
if (handle != null) {
//if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) {
@@ -155,26 +156,19 @@ public class WindowsRegistry {
/**
* Read an int value.
*
- *
* @return int or 0
* @param rootKey root key
* @param subKeyName key name
* @param name value name
*/
static public int getIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
- Advapi32 advapi32;
- IntByReference pType;
- IntByReference lpcbData;
- byte[] lpData = new byte[1];
- //int handle = 0;
- HKEY handle = null;
+ Advapi32 advapi32 = Advapi32.INSTANCE;
+ IntByReference pType = new IntByReference();
+ IntByReference lpcbData = new IntByReference();
+ HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ);
+
int ret = 0;
-
- advapi32 = Advapi32.INSTANCE;
- pType = new IntByReference();
- lpcbData = new IntByReference();
- handle = openKey(rootKey, subKeyName, WinNT.KEY_READ);
-
+ byte[] lpData = new byte[1];
//if(handle != 0) {
if (handle != null) {
//if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) {
@@ -203,10 +197,10 @@ public class WindowsRegistry {
static public boolean deleteValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
Advapi32 advapi32 = Advapi32.INSTANCE;
//int handle;
- boolean ret = true;
HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ | WinNT.KEY_WRITE);
+ boolean ret = true;
//if(handle != 0) {
if (handle != null) {
if (advapi32.RegDeleteValue(handle, name) == WinError.ERROR_SUCCESS) {
@@ -230,18 +224,18 @@ public class WindowsRegistry {
*/
static public boolean setStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, String value) throws UnsupportedEncodingException {
//int handle;
- byte[] data;
- boolean ret = false;
+ //byte[] data;
// appears to be Java 1.6 syntax, removing [fry]
//data = Arrays.copyOf(value.getBytes("UTF-16LE"), value.length() * 2 + 2);
- data = new byte[value.length() * 2 + 2];
+ byte[] data = new byte[value.length() * 2 + 2];
byte[] src = value.getBytes("UTF-16LE");
System.arraycopy(src, 0, data, 0, src.length);
Advapi32 advapi32 = Advapi32.INSTANCE;
HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ | WinNT.KEY_WRITE);
+ boolean ret = false;
//if(handle != 0) {
if (handle != null) {
if (advapi32.RegSetValueEx(handle, name, 0, WinNT.REG_SZ, data, data.length) == WinError.ERROR_SUCCESS) {
@@ -256,7 +250,6 @@ public class WindowsRegistry {
/**
* Writes an int value.
*
- *
* @return true on success
* @param rootKey root key
* @param subKeyName key name
@@ -264,19 +257,19 @@ public class WindowsRegistry {
* @param value value
*/
static public boolean setIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, int value) {
- Advapi32 advapi32;
+ //Advapi32 advapi32;
//int handle;
- byte[] data;
- boolean ret = false;
+ //byte[] data;
- data = new byte[4];
+ byte[] data = new byte[4];
data[0] = (byte)(value & 0xff);
data[1] = (byte)((value >> 8) & 0xff);
data[2] = (byte)((value >> 16) & 0xff);
data[3] = (byte)((value >> 24) & 0xff);
- advapi32 = Advapi32.INSTANCE;
+ Advapi32 advapi32 = Advapi32.INSTANCE;
HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ | WinNT.KEY_WRITE);
+ boolean ret = false;
//if(handle != 0) {
if (handle != null) {
if (advapi32.RegSetValueEx(handle, name, 0, WinNT.REG_DWORD, data, data.length) == WinError.ERROR_SUCCESS) {
@@ -298,16 +291,16 @@ public class WindowsRegistry {
*/
static public boolean valueExists(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
//Advapi32 advapi32;
- IntByReference pType, lpcbData;
- byte[] lpData = new byte[1];
+ //IntByReference pType, lpcbData;
//int handle = 0;
- boolean ret = false;
Advapi32 advapi32 = Advapi32.INSTANCE;
- pType = new IntByReference();
- lpcbData = new IntByReference();
+ IntByReference pType = new IntByReference();
+ IntByReference lpcbData = new IntByReference();
HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ);
+ byte[] lpData = new byte[1];
+ boolean ret = false;
//if(handle != 0) {
if (handle != null) {
//if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) != WinError.ERROR_FILE_NOT_FOUND) {
@@ -335,7 +328,6 @@ public class WindowsRegistry {
//Advapi32 advapi32;
//IntByReference hkResult, dwDisposition;
//int handle = 0;
- boolean ret = false;
Advapi32 advapi32 = Advapi32.INSTANCE;
//IntByReference hkResult = new IntByReference();
@@ -343,6 +335,7 @@ public class WindowsRegistry {
IntByReference dwDisposition = new IntByReference();
HKEY handle = openKey(rootKey, parent, WinNT.KEY_READ);
+ boolean ret = false;
//if(handle != 0) {
if (handle != null) {
if (advapi32.RegCreateKeyEx(handle, name, 0, null, WinNT.REG_OPTION_NON_VOLATILE, WinNT.KEY_READ, null,
@@ -370,11 +363,11 @@ public class WindowsRegistry {
static public boolean deleteKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) {
//Advapi32 advapi32;
//int handle = 0;
- boolean ret = false;
Advapi32 advapi32 = Advapi32.INSTANCE;
HKEY handle = openKey(rootKey, parent, WinNT.KEY_READ);
+ boolean ret = false;
//if(handle != 0) {
if (handle != null) {
if (advapi32.RegDeleteKey(handle, name) == WinError.ERROR_SUCCESS) {
@@ -399,23 +392,22 @@ public class WindowsRegistry {
static public String[] getSubKeys(REGISTRY_ROOT_KEY rootKey, String parent) {
//Advapi32 advapi32;
//int handle = 0, dwIndex;
- char[] lpName;
- IntByReference lpcName;
- WinBase.FILETIME lpftLastWriteTime;
+ //char[] lpName;
+ //IntByReference lpcName;
+ //WinBase.FILETIME lpftLastWriteTime;
TreeSet subKeys = new TreeSet();
-
Advapi32 advapi32 = Advapi32.INSTANCE;
HKEY handle = openKey(rootKey, parent, WinNT.KEY_READ);
- lpName = new char[256];
- lpcName = new IntByReference(256);
- lpftLastWriteTime = new WinBase.FILETIME();
+ char[] lpName = new char[256];
+ IntByReference lpcName = new IntByReference(256);
+ WinBase.FILETIME lpftLastWriteTime = new WinBase.FILETIME();
//if(handle != 0) {
if (handle != null) {
int dwIndex = 0;
- while(advapi32.RegEnumKeyEx(handle, dwIndex, lpName, lpcName, null,
- null, null, lpftLastWriteTime) == WinError.ERROR_SUCCESS) {
+ while (advapi32.RegEnumKeyEx(handle, dwIndex, lpName, lpcName, null,
+ null, null, lpftLastWriteTime) == WinError.ERROR_SUCCESS) {
subKeys.add(new String(lpName, 0, lpcName.getValue()));
lpcName.setValue(256);
dwIndex++;
@@ -437,25 +429,27 @@ public class WindowsRegistry {
static public TreeMap