Search in sources :

Example 61 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class GridPaneTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(GridPaneTest.class, "gridpane_test.bxml");
    window.open(display);
}
Also used : BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 62 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class HyperlinkButtonTest2 method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer serializer = new BXMLSerializer();
    frame = (Frame) serializer.readObject(new ByteArrayInputStream(bxmlFile.getBytes()));
    frame.open(display);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 63 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class JavascriptConsoleTest method loadWindowFromURL.

/**
 * Load (and returns) a Window, given its URL and serializer to use <p> Note
 * that if public this method could be called even from JS in a bxml file
 * (but a reference to the current application has to be put in serializer
 * namespace). <p> Note that all Exceptions are catched inside this method,
 * to not expose them to JS code.
 *
 * @param urlString the URL of the bxml file to load, as a String
 * @param bxmlSerializer the serializer to use, or if null a new one will be created
 * @return the Window instance
 */
public Window loadWindowFromURL(String urlString, final BXMLSerializer bxmlSerializer) {
    logObject("loadWindow from \"" + urlString + "\", with the serializer " + bxmlSerializer);
    BXMLSerializer serializer = bxmlSerializer;
    if (serializer == null) {
        serializer = new BXMLSerializer();
    }
    Window loadedWindow = null;
    try {
        URL url = new URL(urlString);
        // force the location, so it will be possible to decode resources
        // like labels ...
        serializer.setLocation(url);
        loadedWindow = (Window) serializer.readObject(url);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (SerializationException e) {
        e.printStackTrace();
    }
    return loadedWindow;
}
Also used : Window(org.apache.pivot.wtk.Window) MalformedURLException(java.net.MalformedURLException) SerializationException(org.apache.pivot.serialization.SerializationException) IOException(java.io.IOException) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer) URL(java.net.URL)

Example 64 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class JavascriptConsoleTest method startup.

@Override
public void startup(Display displayArgument, Map<String, String> properties) throws Exception {
    logObject("startup: start");
    this.display = displayArgument;
    // get the locale from startup properties, or use the default
    String language = properties.get(LANGUAGE_KEY);
    locale = (language == null) ? Locale.getDefault() : new Locale(language);
    logObject("running with the locale " + locale);
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    // add a reference to the application itself in bxml namespace, to be
    // used by JS inside bxml files
    bxmlSerializer.getNamespace().put("application", this);
    logObject("put a reference to application in serializer namespace");
    bxmlSerializer.getNamespace().put("mainClassName", MAIN_CLASS_NAME);
    logObject("put a reference to main class name in serializer namespace \"" + MAIN_CLASS_NAME + "\"");
    window = loadWindow("javascript_console_test.bxml", bxmlSerializer);
    initializeFields(bxmlSerializer);
    window.open(display);
    logObject("startup: end");
}
Also used : Locale(java.util.Locale) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 65 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class Pivot949 method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    System.out.println("Pivot949 startup(...)");
    System.out.println("\n" + "Note that this issue is related to include scripts (with absolute path) " + "from a bxml file.\n" + "Here we'll test both relative and absolute scripts.\n" + "\n");
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(Pivot949.class, "pivot_949.bxml");
    System.out.println("got window = " + window);
    window.open(display);
}
Also used : BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Aggregations

BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)86 Component (org.apache.pivot.wtk.Component)24 IOException (java.io.IOException)19 SerializationException (org.apache.pivot.serialization.SerializationException)14 Window (org.apache.pivot.wtk.Window)13 Button (org.apache.pivot.wtk.Button)11 PushButton (org.apache.pivot.wtk.PushButton)11 File (java.io.File)9 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)9 Frame (org.apache.pivot.wtk.Frame)8 TextInput (org.apache.pivot.wtk.TextInput)8 ArrayList (org.apache.pivot.collections.ArrayList)7 List (org.apache.pivot.collections.List)7 Mouse (org.apache.pivot.wtk.Mouse)6 Sequence (org.apache.pivot.collections.Sequence)5 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)5 ListButton (org.apache.pivot.wtk.ListButton)5 TextInputContentListener (org.apache.pivot.wtk.TextInputContentListener)5 URL (java.net.URL)4 MalformedURLException (java.net.MalformedURLException)3