Search in sources :

Example 76 with BXMLSerializer

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

the class JSONViewer method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    bxmlSerializer.getNamespace().put(APPLICATION_KEY, this);
    window = (Window) bxmlSerializer.readObject(JSONViewer.class, "json_viewer.bxml");
    bxmlSerializer.bind(this);
    Label prompt = new Label("Drag or paste JSON here");
    prompt.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    prompt.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    promptDecorator.setOverlay(prompt);
    treeView.getDecorators().add(promptDecorator);
    window.setTitle(WINDOW_TITLE);
    window.open(display);
    window.requestFocus();
    if (System.in.available() > 0) {
        JSONSerializer jsonSerializer = new JSONSerializer();
        try {
            setValue(jsonSerializer.readObject(System.in));
        } catch (Exception exception) {
        // No-op
        }
    }
}
Also used : Label(org.apache.pivot.wtk.Label) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer) IOException(java.io.IOException) JSONSerializer(org.apache.pivot.json.JSONSerializer)

Example 77 with BXMLSerializer

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

the class MemGame method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(getClass().getResource("memgame.bxml"));
    buttons = new PushButton[36];
    for (int aux = 0; aux < 36; aux++) {
        buttons[aux] = (PushButton) bxmlSerializer.getNamespace().get(String.valueOf(aux + 1));
        buttons[aux].getButtonPressListeners().add(this);
    }
    prepareGame();
    window.open(display);
    window.setWidth(420);
    window.setHeight(420);
}
Also used : BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 78 with BXMLSerializer

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

the class RowEditorDemo method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    String language = properties.get(LANGUAGE_KEY);
    Locale locale = (language == null) ? Locale.getDefault() : new Locale(language);
    Resources resources = new Resources(RESOURCE_NAME, locale);
    System.out.println("Loaded Resources from: " + resources.getBaseName() + ", for locale " + locale);
    // Search for a font that can support the sample string
    String title = (String) resources.get("title");
    System.out.println("Title from Resources file is: \"" + title + "\"");
    // print if the theme has transitions enabled
    System.out.println("Theme has transitions enabled: " + Theme.getTheme().isTransitionEnabled());
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(RowEditorDemo.class.getResource("row_editor_demo.bxml"), resources);
    window.open(display);
}
Also used : Locale(java.util.Locale) Resources(org.apache.pivot.util.Resources) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 79 with BXMLSerializer

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

the class ActionMappingTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    Action.getNamedActions().put("action1", new Action() {

        @Override
        public void perform(Component source) {
            Alert.alert(MessageType.INFO, "Action 1 performed.", window);
        }
    });
    Action.getNamedActions().put("action2", new Action() {

        @Override
        public void perform(Component source) {
            Alert.alert(MessageType.INFO, "Action 2 performed.", window);
        }
    });
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(ActionMappingTest.class, "action_mapping_test.bxml");
    window.getActionMappings().add(new Window.ActionMapping(new Keyboard.KeyStroke(Keyboard.KeyCode.B, Keyboard.Modifier.SHIFT.getMask()), "action2"));
    window.open(display);
    window.requestFocus();
}
Also used : Window(org.apache.pivot.wtk.Window) Action(org.apache.pivot.wtk.Action) Component(org.apache.pivot.wtk.Component) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 80 with BXMLSerializer

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

the class ApplicationWithPropertiesTest method startup.

@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
    System.out.println("application startup(...)");
    // initializeProperties(properties);
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(ApplicationWithPropertiesTest.class, "application_with_properties_test.bxml");
    initializeFields(bxmlSerializer);
    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