Revision: 4633 http://sourceforge.net/p/vexi/code/4633 Author: clrg Date: 2013-12-24 03:19:36 +0000 (Tue, 24 Dec 2013) Log Message: -----------
Modified Paths: -------------- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Resources.java branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/VMLBuilder.java branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/JDesktop.java branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/JPlatform.java branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/Platform.java branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/ui/Box.jpp Added Paths: ----------- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Desktop.java Added: branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Desktop.java =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Desktop.java (rev 0) +++ branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Desktop.java 2013-12-24 03:19:36 UTC (rev 4633) @@ -0,0 +1,90 @@ +// Copyright (c) 2013 the Contributors, as shown in the revision logs. +// Licensed under the GNU General Public License version 2 ("the License"). +// You may not use this file except in compliance with the License. + +package org.vexi.core; + +import java.io.File; +import java.io.IOException; +import java.net.URI; + +import org.ibex.js.Fountain; +import org.ibex.js.JS; +import org.ibex.js.JSExn; +import org.ibex.js.JSU; +import org.vexi.plat.Platform; + +public class Desktop extends JS.Immutable { + static private Desktop singleton; + static public Desktop get() throws JSExn { + if (singleton==null) { + try { + Class.forName("java.awt.Desktop"); + } catch (ClassNotFoundException e) { + } + if (!java.awt.Desktop.isDesktopSupported()) { + throw new JSExn("Desktop not supported"); + } + singleton = new Desktop(); + } + return singleton; + } + final Platform.Desktop desktop; + public Desktop() throws JSExn { desktop = Platform.getDesktop(); } + + public JS get(JS jskey) throws JSExn { + String key = JSU.toString(jskey); + if ("browse".equals(key)) return METHOD; + if ("edit".equals(key)) return METHOD; + if ("email".equals(key)) return METHOD; + if ("open".equals(key)) return METHOD; + if ("print".equals(key)) return METHOD; + return super.get(jskey); + } + + public JS callMethod(JS this_, JS jsmethod, JS[] args) throws JSExn { + String method = JSU.toString(jsmethod); + if (args.length==1) { + JS arg = args[0]; + try { + if ("browse".equals(method)) { + desktop.browse(expectURI(arg)); + return null; + } + if ("email".equals(method)) { + desktop.mail(expectURI(arg)); + return null; + } + if ("edit".equals(method)) { + desktop.edit(expectFile(arg)); + return null; + } + if ("open".equals(method)) { + desktop.open(expectFile(arg)); + return null; + } + if ("print".equals(method)) { + desktop.print(expectFile(arg)); + return null; + } + } catch(IOException e) { + throw new JSExn("Could not run method: "+method, e); + } + } + return super.get(jsmethod); + } + + static private URI expectURI(JS arg) throws JSExn { + return URI.create(JSU.toString(arg)); + } + + static private File expectFile(JS arg) throws JSExn { + Fountain f = JSU.getFountain(arg); + if (f instanceof Fountain.File) { + return new File(((Fountain.File)f).path); + } else { + throw new JSExn("Expected file fountain as argument: "+JSU.toString(arg)); + } + } + +} Property changes on: branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Desktop.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Resources.java =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Resources.java 2013-12-24 02:20:56 UTC (rev 4632) +++ branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Resources.java 2013-12-24 03:19:36 UTC (rev 4633) @@ -133,7 +133,7 @@ * from multiple locations, this will be 0.0.0.0 (the invalid * IP). */ - public static Vector originAddresses = null; + public static Vector<?> originAddresses = null; public static String originHost = null; Modified: branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java 2013-12-24 02:20:56 UTC (rev 4632) +++ branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java 2013-12-24 03:19:36 UTC (rev 4633) @@ -497,7 +497,6 @@ // FIXME: handle exceptions etc - better checking of types? /** Prepare an image for setting it as the icon of this surface */ public final void setIcon(JS jsIcon) throws JSExn { - System.out.println("Loading icons!"); if (jsIcon == null) { _setIcon(vexiIcon); return; @@ -508,7 +507,6 @@ final ArrayList<Picture> icon = new ArrayList<Picture>(); final Callable iconReady = new Callable() { public Object run(Object o) { - System.out.println("Loading icons!"); // check if icons are initialized as Pictures for (int i=0; iconArray.length>i; i++) { if (icon.size() < i+1) { @@ -529,7 +527,6 @@ } } // icons ready - System.out.println("icons ready!"); _setIcon(icon.size() == 0 ? vexiIcon : icon); return o; } Modified: branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/VMLBuilder.java =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/VMLBuilder.java 2013-12-24 02:20:56 UTC (rev 4632) +++ branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/VMLBuilder.java 2013-12-24 03:19:36 UTC (rev 4633) @@ -12,6 +12,7 @@ import org.ibex.js.ExecParser; import org.ibex.js.JS; +import org.ibex.js.JS.Constructor; import org.ibex.js.JSExn; import org.ibex.js.JSU; import org.ibex.js.JSU.Wrapper; @@ -185,7 +186,7 @@ private static final JS[] callempty = new JS[0]; private static String LOG_TYPE = "[Template Warning]"; - final Map constructors = new HashMap(); + final Map<String, Constructor> constructors = new HashMap<String, Constructor>(); /** handles XML parsing; builds a Template tree as it goes */ Modified: branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/JDesktop.java =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/JDesktop.java 2013-12-24 02:20:56 UTC (rev 4632) +++ branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/JDesktop.java 2013-12-24 03:19:36 UTC (rev 4633) @@ -8,82 +8,23 @@ import java.io.IOException; import java.net.URI; -import org.ibex.js.Fountain; -import org.ibex.js.JS; import org.ibex.js.JSExn; -import org.ibex.js.JSU; -public class JDesktop extends JS.Immutable { - static private JDesktop singleton; - static public JDesktop get() throws JSExn { - if (singleton==null) { - try { - Class.forName("java.awt.Desktop"); - } catch (ClassNotFoundException e) { - } - if (!java.awt.Desktop.isDesktopSupported()) { - throw new JSExn("Desktop not supported"); - } - singleton = new JDesktop(); +public class JDesktop implements Platform.Desktop { + public JDesktop() throws JSExn { + try { + Class.forName("java.awt.Desktop"); + } catch (ClassNotFoundException e) { } - return singleton; + if (!java.awt.Desktop.isDesktopSupported()) { + throw new JSExn("Desktop not supported"); + } } final java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); - public JS get(JS jskey) throws JSExn { - String key = JSU.toString(jskey); - if ("browse".equals(key)) return METHOD; - if ("edit".equals(key)) return METHOD; - if ("email".equals(key)) return METHOD; - if ("open".equals(key)) return METHOD; - if ("print".equals(key)) return METHOD; - return super.get(jskey); - } - - - public JS callMethod(JS this_, JS jsmethod, JS[] args) throws JSExn { - String method = JSU.toString(jsmethod); - if (args.length==1) { - JS arg = args[0]; - try{ - if ("browse".equals(method)) { - desktop.browse(expectURI(arg)); - return null; - } - if ("email".equals(method)) { - desktop.mail(expectURI(arg)); - return null; - } - if ("edit".equals(method)) { - desktop.edit(expectFile(arg)); - return null; - } - if ("open".equals(method)) { - desktop.open(expectFile(arg)); - return null; - } - if ("print".equals(method)) { - desktop.print(expectFile(arg)); - return null; - } - } catch(IOException e) { - throw new JSExn("Could not run method: "+method, e); - } - } - return super.get(jsmethod); - } - - static private URI expectURI(JS arg) throws JSExn { - return URI.create(JSU.toString(arg)); - } - - static private File expectFile(JS arg) throws JSExn { - Fountain f = JSU.getFountain(arg); - if (f instanceof Fountain.File) { - return new File(((Fountain.File)f).path); - } else { - throw new JSExn("Expected file fountain as argument: "+JSU.toString(arg)); - } - } - + public void browse(URI arg) throws IOException, JSExn { desktop.browse(arg); } + public void mail(URI arg) throws IOException, JSExn { desktop.mail(arg); } + public void edit(File arg) throws IOException, JSExn { desktop.edit(arg); } + public void open(File arg) throws IOException, JSExn { desktop.open(arg); } + public void print(File arg) throws IOException, JSExn { desktop.print(arg); } } Modified: branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/JPlatform.java =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/JPlatform.java 2013-12-24 02:20:56 UTC (rev 4632) +++ branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/JPlatform.java 2013-12-24 03:19:36 UTC (rev 4633) @@ -58,6 +58,8 @@ //////// Platform Implementation ////////////////////////////////// + protected Platform.Desktop _getDesktop() throws JSExn { return new JDesktop(); } + protected Font.Glyph _createGlyph(Font f, char c) { return new JGlyph(f, c); } protected Picture _createPicture(JS r) { return new JPicture(r); } protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { Modified: branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/Platform.java =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/Platform.java 2013-12-24 02:20:56 UTC (rev 4632) +++ branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/plat/Platform.java 2013-12-24 03:19:36 UTC (rev 4633) @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.URI; import org.ibex.js.JS; import org.ibex.js.JSExn; @@ -162,6 +163,19 @@ /** invoked after initialization messages have been printed; useful for additional platform detection log messages */ protected void postInit() { } + + public interface Desktop { + public void browse(URI arg) throws IOException, JSExn; + public void mail(URI arg) throws IOException, JSExn; + public void edit(File arg) throws IOException, JSExn; + public void open(File arg) throws IOException, JSExn; + public void print(File arg) throws IOException, JSExn; + } + + /** the desktop object that gives access to desktop/app interaction + * @throws JSExn */ + public static Desktop getDesktop() throws JSExn { return platform._getDesktop(); } + protected abstract Desktop _getDesktop() throws JSExn; /** the human-readable name of the key mapped to Vexi's 'alt' key */ public static String altKeyName() { return platform._altKeyName(); } Modified: branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp 2013-12-24 02:20:56 UTC (rev 4632) +++ branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp 2013-12-24 03:19:36 UTC (rev 4633) @@ -4,9 +4,6 @@ package org.vexi.core; -import java.awt.Desktop; -import java.io.File; - import org.ibex.crypto.MD5; import org.ibex.js.*; import org.ibex.js.JSU.*; @@ -297,6 +294,7 @@ } private Cache subCache = new Cache(20); + @SuppressWarnings("unchecked") private Sub getSub(JS key) { // DUBIOUS unnecessary caching? Sub ret = (Sub)subCache.get(key); @@ -306,6 +304,7 @@ return ret; } + @SuppressWarnings("unused") public JS get(JS name) throws JSExn { // FEATURE: Preprocessor hack to generate specialized JS instances (avoid all this string concatenation) //#switch(JSU.toString(name)) @@ -343,7 +342,7 @@ case "ui.mouse": return getSub(name); case "ui.screen": return getSub(name); - case "desktop": return org.vexi.plat.Desktop.get(); + case "desktop": return Desktop.get(); /* The version of the current Vexi core * @type(String) * @initial_value(varies,code=false) */ @@ -645,6 +644,7 @@ return null; } + @SuppressWarnings("unused") public void put(JS name, JS value) throws JSExn { //#switch(JSU.toString(name)) case "thread": @@ -707,7 +707,8 @@ } return new Fountain.File(f,write); } - + + @SuppressWarnings("unused") public JS callMethod(JS this_, JS method, JS[] args) throws JSExn { try { //#switch(JSU.toString(method)) Modified: branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/ui/Box.jpp =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/ui/Box.jpp 2013-12-24 02:20:56 UTC (rev 4632) +++ branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/ui/Box.jpp 2013-12-24 03:19:36 UTC (rev 4633) @@ -216,7 +216,7 @@ // useful debugging //private final int depth() { return parent==null ? 0 : parent.depth()+1; } - private final String name() { try { JS str = get(JSU.S("name")); return str==null?"null":str.toString(); } catch (JSExn e) { throw new Error(); } } + //private final String name() { try { JS str = get(JSU.S("name")); return str==null?"null":str.toString(); } catch (JSExn e) { throw new Error(); } } private static final int min(int a, int b) { return (a<b) ? a : b; } private static final int max(int a, int b) { return (a>b) ? a : b; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn