From astalla at common-lisp.net Sat Aug 7 20:35:19 2010 From: astalla at common-lisp.net (Alessio Stalla) Date: Sat, 07 Aug 2010 16:35:19 -0400 Subject: [snow-cvs] r80 - in trunk: . src/java/snow src/lisp/snow src/lisp/snow/showcase Message-ID: Author: astalla Date: Sat Aug 7 16:35:19 2010 New Revision: 80 Log: Small updates Modified: trunk/TODO trunk/src/java/snow/Snow.java trunk/src/lisp/snow/showcase/showcase.lisp trunk/src/lisp/snow/widgets.lisp Modified: trunk/TODO ============================================================================== --- trunk/TODO (original) +++ trunk/TODO Sat Aug 7 16:35:19 2010 @@ -1,2 +1,4 @@ * improve error handling and reporting * validation (JGoodies?) +* top-level widgets implicit with-gui +* jquery-like API Modified: trunk/src/java/snow/Snow.java ============================================================================== --- trunk/src/java/snow/Snow.java (original) +++ trunk/src/java/snow/Snow.java Sat Aug 7 16:35:19 2010 @@ -85,66 +85,6 @@ baseDir = fixPath(url.toString(), pathSeparator); baseDir = baseDir.substring(0, baseDir.length() - "snow/".length()); libDir = baseDir; - /*ZipInputStream extractor = null; - try { - String tmpDir = System.getProperty("java.io.tmpdir"); - if(tmpDir != null && fileSeparator != null) { - tmpDir = fixDirPath(tmpDir); - String jarUrlStr = url.getPath(); - int bangPos = jarUrlStr.indexOf('!'); - if(bangPos >= 0) { - jarUrlStr = jarUrlStr.substring(0, bangPos); - } - URL jarUrl = new URL(jarUrlStr); - extractor = new ZipInputStream(jarUrl.openStream()); - int targetDirIndex = 0; - File targetDir; - do { - targetDir = new File(tmpDir + "snow" + (targetDirIndex++)); - } while(targetDir.exists()); - targetDir.mkdir(); - targetDir.deleteOnExit(); - baseDir = targetDir.getAbsolutePath(); - baseDir = fixDirPath(baseDir); - libDir = baseDir; - for(ZipEntry entry = extractor.getNextEntry(); entry != null; entry = extractor.getNextEntry()) { - File extracted = new File(baseDir + entry.getName()); - extracted.deleteOnExit(); - if(entry.isDirectory()) { - extracted.mkdirs(); - } else { - extracted.getParentFile().mkdirs(); - FileOutputStream fos = new FileOutputStream(extracted); - byte[] buf = new byte[4096]; - while(true) { - int read = extractor.read(buf); - if(read != -1) { - fos.write(buf, 0, read); - } else { - fos.flush(); - fos.close(); - break; - } - } - } - extracted.setLastModified(entry.getTime()); - System.out.println("Extracted " + extracted.getAbsolutePath()); - } - } else { - throw new RuntimeException("Cannot extract jar " + url + " - no temp dir or file separator defined"); - } - } catch(Exception e) { - throw new RuntimeException("Cannot extract jar " + url, e); - } finally { - if(extractor != null) { - try { - extractor.close(); - } catch (IOException e) { - System.err.println("Couldn't close jar extractor: " + e.getMessage()); - e.printStackTrace(); - } - } - }*/ } else { throw new RuntimeException("Unsupported URL for snow.asd: " + url + " make sure it is a regular file or is in a jar."); @@ -341,6 +281,19 @@ } }); if(args.length == 0) { //Launch GUI REPL + Runnable r = new Runnable() { + public void run() { + try { + Interpreter interpreter = Interpreter.createDefaultInstance(args); + } catch(Throwable t) { + System.err.println("Caught error, exiting: " + t); + t.printStackTrace(); + System.exit(1); + } + } + }; + Thread t = new Thread(null, r, "interpreter", 4194304L); + t.start(); SplashScreen s = new SplashScreen(); s.setVisible(true); init(s); Modified: trunk/src/lisp/snow/showcase/showcase.lisp ============================================================================== --- trunk/src/lisp/snow/showcase/showcase.lisp (original) +++ trunk/src/lisp/snow/showcase/showcase.lisp Sat Aug 7 16:35:19 2010 @@ -109,13 +109,12 @@ (finish-output)))) (defun showcase (&optional exit-on-close-p) - (with-gui () - (frame (:id frame :title "Snow Showcase" :visible-p t :size #C(800 600) - :layout-manager '(:mig "fill") - :on-close (when exit-on-close-p :exit)) - (tabs (:layout "grow") - (dolist (x (reverse *examples*)) - (tab (car x) (funcall (cadr x)))))))) + (frame (:id frame :title "Snow Showcase" :visible-p t :size #C(800 600) + :layout-manager '(:mig "fill") + :on-close (when exit-on-close-p :exit)) + (tabs (:layout "grow") + (dolist (x (reverse *examples*)) + (tab (car x) (funcall (cadr x))))))) #|| (let ((fr (frame (:title "pippo" :visible-p t) Modified: trunk/src/lisp/snow/widgets.lisp ============================================================================== --- trunk/src/lisp/snow/widgets.lisp (original) +++ trunk/src/lisp/snow/widgets.lisp Sat Aug 7 16:35:19 2010 @@ -55,7 +55,11 @@ nil nil on-close nil nil nil nil)))) f)) -(define-container-widget frame (menu-bar title on-close) make-frame) +(define-container-widget %frame (menu-bar title on-close) make-frame) + +(defmacro frame (&rest args) ;;TODO actual args + `(with-gui () + (%frame , at args))) (defun make-dialog (&key parent title modal-p visible-p &allow-other-keys) (let ((d (jnew "javax.swing.JDialog" @@ -67,7 +71,7 @@ :title title) d)) -(define-widget-macro dialog +(define-widget-macro %dialog ((&rest args &key &common-widget-args id layout-manager parent title modal-p visible-p) &body body) @@ -83,6 +87,10 @@ ,@(generate-default-children-processing-code id body) (setf (widget-visible-p self) ,visible-p))) +(defmacro dialog (&rest args) ;;TODO actual args + `(with-gui () + (%dialog , at args))) + (defun make-file-chooser (&key multi-selection-p &allow-other-keys) (let ((c (jnew "javax.swing.JFileChooser"))) (jcall "setMultiSelectionEnabled" c (jbool multi-selection-p))