mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
working on the application, and implemented update check
This commit is contained in:
@@ -50,7 +50,8 @@ import processing.core.*;
|
||||
* files and images, etc) that comes from that.
|
||||
*/
|
||||
public class Base {
|
||||
static final String VERSION = "0083 Alpha";
|
||||
static final int VERSION = 83;
|
||||
static final String VERSION_NAME = "0083 Alpha";
|
||||
|
||||
/**
|
||||
* Path of filename opened on the command line,
|
||||
@@ -68,9 +69,9 @@ public class Base {
|
||||
if (PApplet.javaVersion < 1.4f) {
|
||||
//System.err.println("no way man");
|
||||
Base.showError("Need to install Java 1.4",
|
||||
"This version of Processing requires \n" +
|
||||
"Java 1.4 or later to run properly.\n" +
|
||||
"Please visit java.com to upgrade.", null);
|
||||
"This version of Processing requires \n" +
|
||||
"Java 1.4 or later to run properly.\n" +
|
||||
"Please visit java.com to upgrade.", null);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +119,6 @@ public class Base {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// build the editor object
|
||||
editor = new Editor();
|
||||
|
||||
@@ -130,6 +130,11 @@ public class Base {
|
||||
|
||||
// show the window
|
||||
editor.show();
|
||||
|
||||
// check for updates
|
||||
if (Preferences.getBoolean("update.check")) {
|
||||
new UpdateCheck(editor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Editor extends JFrame
|
||||
MRJOpenDocumentHandler //, MRJOpenApplicationHandler
|
||||
{
|
||||
// yeah
|
||||
static final String WINDOW_TITLE = "Processing" + " - " + Base.VERSION;
|
||||
static final String WINDOW_TITLE = "Processing" + " - " + Base.VERSION_NAME;
|
||||
|
||||
// p5 icon for the window
|
||||
Image icon;
|
||||
@@ -874,7 +874,7 @@ public class Editor extends JFrame
|
||||
|
||||
g.setFont(new Font("SansSerif", Font.PLAIN, 11));
|
||||
g.setColor(Color.white);
|
||||
g.drawString(Base.VERSION, 50, 30);
|
||||
g.drawString(Base.VERSION_NAME, 50, 30);
|
||||
}
|
||||
};
|
||||
window.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@@ -73,12 +73,11 @@ public class Preferences extends JComponent {
|
||||
|
||||
// mac needs it to be 70, windows needs 66, linux needs 76
|
||||
|
||||
static /*final*/ int BUTTON_WIDTH = 76;
|
||||
static /*final*/ int BUTTON_HEIGHT = 24;
|
||||
static int BUTTON_WIDTH = 76;
|
||||
static int BUTTON_HEIGHT = 24;
|
||||
|
||||
// value for the size bars, buttons, etc
|
||||
|
||||
//static final int INSET_SIZE = 5;
|
||||
static final int GRID_SIZE = 33;
|
||||
|
||||
// gui variables
|
||||
@@ -98,6 +97,7 @@ public class Preferences extends JComponent {
|
||||
JCheckBox sketchCleanBox;
|
||||
//JCheckBox exportLibraryBox;
|
||||
JCheckBox externalEditorBox;
|
||||
JCheckBox checkUpdatesBox;
|
||||
|
||||
JTextField fontSizeField;
|
||||
|
||||
@@ -123,7 +123,7 @@ public class Preferences extends JComponent {
|
||||
|
||||
} catch (Exception e) {
|
||||
Base.showError(null, "Could not read default settings.\n" +
|
||||
"You'll need to reinstall Processing.", e);
|
||||
"You'll need to reinstall Processing.", e);
|
||||
}
|
||||
|
||||
// check for platform-specific properties in the defaults
|
||||
@@ -307,6 +307,16 @@ public class Preferences extends JComponent {
|
||||
top += d.height + GUI_BETWEEN;
|
||||
|
||||
|
||||
// [ ] Check for updates on startup
|
||||
|
||||
checkUpdatesBox = new JCheckBox("Check for updates on startup");
|
||||
pain.add(checkUpdatesBox);
|
||||
d = checkUpdatesBox.getPreferredSize();
|
||||
checkUpdatesBox.setBounds(left, top, d.width, d.height);
|
||||
right = Math.max(right, left + d.width);
|
||||
top += d.height + GUI_BETWEEN;
|
||||
|
||||
|
||||
// More preferences are in the ...
|
||||
|
||||
/*
|
||||
@@ -433,9 +443,6 @@ public class Preferences extends JComponent {
|
||||
* Close the window after an OK or Cancel.
|
||||
*/
|
||||
public void disposeFrame() {
|
||||
//frame.hide();
|
||||
//editor.applyPreferences();
|
||||
//editor.show();
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
@@ -445,14 +452,12 @@ public class Preferences extends JComponent {
|
||||
* then send a message to the editor saying that it's time to do the same.
|
||||
*/
|
||||
public void applyFrame() {
|
||||
//editor.setExternalEditor(getBoolean("editor.external"));
|
||||
// put each of the settings into the table
|
||||
|
||||
setBoolean("sketchbook.prompt", sketchPromptBox.isSelected());
|
||||
setBoolean("sketchbook.auto_clean", sketchCleanBox.isSelected());
|
||||
set("sketchbook.path", sketchbookLocationField.getText());
|
||||
//setBoolean("export.library", exportLibraryBox.isSelected());
|
||||
setBoolean("editor.external", externalEditorBox.isSelected());
|
||||
setBoolean("update.check", checkUpdatesBox.isSelected());
|
||||
|
||||
String newSizeText = fontSizeField.getText();
|
||||
try {
|
||||
@@ -469,16 +474,14 @@ public class Preferences extends JComponent {
|
||||
|
||||
|
||||
public void showFrame(Editor editor) {
|
||||
// hide the editor window so it can't be messed with
|
||||
this.editor = editor;
|
||||
//editor.hide();
|
||||
|
||||
// set all settings entry boxes to their actual status
|
||||
sketchPromptBox.setSelected(getBoolean("sketchbook.prompt"));
|
||||
sketchCleanBox.setSelected(getBoolean("sketchbook.auto_clean"));
|
||||
sketchbookLocationField.setText(get("sketchbook.path"));
|
||||
//exportLibraryBox.setSelected(getBoolean("export.library"));
|
||||
externalEditorBox.setSelected(getBoolean("editor.external"));
|
||||
checkUpdatesBox.setSelected(getBoolean("update.check"));
|
||||
|
||||
frame.show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2005 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 distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
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 with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.undo.*;
|
||||
|
||||
import com.apple.mrj.*;
|
||||
import com.ice.jni.registry.*;
|
||||
|
||||
import processing.core.*;
|
||||
|
||||
|
||||
/**
|
||||
* Threaded class to check for updates.
|
||||
* <P>
|
||||
* This generates a random id number for this user,
|
||||
* and hits the server to check for updates.
|
||||
* The id number is used so that we can keep track of
|
||||
* how many people are using Processing, which helps us
|
||||
* when writing grant proposals and that kind of thing.
|
||||
*/
|
||||
public class UpdateCheck implements Runnable {
|
||||
Editor editor;
|
||||
String downloadURL = "http://processing.org/download/latest.txt";
|
||||
|
||||
|
||||
public UpdateCheck(Editor editor) {
|
||||
this.editor = editor;
|
||||
Thread thread = new Thread(this);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
//System.out.println("checking for updates...");
|
||||
|
||||
// generate a random id in case none exists yet
|
||||
Random r = new Random();
|
||||
long id = r.nextLong();
|
||||
|
||||
String idString = Preferences.get("update.id");
|
||||
if (idString != null) {
|
||||
id = Long.parseLong(idString);
|
||||
} else {
|
||||
Preferences.set("update.id", String.valueOf(id));
|
||||
}
|
||||
|
||||
try {
|
||||
//int id = PApplet.parseInt(idString);
|
||||
//int latest = PApplet.toInt(PApplet.loadStrings());
|
||||
int latest = readInt(downloadURL + "?" + id);
|
||||
|
||||
String prompt =
|
||||
"A new version of Processing is available,\n" +
|
||||
"would you like to visit the Processing download page?";
|
||||
|
||||
if (latest > Base.VERSION) {
|
||||
Object[] options = { "Yes", "No" };
|
||||
int result = JOptionPane.showOptionDialog(editor,
|
||||
prompt,
|
||||
"Update",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
Base.openURL("http://processing.org/download/");
|
||||
|
||||
//} else if (result == JOptionPane.NO_OPTION) {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Error while trying to check for an update.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected int readInt(String filename) throws Exception {
|
||||
URL url = new URL(filename);
|
||||
InputStream stream = url.openStream();
|
||||
InputStreamReader isr = new InputStreamReader(stream);
|
||||
BufferedReader reader = new BufferedReader(isr);
|
||||
return Integer.parseInt(reader.readLine());
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,12 @@ settings.path.fallback=data
|
||||
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
# by default, check the processing server for any updates
|
||||
# (please avoid disabling, this also helps us know basic numbers
|
||||
# on how many people are using Processing)
|
||||
update.check = true
|
||||
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
# default size for the main window
|
||||
default.window.width = 500
|
||||
|
||||
Binary file not shown.
+5
-4
@@ -56,6 +56,11 @@ X then call them inside post()
|
||||
saturday evening and sunday morning
|
||||
X scrubbing all the code to include proper license and copyright info
|
||||
|
||||
sunday afternoon
|
||||
X update checker (can be turned off in prefs)
|
||||
X send unique id, and information about person's java vm/platform
|
||||
o using timezone would be an interesting method for tracking location
|
||||
|
||||
|
||||
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
@@ -78,10 +83,6 @@ _ code is larger than we'd like, has increased in size
|
||||
_ working to remove and optimize, also make possible to remove un-needed
|
||||
_ setup bugzilla, move legit bugs there, non-bugs to readme
|
||||
|
||||
_ update checker (can be turned off in prefs)
|
||||
_ send unique id, and information about person's java vm/platform
|
||||
_ using timezone would be an interesting method for tracking location
|
||||
|
||||
//
|
||||
|
||||
SAVE AS BUGS
|
||||
|
||||
Reference in New Issue
Block a user